コード例 #1
0
  /** @see {@link CohortService#saveCohort(Cohort)} */
  @Test
  @Verifies(value = "should update an existing cohort", method = "saveCohort(Cohort)")
  public void saveCohort_shouldUpdateAnExistingCohort() throws Exception {
    executeDataSet(COHORT_XML);

    // get and modify a cohort in the  data set
    String modifiedCohortDescription = "This description has been modified in a test";
    Cohort cohortToModify = service.getCohort(2);
    cohortToModify.setDescription(modifiedCohortDescription);

    // save the modified cohort back to the data set, see if the modification is there
    service.saveCohort(cohortToModify);
    assertTrue(service.getCohort(2).getDescription().equals(modifiedCohortDescription));
  }
コード例 #2
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());
  }