예제 #1
0
 @Test
 public void testAddSubjectCriteriaNull() {
   assertTrue(validTrial.getCriteria().isEmpty());
   validTrial.addCriterion(null);
   assertTrue(validTrial.getCriteria().isEmpty());
   assertValid(validTrial);
 }
  @Test
  public void testDateDepenceIsValid() {
    stringUtil.getWithLength(20);

    Trial trial = factory.getTrial();

    trial.setStartDate(new GregorianCalendar(2006, 0, 1));
    trial.setEndDate(new GregorianCalendar());

    assertEquals(0, trialValidator.validate(trial).size());

    trial.setStartDate(new GregorianCalendar());
    trial.setEndDate(new GregorianCalendar(2006, 0, 1));

    assertEquals(1, trialValidator.validate(trial).size());

    trial.setStartDate(new GregorianCalendar(2006, 0, 1));
    trial.setEndDate(new GregorianCalendar(2006, 0, 1));

    assertEquals(1, trialValidator.validate(trial).size());

    trial.setEndDate(null);

    assertEquals(1, trialValidator.validate(trial).size());

    trial.setCreatedAt(null);

    assertEquals(1, trialValidator.validate(trial).size());

    trial.setEndDate(new GregorianCalendar(2006, 0, 1));

    assertEquals(1, trialValidator.validate(trial).size());
  }
예제 #3
0
  @Override
  public void setUp() {
    super.setUp();
    authenticatAsAdmin();
    validTrial = factory.getTrial();
    validTrial.setLeadingSite(user.getPerson().getTrialSite());
    validTrial.setSponsorInvestigator(user.getPerson());

    // if(validTrial.getParticipatingSites().size()<2){
    //
    // Person cp2 = new Person();
    // cp2.setFirstname("Contact");
    // cp2.setSurname("Person");
    // cp2.setEmail("*****@*****.**");
    // cp2.setPhone("1234567");
    // cp2.setSex(Gender.MALE);
    // TrialSite trialSite1 = new TrialSite();
    // trialSite1.setCity("Heidelberg");
    // trialSite1.setCountry("Germany");
    // trialSite1.setName("NCT");
    // trialSite1.setPostcode("69120");
    // trialSite1.setStreet("INF");
    // trialSite1.setPassword("1$heidelberg");
    // trialSite1.setContactPerson(cp2);
    //
    // trialSiteService.create(trialSite1);
    // validTrial.addParticipatingSite(trialSite1);
    // }

  }
예제 #4
0
 @Test
 public void testGenerateIds() {
   validTrial.setGenerateIds(true);
   assertTrue(validTrial.isGenerateIds());
   validTrial.setGenerateIds(false);
   assertFalse(validTrial.isGenerateIds());
 }
예제 #5
0
 @Test
 public void testLeadingSiteCorrect() {
   TrialSite c = factory.getTrialSite();
   validTrial.setLeadingSite(c);
   assertEquals(c, validTrial.getLeadingSite());
   assertValid(validTrial);
 }
예제 #6
0
 @Test
 public void testStratifyTrialSite() {
   validTrial.setStratifyTrialSite(true);
   assertTrue(validTrial.isStratifyTrialSite());
   validTrial.setStratifyTrialSite(false);
   assertFalse(validTrial.isStratifyTrialSite());
 }
예제 #7
0
 @Test
 public void testSponsorInvestigatorCorrect() {
   Person p = factory.getPerson();
   validTrial.setSponsorInvestigator(p);
   assertEquals(p, validTrial.getSponsorInvestigator());
   assertValid(validTrial);
 }
예제 #8
0
 @Test
 public void testAddParticipatingSitesNull() {
   assertTrue(validTrial.getParticipatingSites().isEmpty());
   validTrial.addParticipatingSite(null);
   validTrial.addParticipatingSite(null);
   assertEquals(0, validTrial.getParticipatingSites().size());
   assertValid(validTrial);
 }
예제 #9
0
 @Test
 public void testNameLongerThan255() {
   String[] invalidValues = {stringUtil.getWithLength(256), stringUtil.getWithLength(650)};
   for (String s : invalidValues) {
     validTrial.setName(s);
     assertEquals(s, validTrial.getName());
     assertInvalid(validTrial);
   }
 }
예제 #10
0
 @Test
 public void testAbbreviationNotLongerThan255() {
   String[] invalidValue = {stringUtil.getWithLength(256), stringUtil.getWithLength(600)};
   for (String s : invalidValue) {
     validTrial.setAbbreviation(s);
     assertEquals(s, validTrial.getAbbreviation());
     assertInvalid(validTrial);
   }
 }
