Package org.jboss.resteasy.api.validation

Examples of org.jboss.resteasy.api.validation.ResteasyConstraintViolation


   private List<String> getMessagesFromList(List<ResteasyConstraintViolation> rcvs)
   {
      List<String> list = new ArrayList<String>();
      for (Iterator<ResteasyConstraintViolation> it = rcvs.iterator(); it.hasNext(); )
      {
         ResteasyConstraintViolation rcv = it.next();
         list.add(rcv.getMessage() + "; " + rcv.getValue());
      }
      return list;
   }
View Full Code Here


      Object header = response.getHeaders().getFirst(Validation.VALIDATION_HEADER);
      Assert.assertTrue(header instanceof String);
      Assert.assertTrue(Boolean.valueOf(String.class.cast(header)));
      ViolationReport report = response.readEntity(ViolationReport.class);
      countViolations(report, 1, 1, 1, 1, 0);
      ResteasyConstraintViolation violation = report.getFieldViolations().iterator().next();
      System.out.println("field path: " + violation.getPath());
      Assert.assertEquals(fieldPath, violation.getPath());
      violation = report.getPropertyViolations().iterator().next();
      System.out.println("property path: " + violation.getPath());
      Assert.assertEquals(propertyPath, violation.getPath());
      violation = report.getClassViolations().iterator().next();
      System.out.println("class path: " + violation.getPath());
      Assert.assertEquals(classPath, violation.getPath());;
      violation = report.getParameterViolations().iterator().next();
      System.out.println("parameter path: " + violation.getPath());
      Assert.assertEquals(parameterPath, violation.getPath());
   }
View Full Code Here

      Object header = response.getHeaders().getFirst(Validation.VALIDATION_HEADER);
      Assert.assertTrue(header instanceof String);
      Assert.assertTrue(Boolean.valueOf(String.class.cast(header)));
      ViolationReport report = response.readEntity(ViolationReport.class);
      countViolations(report, 0, 0, 0, 0, 1);
      ResteasyConstraintViolation violation = report.getReturnValueViolations().iterator().next();
      System.out.println("return value path: " + violation.getPath());
      Assert.assertEquals(returnValuePath, violation.getPath());
   }
View Full Code Here

         log.info("entity: " + answer);
         assertEquals(400, response.getStatus());
         ResteasyViolationException e = new ResteasyViolationException(String.class.cast(answer));
         System.out.println(e.toString());
         countViolations(e, 4, 1, 1, 1, 1, 0);
         ResteasyConstraintViolation cv = e.getFieldViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 3"));
         cv = e.getPropertyViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 5"));
         cv = e.getClassViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().indexOf("org.jboss.resteasy.resteasy1058.SumConstraint") > 0);
         cv = e.getParameterViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 7"));
         response.close();
        
         response = request2.get();
         log.info("status: " + response.getStatus());
         answer = response.getEntity(String.class);
         log.info("entity: " + answer);
         assertEquals(400, response.getStatus());
         e = new ResteasyViolationException(String.class.cast(answer));
         System.out.println(e.toString());
         countViolations(e, 4, 1, 1, 1, 1, 0);
         cv = e.getFieldViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 3"));
         cv = e.getPropertyViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 5"));
         cv = e.getClassViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().indexOf("org.jboss.resteasy.resteasy1058.SumConstraint") > 0);
         cv = e.getParameterViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 7"));
         response.close();
      }
   }
View Full Code Here

         log.info("entity: " + answer);
         assertEquals(500, response.getStatus());
         ResteasyViolationException e = new ResteasyViolationException(String.class.cast(answer));
         System.out.println(e.toString());
         countViolations(e, 1, 0, 0, 0, 0, 1);
         ResteasyConstraintViolation cv = e.getReturnValueViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be less than or equal to 0"));
         response.close();
        
         response = request2.get();  
         answer = response.getEntity(String.class);
         log.info("status: " + response.getStatus());
         log.info("entity: " + answer);
         assertEquals(500, response.getStatus());
         e = new ResteasyViolationException(String.class.cast(answer));
         System.out.println(e.toString());
         countViolations(e, 1, 0, 0, 0, 0, 1);
         cv = e.getReturnValueViolations().iterator().next();
         Assert.assertTrue(cv.getMessage().equals("must be less than or equal to 0"));
         response.close();
      }
   }
View Full Code Here

         for (Iterator<ConstraintViolation<Object>> it = cvs.iterator(); it.hasNext(); )
         {
            ConstraintViolation<Object> cv = it.next();
            Type ct = util.getConstraintType(cv);
            String path = (suppressPath ? "*" : cv.getPropertyPath().toString());
            rcvs.add(new ResteasyConstraintViolation(ct, path, cv.getMessage(), (cv.getInvalidValue() == null ? "null" :cv.getInvalidValue().toString())));
         }
      }
      catch (Exception e)
      {
         ViolationsContainer<Object> violationsContainer = getViolationsContainer(request, object);
View Full Code Here

            ConstraintViolation<Object> cv = it.next();
            Type ct = util.getConstraintType(cv);
            Object o = cv.getInvalidValue();
            String value = (o == null ? "" : o.toString());
            String path = (suppressPath ? "*" : cv.getPropertyPath().toString());
            rcvs.add(new ResteasyConstraintViolation(ct, path, cv.getMessage(), value));
         }
      }
      catch (Exception e)
      {
         violationsContainer.setException(e);
View Full Code Here

            ConstraintViolation<Object> cv = it.next();
            Type ct = util.getConstraintType(cv);
            Object o = cv.getInvalidValue();
            String value = (o == null ? "" : o.toString());
            String path = (suppressPath ? "*" : cv.getPropertyPath().toString());
            rcvs.add(new ResteasyConstraintViolation(ct, path, cv.getMessage(), value));
         }
      }
      catch (Exception e)
      {
         violationsContainer.setException(e);
View Full Code Here

            for (Iterator<ConstraintViolation<?>> it = cvs.iterator(); it.hasNext(); )
            {
               ConstraintViolation<?> cv = it.next();
               Type ct = util.getConstraintType(cv);
               String path = (suppressPath ? "*" : cv.getPropertyPath().toString());
               rcvs.add(new ResteasyConstraintViolation(ct, path, cv.getMessage(), (cv.getInvalidValue() == null ? "null" :cv.getInvalidValue().toString())));
            }
         }
         catch (Exception e1)
         {
            ViolationsContainer<Object> violationsContainer = getViolationsContainer(request, null);
View Full Code Here

      log.info("status: " + response.getStatus());
      log.info("entity: " + answer);
      assertEquals(400, response.getStatus());
      ViolationReport r = new ViolationReport(answer);
      countViolations(r, 1, 1, 1, 1, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 3"));
      cv = r.getPropertyViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 5"));
      cv = r.getClassViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().indexOf("org.jboss.resteasy.ejb.validation.SumConstraint") > 0);
      cv = r.getParameterViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 7"));
   }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.api.validation.ResteasyConstraintViolation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.