### Question:
AgendaValidator extends DataObjectValidator<Agenda, DataObjectRequest<Agenda>> { @Override public void validatePOST(DataObjectRequest<Agenda> request) { super.validatePOST(request); validationIssues = new LinkedList<>(); Agenda agenda = request.getDataObject(); validateOperations(agenda); if(validationIssues.size() > 0) { int lastIssueIndex = Math.min(validationIssues.size(), MAX_ISSUES); throw new ValidationException(String.format("Validation Issues detected: %1$s%2$s", String.join(",", validationIssues.subList(0, lastIssueIndex)), lastIssueIndex < validationIssues.size() ? "[Truncating additional issues]" : "") ); } }  @Override void validatePOST(DataObjectRequest<Agenda> request); AgendaValidator setJsonContext(JsonContext jsonContext);  }### Answer:
@Test(dataProvider = "invalidOperationsProvider", expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*No operations specified in Agenda.*") public void testInvalidOperations(Agenda agenda) { validator.validatePOST(createRequest(agenda)); }
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*Invalid references found in operation.*") public void testInvalidReferences() { Agenda agenda = createAgenda(CUSTOMER_ID); agenda.setOperations(Collections.singletonList(createOperation("Op1", "Op2.out"))); validator.validatePOST(createRequest(agenda)); }
@Test public void testPOPReference() { Agenda agenda = createAgenda(CUSTOMER_ID); agenda.setOperations(Collections.singletonList(createOperation("Op1", AgendaToken.AGENDA_ID.getToken()))); validator.validatePOST(createRequest(agenda)); }
@Test public void testValidReference() { Agenda agenda = createAgenda(CUSTOMER_ID); agenda.setOperations(Arrays.asList( createOperation("Op1", "Op2.out"), createOperation("Op2") )); validator.validatePOST(createRequest(agenda)); }
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*There is a circular reference.*") public void testCircularReferenceSimple() { Agenda agenda = createAgenda(CUSTOMER_ID); agenda.setOperations(Collections.singletonList(createOperation("Op1", "Op1.out"))); validator.validatePOST(createRequest(agenda)); }
@Test(dataProvider = "circularReferenceProvider", expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = ".*There is a circular reference.*") public void testCircularReference(List<Operation> operations) { Agenda agenda = createAgenda(CUSTOMER_ID); agenda.setOperations(operations); validator.validatePOST(createRequest(agenda)); }