예제 #11
0
 @Test
 public void testRandomizationConfigurationCorrect() {
   CompleteRandomizationConfig conf = new CompleteRandomizationConfig();
   conf.setTrial(null);
   assertNull(conf.getTrial());
   validTrial.setRandomizationConfiguration(conf);
   assertEquals(conf, validTrial.getRandomizationConfiguration());
   assertEquals(validTrial, conf.getTrial());
   assertValid(validTrial);
 }
예제 #12
0
  @Test
  public void testEndDateNotNull() {
    final GregorianCalendar startDate = new GregorianCalendar(1990, Calendar.NOVEMBER, 3);
    validTrial.setStartDate(startDate);
    assertEquals(startDate, validTrial.getStartDate());

    validTrial.setEndDate(null);
    assertNull(validTrial.getEndDate());
    assertInvalid(validTrial);
  }
예제 #13
0
  @Test
  public void testEndDateCorrect() {
    final GregorianCalendar date = new GregorianCalendar(1996, Calendar.FEBRUARY, 29);
    final GregorianCalendar endDate = new GregorianCalendar(2012, Calendar.NOVEMBER, 3);
    validTrial.setEndDate(endDate);
    assertEquals(endDate, validTrial.getEndDate());

    validTrial.setStartDate(date);
    assertEquals(date, validTrial.getStartDate());
    assertValid(validTrial);
  }
예제 #14
0
 @Test
 public void testAbbreviationCorrect() {
   String[] validValue = {
     stringUtil.getWithLength(255), stringUtil.getWithLength(1), stringUtil.getWithLength(136)
   };
   for (String s : validValue) {
     validTrial.setAbbreviation(s);
     assertEquals(s, validTrial.getAbbreviation());
     assertValid(validTrial);
   }
 }
예제 #15
0
  @Test
  public void testStrataNamesAndIdsStrataCriterions() {
    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setId(1);
    criterion1.setName("criterion1");
    criterion1.setOption1("option1");
    criterion1.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion1.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion1.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setId(2);
    criterion2.setName("criterion2");
    criterion2.setOption1("option1");
    criterion2.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion2.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion2.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    validTrial.addCriterion(criterion1);
    validTrial.addCriterion(criterion2);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(4, pair.first().size());
    assertEquals(4, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1_1;2_1;", pair.first().get(0));
    assertEquals("1_1;2_2;", pair.first().get(1));
    assertEquals("1_2;2_1;", pair.first().get(2));
    assertEquals("1_2;2_2;", pair.first().get(3));

    Collections.sort(pair.last());
    assertEquals("criterion1_option1;criterion2_option1;", pair.last().get(0));
    assertEquals("criterion1_option1;criterion2_option2;", pair.last().get(1));
    assertEquals("criterion1_option2;criterion2_option1;", pair.last().get(2));
    assertEquals("criterion1_option2;criterion2_option2;", pair.last().get(3));
  }
예제 #16
0
 @Test
 public void testDescriptionAnyLengt() {
   String[] validValues = {
     stringUtil.getWithLength(8941),
     stringUtil.getWithLength(2),
     stringUtil.getWithLength(10000000)
   };
   for (String s : validValues) {
     validTrial.setDescription(s);
     assertEquals(s, validTrial.getDescription());
     assertValid(validTrial);
   }
 }
예제 #17
0
 @Override
 @Transactional(propagation = Propagation.REQUIRED)
 public void logRandomize(
     LogEntry.ActionType action, String username, Trial trial, TrialSubject trialSubject) {
   LogEntry entry = new LogEntry();
   entry.setAction(action);
   entry.setUsername(username);
   entry.setClazz(trial.getClass());
   entry.setIdentifier(trial.getId());
   entry.setValue(trialSubject.toString());
   entry.setUiName(trialSubject.getUIName());
   entityManager.persist(entry);
 }
예제 #18
0
 @Test
 public void testNameCorrect() {
   String[] validValues = {
     stringUtil.getWithLength(254),
     stringUtil.getWithLength(2),
     "Name",
     stringUtil.getWithLength(132)
   };
   for (String s : validValues) {
     validTrial.setName(s);
     assertEquals(s, validTrial.getName());
     assertValid(validTrial);
   }
 }
예제 #19
0
  @Test
  public void testSubjectCriteriaCorrect() {
    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setName("criterion1");
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setName("criterion2");
    List<
            AbstractCriterion<
                ? extends Serializable, ? extends AbstractConstraint<? extends Serializable>>>
        criteria =
            new ArrayList<
                AbstractCriterion<
                    ? extends Serializable,
                    ? extends AbstractConstraint<? extends Serializable>>>();
    criteria.add(criterion1);
    criteria.add(criterion2);
    validTrial.setCriteria(criteria);
    assertEquals(2, validTrial.getCriteria().size());
    assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(0)));
    assertEquals("criterion1", validTrial.getCriteria().get(0).getName());
    assertTrue(DichotomousCriterion.class.isInstance(validTrial.getCriteria().get(1)));
    assertEquals("criterion2", validTrial.getCriteria().get(1).getName());

    List<
            AbstractCriterion<
                ? extends Serializable, ? extends AbstractConstraint<? extends Serializable>>>
        list =
            new ArrayList<
                AbstractCriterion<
                    ? extends Serializable,
                    ? extends AbstractConstraint<? extends Serializable>>>();
    validTrial.setCriteria(list);
    assertEquals(list, validTrial.getCriteria());
  }
