/**
   * Test that the {@link PersonProgramStatusController#create(UUID, PersonProgramStatusTO)} action
   * prohibits duplicates correctly.
   *
   * @throws ValidationException If validation error occurred.
   * @throws ObjectNotFoundException If object could not be found.
   */
  @Test(expected = ValidationException.class)
  public void testControllerCreateDuplicateProhibition()
      throws ValidationException, ObjectNotFoundException {
    final Date now = new Date();
    final PersonProgramStatusTO obj = createProgramStatus();
    obj.setEffectiveDate(now);
    final PersonProgramStatusTO saved = controller.create(PERSON_ID, obj);

    final UUID savedId = saved.getId();

    assertEquals("Saved instance values did not match.", now, saved.getEffectiveDate());
    assertEquals(
        "Saved instance sets did not match.",
        PROGRAM_STATUS_CHANGE_REASON_ID,
        saved.getProgramStatusChangeReasonId());

    final PersonProgramStatusTO obj2 = createProgramStatus();

    final PersonProgramStatusTO saved2 = controller.create(PERSON_ID, obj2);
    assertNotNull("Saved instance should not have been null.", saved2);

    final PersonProgramStatusTO autoExpired = controller.get(savedId, PERSON_ID);
    assertNotNull("Saved instance identifier should not have been null.", autoExpired);

    assertNotNull(
        "Original instance should have been auto-expired when new one added.",
        autoExpired.getExpirationDate());

    saved2.setExpirationDate(null);
    controller.save(saved2.getId(), PERSON_ID, saved2);
  }
  /**
   * Test the {@link PersonProgramStatusController#create(UUID, PersonProgramStatusTO)} and {@link
   * PersonProgramStatusController#delete(UUID, UUID)} actions.
   *
   * @throws ValidationException If validation error occurred.
   * @throws ObjectNotFoundException If object could not be found.
   */
  @Test(expected = ObjectNotFoundException.class)
  public void testControllerDelete() throws ValidationException, ObjectNotFoundException {
    final Date now = new Date();
    final PersonProgramStatusTO obj = createProgramStatus();
    obj.setEffectiveDate(now);
    final PersonProgramStatusTO saved = controller.create(PERSON_ID, obj);
    assertNotNull("Saved instance should not have been null.", saved);

    final UUID savedId = saved.getId();
    assertNotNull("Saved instance identifier should not have been null.", savedId);

    assertEquals("Saved instance values did not match.", now, saved.getEffectiveDate());
    assertEquals(
        "Saved instance sets did not match.",
        PROGRAM_STATUS_CHANGE_REASON_ID,
        saved.getProgramStatusChangeReasonId());

    final ServiceResponse response = controller.delete(savedId, PERSON_ID);

    assertNotNull("Deletion response should not have been null.", response);
    assertTrue("Deletion response did not return success.", response.isSuccess());

    final PersonProgramStatusTO afterDeletion = controller.get(savedId, PERSON_ID);
    // ObjectNotFoundException expected at this point
    assertNull(
        "Instance should not be able to get loaded after it has been deleted.", afterDeletion);
  }
  /**
   * Test the {@link PersonProgramStatusController#getAll(UUID, ObjectStatus, Integer, Integer,
   * String, String)} action.
   *
   * @throws ObjectNotFoundException If object could not be found.
   */
  @Test
  public void testControllerAll() throws ObjectNotFoundException {
    final Collection<PersonProgramStatusTO> list =
        controller.getAll(PERSON_ID, ObjectStatus.ACTIVE, null, null, null, null).getRows();

    assertNotNull("List should not have been null.", list);
  }
  /**
   * Test that the {@link PersonProgramStatusController#get(UUID, UUID)} action returns the correct
   * validation errors when an invalid ID is sent.
   *
   * @throws ValidationException If validation error occurred.
   * @throws ObjectNotFoundException If object could not be found.
   */
  @Test(expected = ObjectNotFoundException.class)
  public void testControllerGetOfInvalidId() throws ObjectNotFoundException, ValidationException {
    assertNotNull(
        "Controller under test was not initialized by the container correctly.", controller);

    final PersonProgramStatusTO obj = controller.get(PERSON_ID, UUID.randomUUID());

    assertNull("Returned PersonProgramStatusTO from the controller should have been null.", obj);
  }
 @Test(expected = ValidationException.class)
 public void testControllerCreateWithInvalidDataGetId()
     throws ValidationException, ObjectNotFoundException {
   final PersonProgramStatusTO obj = new PersonProgramStatusTO();
   obj.setId(UUID.randomUUID());
   obj.setEffectiveDate(null);
   controller.create(UUID.randomUUID(), obj);
   fail("Create with invalid Person UUID should have thrown exception.");
 }
  @Test
  public void testGetCurrent() throws ObjectNotFoundException, ValidationException {

    final PersonProgramStatus status = personProgramStatusService.getCurrent(PERSON_ID);

    final Date yesterday = new Date(new Date().getTime() - (24 * 60 * 60 * 1000));
    status.setExpirationDate(yesterday);

    // arrange, act
    final PersonProgramStatusTO programStatus = controller.getCurrent(PERSON_ID);

    // assert
    assertNull(
        "No PersonProgramStatus should have been returned as they are all currently expired.",
        programStatus);
  }
 /** Test that getLogger() returns the matching log class name for the current class under test. */
 @Test
 public void testLogger() {
   final Logger logger = controller.getLogger();
   assertEquals(
       "Log class name did not match.", controller.getClass().getName(), logger.getName());
 }