/**
   * Test that the {@link PersonProgramStatusController#create(UUID, PersonProgramStatusTO)} action
   * auto-expires old instances correctly.
   *
   * @throws ValidationException If validation error occurred.
   * @throws ObjectNotFoundException If object could not be found.
   */
  @Test
  public void testControllerCreateWithAutoExpiration()
      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 effective date does not match.", now, saved.getEffectiveDate());
    assertEquals(
        "Saved instance sets does not match.",
        PROGRAM_STATUS_CHANGE_REASON_ID,
        saved.getProgramStatusChangeReasonId());

    final PersonProgramStatusTO obj2 = createProgramStatus();
    obj2.setEffectiveDate(now);

    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());
    assertNotNull(
        "Original instance should have had an effective date.", autoExpired.getEffectiveDate());
  }
  /**
   * 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(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.");
 }