예제 #20
0
 @Test
 public void testTreatmentArmsCorrect() {
   TreatmentArm arm1 = new TreatmentArm();
   arm1.setName("arm1");
   TreatmentArm arm2 = new TreatmentArm();
   arm2.setName("arm2");
   List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
   arms.add(arm1);
   arms.add(arm2);
   validTrial.setTreatmentArms(arms);
   assertEquals(arms, validTrial.getTreatmentArms());
   assertEquals(2, validTrial.getTreatmentArms().size());
   assertTrue(validTrial.getTreatmentArms().containsAll(arms));
   assertValid(validTrial);
 }
예제 #21
0
 @Test
 public void testConstructor() {
   final Trial t = new Trial();
   assertEquals("", t.getName());
   assertEquals("", t.getDescription());
   assertEquals("", t.getAbbreviation());
   assertNull(t.getStartDate());
   assertNull(t.getEndDate());
   assertEquals(TrialStatus.IN_PREPARATION, t.getStatus());
   assertNull(t.getProtocol());
   assertEquals(0, t.getParticipatingSites().size());
 }
예제 #22
0
  @Test
  public void testParticipatingSitesCorrect() {
    Set<TrialSite> cl = validTrial.getParticipatingSites();

    TrialSite c1 = factory.getTrialSite();
    TrialSite c2 = factory.getTrialSite();
    TrialSite c3 = factory.getTrialSite();

    cl.add(c1);
    cl.add(c2);
    cl.add(c3);

    assertEquals(3, validTrial.getParticipatingSites().size());

    assertValid(validTrial);
  }
예제 #23
0
 @Test
 public void testPlannedSubjectAmount() {
   TreatmentArm arm1 = new TreatmentArm();
   arm1.setName("arm1");
   arm1.setTrial(validTrial);
   arm1.setPlannedSubjects(100);
   TreatmentArm arm2 = new TreatmentArm();
   arm2.setName("arm2");
   arm2.setTrial(validTrial);
   arm2.setPlannedSubjects(100);
   List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
   arms.add(arm1);
   arms.add(arm2);
   validTrial.setTreatmentArms(arms);
   assertEquals(200, validTrial.getPlannedSubjectAmount());
 }
예제 #24
0
 @Test
 public void testAddParticipatingSitesCorrect() {
   assertTrue(validTrial.getParticipatingSites().isEmpty());
   TrialSite[] validValues = {
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite()
   };
   for (int i = 0; i < validValues.length; i++) {
     validTrial.addParticipatingSite(validValues[i]);
     assertEquals(i + 1, validTrial.getParticipatingSites().size());
     assertTrue(validTrial.getParticipatingSites().contains(validValues[i]));
     assertValid(validTrial);
   }
 }
예제 #25
0
 @Test
 public void testIsFresh() {
   TreatmentArm arm1 = new TreatmentArm();
   arm1.setName("arm1");
   arm1.setTrial(validTrial);
   arm1.setPlannedSubjects(100);
   TreatmentArm arm2 = new TreatmentArm();
   arm2.setName("arm2");
   arm2.setTrial(validTrial);
   arm2.setPlannedSubjects(100);
   List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
   arms.add(arm1);
   arms.add(arm2);
   validTrial.setTreatmentArms(arms);
   assertTrue(validTrial.isFresh());
   arm1.addSubject(new TrialSubject());
   assertFalse(validTrial.isFresh());
 }
