/** @see {@link CohortService#voidCohort(Cohort,String)} */
  @Test
  @Verifies(value = "should fail if reason is null", method = "voidCohort(Cohort,String)")
  public void voidCohort_shouldFailIfReasonIsNull() throws Exception {
    executeDataSet(COHORT_XML);

    // Get a non-voided, valid Cohort and try to void it with a null reason
    Cohort exampleCohort = service.getCohort("Example Cohort");
    assertNotNull(exampleCohort);
    assertFalse(exampleCohort.isVoided());

    try {
      service.voidCohort(exampleCohort, null);
      Assert.fail("voidCohort should fail with exception if reason is null.");
    } catch (Exception e) {
    }

    // Now get the Cohort and try to void it with an empty reason
    exampleCohort = service.getCohort("Example Cohort");
    assertNotNull(exampleCohort);
    assertFalse(exampleCohort.isVoided());

    try {
      service.voidCohort(exampleCohort, "");
      Assert.fail("voidCohort should fail with exception if reason is empty");
    } catch (Exception e) {
    }
  }
  /** @see {@link CohortService#voidCohort(Cohort,String)} */
  @Test
  @Verifies(value = "should void cohort", method = "voidCohort(Cohort,String)")
  public void voidCohort_shouldVoidCohort() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have a cohort that is not voided
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());
    assertFalse(allCohorts.get(1).isVoided());

    // now void the cohort and see if it's voided
    Cohort voidedCohort = service.voidCohort(allCohorts.get(1), "voided for Test");
    assertTrue(allCohorts.get(1).isVoided());
  }
  /** @see {@link CohortService#voidCohort(Cohort,String)} */
  @Test
  @Verifies(
      value = "should not change an already voided cohort",
      method = "voidCohort(Cohort,String)")
  public void voidCohort_shouldNotChangeAnAlreadyVoidedCohort() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have an already voided cohort
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());
    assertTrue(allCohorts.get(0).isVoided());

    // Make sure the void reason is different from the reason to be given in the test
    assertNotNull(allCohorts.get(0).getVoidReason());
    String reasonAlreadyVoided = allCohorts.get(0).getVoidReason();
    String voidedForTest = "Voided for test";
    assertFalse(voidedForTest.equals(reasonAlreadyVoided));

    // Try to void and see if the void reason changes as a result
    Cohort voidedCohort = service.voidCohort(allCohorts.get(0), voidedForTest);
    assertFalse(voidedCohort.getVoidReason().equals(voidedForTest));
    assertTrue(voidedCohort.getVoidReason().equals(reasonAlreadyVoided));
  }