@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)); }
@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)); }