예제 #26
0
  @Test
  public void testStrataNamesAndIdsStrataTrialSite() {

    TrialSite site1 = new TrialSite();
    site1.setId(1);
    site1.setName("site1");

    TrialSite site2 = new TrialSite();
    site2.setId(2);
    site2.setName("site2");

    TrialSite site3 = new TrialSite();
    site3.setId(3);
    site3.setName("site3");

    TrialSite site4 = new TrialSite();
    site4.setId(4);
    site4.setName("site4");

    validTrial.addParticipatingSite(site1);
    validTrial.addParticipatingSite(site2);
    validTrial.addParticipatingSite(site3);
    validTrial.addParticipatingSite(site4);

    validTrial.setStratifyTrialSite(true);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(4, pair.first().size());
    assertEquals(4, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1__", pair.first().get(0));
    assertEquals("2__", pair.first().get(1));
    assertEquals("3__", pair.first().get(2));
    assertEquals("4__", pair.first().get(3));

    Collections.sort(pair.last());
    assertEquals("site1", pair.last().get(0));
    assertEquals("site2", pair.last().get(1));
    assertEquals("site3", pair.last().get(2));
    assertEquals("site4", pair.last().get(3));
  }
예제 #27
0
 @Test
 public void testTotalSubjectAmount() {
   TreatmentArm arm1 = new TreatmentArm();
   arm1.setName("arm1");
   arm1.setTrial(validTrial);
   arm1.setPlannedSubjects(100);
   TreatmentArm arm2 = new TreatmentArm();
   arm2.setName("arm2");
   arm2.setTrial(validTrial);
   arm2.setPlannedSubjects(100);
   List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
   arms.add(arm1);
   arms.add(arm2);
   validTrial.setTreatmentArms(arms);
   for (int i = 1; i <= 100; i++) {
     if (i % 2 == 0) {
       arm1.addSubject(new TrialSubject());
     } else {
       arm2.addSubject(new TrialSubject());
     }
     assertEquals(i, validTrial.getTotalSubjectAmount());
   }
 }
예제 #28
0
  @Test
  public void testStatusCorrect() {
    validTrial.setStatus(TrialStatus.IN_PREPARATION);
    assertEquals(TrialStatus.IN_PREPARATION, validTrial.getStatus());
    assertValid(validTrial);

    validTrial.setStatus(TrialStatus.ACTIVE);
    assertEquals(TrialStatus.ACTIVE, validTrial.getStatus());
    assertValid(validTrial);

    validTrial.setStatus(TrialStatus.PAUSED);
    assertEquals(TrialStatus.PAUSED, validTrial.getStatus());
    assertValid(validTrial);

    validTrial.setStatus(TrialStatus.FINISHED);
    assertEquals(TrialStatus.FINISHED, validTrial.getStatus());
  }
예제 #29
0
 @Test
 public void testGetSubjects() {
   TreatmentArm arm1 = new TreatmentArm();
   arm1.setName("arm1");
   arm1.setTrial(validTrial);
   arm1.setPlannedSubjects(100);
   TreatmentArm arm2 = new TreatmentArm();
   arm2.setName("arm2");
   arm2.setTrial(validTrial);
   arm2.setPlannedSubjects(100);
   List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
   arms.add(arm1);
   arms.add(arm2);
   validTrial.setTreatmentArms(arms);
   for (int i = 1; i <= 100; i++) {
     TrialSubject sub = new TrialSubject();
     if (i % 2 == 0) {
       arm1.addSubject(sub);
     } else {
       arm2.addSubject(sub);
     }
     assertTrue(validTrial.getSubjects().contains(sub));
   }
 }
예제 #30
0
 @Test
 public void testGetRequieredFields() {
   Map<String, Boolean> map = validTrial.getRequiredFields();
   for (String key : map.keySet()) {
     if (key.equals("name")) {
       assertTrue(map.get(key));
     } else if (key.equals("abbreviation")) {
       assertFalse(map.get(key));
     } else if (key.equals("stratifyTrialSite")) {
       assertFalse(map.get(key));
     } else if (key.equals("description")) {
       assertFalse(map.get(key));
     } else if (key.equals("startDate")) {
       assertFalse(map.get(key));
     } else if (key.equals("endDate")) {
       assertFalse(map.get(key));
     } else if (key.equals("protocol")) {
       assertFalse(map.get(key));
     } else if (key.equals("sponsorInvestigator")) {
       assertTrue(map.get(key));
     } else if (key.equals("leadingSite")) {
       assertTrue(map.get(key));
     } else if (key.equals("status")) {
       assertTrue(map.get(key));
     } else if (key.equals("participatingSites")) {
       assertFalse(map.get(key));
     } else if (key.equals("treatmentArms")) {
       assertFalse(map.get(key));
     } else if (key.equals("subjectCriteria")) {
       assertFalse(map.get(key));
     } else if (key.equals("randomConf")) {
       assertFalse(map.get(key));
     } else if (key.equals("generateIds")) {
       assertFalse(map.get(key));
     } else if (key.equals("serialVersionUID")) {
       assertFalse(map.get(key));
     } else if (key.equals("SUBJECT_COUNT_COMPERATOR")) {
       assertFalse(map.get(key));
     } else if (key.equals("$VRc")) {
       assertFalse(map.get(key));
     } else fail(key + " not checked");
   }
 }