@Test(dataProvider = "validationIssuesProvider") public void testProcessValidationIssues(List<String> validationIssues, final boolean EXPECT_ERROR, final boolean EXPECT_TRUNCATED) { try { defaultRequestValidator.processValidationIssues(validationIssues); if(EXPECT_ERROR) Assert.fail("Expected ValidationException"); } catch(ValidationException e) { String message = e.getMessage(); Assert.assertNotNull(message); Assert.assertEquals(message.contains(DefaultRequestValidator.VALIDATION_TRUNCATION_MESSAGE), EXPECT_TRUNCATED); if(validationIssues == null) return; int endIndex = Math.min(defaultRequestValidator.getMaxValidationIssuesToReport(), validationIssues.size()); for(int idx = 0; idx < endIndex; idx++) { String issue = validationIssues.get(idx); Assert.assertTrue(message.contains(issue), "Expected to find validation issue: " + issue); } for(int idx = endIndex; idx < validationIssues.size(); idx++) { String issue = validationIssues.get(idx); Assert.assertFalse(message.contains(issue), "Unexpected validation issue present (should have been truncated): " + issue); } } }
public void processValidationIssues(List<String> validationIssues) { if(validationIssues == null || validationIssues.size() == 0) return; int lastIssueIndex = Math.min(validationIssues.size(), getMaxValidationIssuesToReport()); throw new ValidationException(String.format("Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? VALIDATION_TRUNCATION_MESSAGE : "") ); }
DefaultRequestValidator implements RequestValidator<R> { public void processValidationIssues(List<String> validationIssues) { if(validationIssues == null || validationIssues.size() == 0) return; int lastIssueIndex = Math.min(validationIssues.size(), getMaxValidationIssuesToReport()); throw new ValidationException(String.format("Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? VALIDATION_TRUNCATION_MESSAGE : "") ); } }
DefaultRequestValidator implements RequestValidator<R> { public void processValidationIssues(List<String> validationIssues) { if(validationIssues == null || validationIssues.size() == 0) return; int lastIssueIndex = Math.min(validationIssues.size(), getMaxValidationIssuesToReport()); throw new ValidationException(String.format("Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? VALIDATION_TRUNCATION_MESSAGE : "") ); }  }
DefaultRequestValidator implements RequestValidator<R> { public void processValidationIssues(List<String> validationIssues) { if(validationIssues == null || validationIssues.size() == 0) return; int lastIssueIndex = Math.min(validationIssues.size(), getMaxValidationIssuesToReport()); throw new ValidationException(String.format("Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? VALIDATION_TRUNCATION_MESSAGE : "") ); }  @Override void validateGET(R request); @Override void validatePOST(R request); @Override void validatePUT(R request); @Override void validateDELETE(R request); void processValidationIssues(List<String> validationIssues); }
DefaultRequestValidator implements RequestValidator<R> { public void processValidationIssues(List<String> validationIssues) { if(validationIssues == null || validationIssues.size() == 0) return; int lastIssueIndex = Math.min(validationIssues.size(), getMaxValidationIssuesToReport()); throw new ValidationException(String.format("Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? VALIDATION_TRUNCATION_MESSAGE : "") ); }  @Override void validateGET(R request); @Override void validatePOST(R request); @Override void validatePUT(R request); @Override void validateDELETE(R request); void processValidationIssues(List<String> validationIssues); static final String VALIDATION_TRUNCATION_MESSAGE; }