Examples of ViolationReport


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

      // Invalid
      request = new ClientRequest(generateURL("/a/uvwxyz"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      countViolations(r, 1, 1, 0, 0, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertEquals("size must be between 2 and 4", cv.getMessage());
      Assert.assertEquals("a", cv.getValue());
      cv = r.getPropertyViolations().iterator().next();
      Assert.assertEquals("size must be between 3 and 5", cv.getMessage());
      Assert.assertEquals("uvwxyz", cv.getValue());
      after();
   }
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/a/b"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      countViolations(r, 0, 0, 1, 0, 0);
      ResteasyConstraintViolation cv = r.getClassViolations().iterator().next();
      Assert.assertEquals("Concatenation of s and t must have length > 5", cv.getMessage());
      Assert.assertEquals("TestResourceWithClassConstraint(\"a\", \"b\")", cv.getValue());
      System.out.println(cv.getValue());
      after();
   }
View Full Code Here

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

         Foo foo = new Foo("p");
         request.body("application/foo", foo);
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(400, response.getStatus());
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report);
         countViolations(report, 4, 2, 1, 1, 1, 0);
         Iterator<ResteasyConstraintViolation> iterator = report.getFieldViolations().iterator();
         ResteasyConstraintViolation cv1 = iterator.next();
         ResteasyConstraintViolation cv2 = iterator.next();
         if (!("a").equals(cv1.getValue()))
         {
            ResteasyConstraintViolation tmp = cv1;
            cv1 = cv2;
            cv2 = tmp;
         }
         Assert.assertEquals("size must be between 2 and 4", cv1.getMessage());
         Assert.assertEquals("a", cv1.getValue());
         Assert.assertEquals("size must be between 2 and 4", cv2.getMessage());
         Assert.assertEquals("b", cv2.getValue());
         ResteasyConstraintViolation cv = report.getPropertyViolations().iterator().next();
         Assert.assertEquals("size must be between 3 and 5", cv.getMessage());
         Assert.assertEquals("c", cv.getValue());
         cv = report.getClassViolations().iterator().next();
         Assert.assertEquals("Concatenation of s and u must have length > 5", cv.getMessage());
         System.out.print("value: " + cv.getValue());
         Assert.assertTrue(cv.getValue().startsWith("org.jboss.resteasy.test.validation.TestValidationXML$TestResourceWithAllFivePotentialViolations@"));
         cv = report.getParameterViolations().iterator().next();
         Assert.assertEquals("s must have length: 3 <= length <= 5", cv.getMessage());
         Assert.assertEquals("Foo[p]", cv.getValue());
      }

      after();
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/abc/xyz"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      countViolations(r, 2, 0, 0, 0, 0);
      Iterator<ResteasyConstraintViolation> it = r.getFieldViolations().iterator();
      ResteasyConstraintViolation cv1 = it.next();
      ResteasyConstraintViolation cv2 = it.next();
      if (cv1.getValue().equals("xyz"))
      {
         ResteasyConstraintViolation tmp = cv1;
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/abc"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      System.out.println("exception: " + r);
      countViolations(r, 1, 0, 0, 0, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().startsWith("size must be between 5 and"));
      Assert.assertEquals("abc", cv.getValue());
      after();
   }
View Full Code Here

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

         Foo foo = new Foo("123");
         request.body("application/foo", foo);
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(500, response.getStatus());
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report);
         countViolations(report, 1, 0, 0, 0, 0, 1);
         ResteasyConstraintViolation cv = report.getReturnValueViolations().iterator().next();
         System.out.println("message: " + cv.getMessage());
         System.out.println("value: " + cv.getValue());
         Assert.assertEquals("s must have length: 4 <= length <= 5", cv.getMessage());
         Assert.assertEquals(foo.toString(), cv.getValue());
      }
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/abc"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      countViolations(r, 1, 0, 0, 0, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().startsWith("size must be between 5 and"));
      Assert.assertEquals("abc", cv.getValue());
      after();
   }
View Full Code Here

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

         Foo foo = new Foo("p");
         request.body("application/foo", foo);
         request.accept(MediaType.APPLICATION_XML);
         ClientResponse<?> response = request.post(Foo.class);
         Assert.assertEquals(400, response.getStatus());
         ViolationReport report = response.getEntity(ViolationReport.class);
         System.out.println("report: " + report);
         countViolations(report, 4, 2, 1, 1, 1, 0);
         Iterator<ResteasyConstraintViolation> iterator = report.getFieldViolations().iterator();
         ResteasyConstraintViolation cv1 = iterator.next();
         ResteasyConstraintViolation cv2 = iterator.next();
         if (!("a").equals(cv1.getValue()))
         {
            ResteasyConstraintViolation tmp = cv1;
            cv1 = cv2;
            cv2 = tmp;
         }
         Assert.assertEquals("size must be between 2 and 4", cv1.getMessage());
         Assert.assertEquals("a", cv1.getValue());
         Assert.assertEquals("size must be between 2 and 4", cv2.getMessage());
         Assert.assertEquals("b", cv2.getValue());
         ResteasyConstraintViolation cv = report.getPropertyViolations().iterator().next();
         Assert.assertEquals("size must be between 3 and 5", cv.getMessage());
         Assert.assertEquals("c", cv.getValue());
         cv = report.getClassViolations().iterator().next();
         Assert.assertEquals("Concatenation of s and u must have length > 5", cv.getMessage());
         System.out.print("value: " + cv.getValue());
         Assert.assertTrue(cv.getValue().startsWith("org.jboss.resteasy.test.validation.TestValidationXML$TestResourceWithAllFivePotentialViolations@"));
         cv = report.getParameterViolations().iterator().next();
         Assert.assertEquals("s must have length: 3 <= length <= 5", cv.getMessage());
         Assert.assertEquals("Foo[p]", cv.getValue());
      }

      after();
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/abc"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      countViolations(r, 1, 0, 0, 0, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().startsWith("size must be between 5 and"));
      Assert.assertEquals("abc", cv.getValue());
      after();
   }
View Full Code Here

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

      // Invalid
      request = new ClientRequest(generateURL("/abc"));
      response = request.post(String.class);
      Assert.assertEquals(400, response.getStatus());
      String entity = response.getEntity(String.class);
      ViolationReport r = new ViolationReport(entity);
      System.out.println("exception: " + r);
      countViolations(r, 1, 0, 0, 0, 0);
      ResteasyConstraintViolation cv = r.getFieldViolations().iterator().next();
      Assert.assertTrue(cv.getMessage().startsWith("size must be between 5 and"));
      Assert.assertEquals("abc", cv.getValue());
      after();
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.