コード例 #1
0
 /** @see {@link CohortService#purgeCohort(Cohort)} */
 @Test
 @Verifies(value = "should delete cohort from database", method = "purgeCohort(Cohort)")
 public void purgeCohort_shouldDeleteCohortFromDatabase() throws Exception {
   executeDataSet(COHORT_XML);
   List<Cohort> allCohorts = service.getAllCohorts(true);
   assertEquals(2, allCohorts.size());
   service.purgeCohort(allCohorts.get(0));
   allCohorts = service.getAllCohorts(true);
   assertEquals(1, allCohorts.size());
 }
コード例 #2
0
  /** @see {@link CohortService#getAllCohorts(null)} */
  @Test
  @Verifies(value = "should return all cohorts and voided", method = "getAllCohorts(null)")
  public void getAllCohorts_shouldReturnAllCohortsAndVoided() throws Exception {
    executeDataSet(COHORT_XML);

    // data set should have two cohorts, one of which is voided
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());
    assertTrue(allCohorts.get(0).isVoided());
    assertFalse(allCohorts.get(1).isVoided());

    // if called with false parameter, should not return the voided one
    allCohorts = service.getAllCohorts(false);
    assertNotNull(allCohorts);
    // only the non-voided cohort should be returned
    assertEquals(1, allCohorts.size());
    assertFalse(allCohorts.get(0).isVoided());
  }
コード例 #3
0
  /** @see {@link CohortService#getAllCohorts()} */
  @Test
  @Verifies(value = "should not return any voided cohorts", method = "getAllCohorts()")
  public void getAllCohorts_shouldNotReturnAnyVoidedCohorts() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have two cohorts, the first of which is voided
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());
    assertTrue(allCohorts.get(0).isVoided());
    assertFalse(allCohorts.get(1).isVoided());

    // now call the target method and see if the voided cohort shows up
    allCohorts = service.getAllCohorts();
    assertNotNull(allCohorts);
    // only the non-voided cohort should be returned
    assertEquals(1, allCohorts.size());
    assertFalse(allCohorts.get(0).isVoided());
  }
コード例 #4
0
  /** @see {@link CohortService#saveCohort(Cohort)} */
  @Test
  @Verifies(value = "should create new cohorts", method = "saveCohort(Cohort)")
  public void saveCohort_shouldCreateNewCohorts() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have two cohorts
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());

    // make and save a new one
    Integer[] ids = {2, 3};
    Cohort newCohort = new Cohort("a third cohort", "a  cohort to add for testing", ids);
    service.saveCohort(newCohort);

    // see if the new cohort shows up in the list of cohorts
    allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(3, allCohorts.size());
  }
コード例 #5
0
  /**
   * @verifies {@link CohortService#getAllCohorts()} test = should get all nonvoided cohorts in
   *     database
   */
  @Test
  @Verifies(value = "should get all nonvoided cohorts in database", method = "getAllCohorts()")
  public void getAllCohorts_shouldGetAllNonvoidedCohortsInDatabase() throws Exception {
    executeDataSet(COHORT_XML);

    // call the method
    List<Cohort> allCohorts = service.getAllCohorts();
    assertNotNull(allCohorts);
    // there is only one non-voided cohort in the data set
    assertEquals(1, allCohorts.size());
    assertFalse(allCohorts.get(0).isVoided());
  }
コード例 #6
0
  /** @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());
  }
コード例 #7
0
  /** @see {@link CohortService#getCohort(String)} */
  @Test
  @Verifies(value = "should only get non voided cohorts by name", method = "getCohort(String)")
  public void getCohort_shouldOnlyGetNonVoidedCohortsByName() throws Exception {
    executeDataSet(COHORT_XML);

    // make sure we have two cohorts with the same name and the first is voided
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(2, allCohorts.size());
    assertTrue(allCohorts.get(0).isVoided());
    assertFalse(allCohorts.get(1).isVoided());

    // now do the actual test: getCohort by name and expect a non voided cohort
    Cohort exampleCohort = service.getCohort("Example Cohort");
    assertNotNull(exampleCohort);
    assertEquals(2, exampleCohort.size());
    assertFalse(exampleCohort.isVoided());
  }
コード例 #8
0
  /** @see {@link CohortService#getCohort(String)} */
  @Test
  @Verifies(
      value = "should get the nonvoided cohort if two exist with same name",
      method = "getCohort(String)")
  public void getCohort_shouldGetTheNonvoidedCohortIfTwoExistWithSameName() throws Exception {
    executeDataSet(COHORT_XML);

    // check to see if both cohorts have the same name and if one is voided
    List<Cohort> allCohorts = service.getAllCohorts(true);
    assertNotNull(allCohorts);
    assertEquals(allCohorts.get(0).getName(), allCohorts.get(1).getName());
    assertTrue(allCohorts.get(0).isVoided());
    assertFalse(allCohorts.get(1).isVoided());
    // the non-voided cohort should have an id of 2
    assertTrue(allCohorts.get(1).getCohortId() == 2);

    // ask for the cohort by name
    Cohort cohortToGet = service.getCohort("Example Cohort");
    // see if the non-voided one got returned
    assertTrue(cohortToGet.getCohortId() == 2);
  }
コード例 #9
0
  /** @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));
  }