### Question:
DataObjectValidator extends DefaultRequestValidator<R> { @Override public void validatePUT(R request) { super.validatePUT(request); validateObjectRequest(request, "PUT"); if(request.getId() == null) throw new ValidationException(UNABLE_TO_PUT_WITHOUT_ID_EXCEPTION); T object = request.getDataObject(); if(object.getId() != null && !object.getId().equals(request.getId())) throw new ValidationException(String.format(MISMATCHED_PUT_ID_EXCEPTION, request.getId(), object.getId())); }  @Override void validatePOST(R request); @Override void validatePUT(R request);  }### Answer:
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Unable to PUT a null object") public void testPUTValidationNullObject() { DefaultDataObjectRequest<Agenda> request = createAgendaRequest(null); validator.validatePUT(request); }
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Unable to PUT an object without specifying an id") public void testPUTValidationNullId() { DefaultDataObjectRequest<Agenda> request = createAgendaRequest(null); request.setDataObject(new Agenda()); validator.validatePUT(request); }
@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "Mismatched Id in URL and on input object: URLId: theURLId and ObjectId: theAgendaId") public void testPUTValidationMismatchedId() { final String URL_ID = "theURLId"; final String AGENDA_ID = "theAgendaId"; DefaultDataObjectRequest<Agenda> request = createAgendaRequest(URL_ID); Agenda agenda = new Agenda(); agenda.setId(AGENDA_ID); request.setDataObject(agenda); validator.validatePUT(request); }
@Test public void testPUTValidationRequestIdOnly() { final String URL_ID = "theURLId"; DefaultDataObjectRequest<Agenda> request = createAgendaRequest(URL_ID); request.setDataObject(new Agenda()); validator.validatePUT(request); }