@Test public void testReplace() { final AnalysesModel model = new AnalysesModel(); final MCMCPresentation inco1 = new MCMCPresentation(d_wrapper, "inco1"); final MCMCPresentation inco2 = new MCMCPresentation(d_wrapper, "inco2"); model.add(ModelType.Inconsistency, inco1); JUnitUtil.assertAllAndOnly( model.getModels(ModelType.Inconsistency), Collections.singleton(inco1)); TreeModelListener listener = EasyMock.createStrictMock(TreeModelListener.class); TreeModelEvent event1a = new TreeModelEvent( model, new Object[] {model.getRoot(), ModelType.Inconsistency}, new int[] {0}, new Object[] {inco2}); listener.treeNodesChanged(TreeModelEventMatcher.eqTreeModelEvent(event1a)); EasyMock.replay(listener); model.addTreeModelListener(listener); model.replace(ModelType.Inconsistency, inco1, inco2); EasyMock.verify(listener); JUnitUtil.assertAllAndOnly( model.getModels(ModelType.Inconsistency), Collections.singleton(inco2)); }
@Test public void testEvents() { JUnitUtil.testSetter(d_mgDay, DoseUnit.PROPERTY_UNIT, d_gram, d_meter); JUnitUtil.testSetter( d_mgDay, DoseUnit.PROPERTY_SCALE_MODIFIER, ScaleModifier.MILLI, ScaleModifier.KILO); JUnitUtil.testSetter( d_mgDay, DoseUnit.PROPERTY_PER_TIME, EntityUtil.createDuration("P1D"), EntityUtil.createDuration("PT1H")); }
@Test public void testEquals() { JUnitUtil.assertNotEquals(d_var, null); JUnitUtil.assertNotEquals(d_var, new RateVariableType()); CategoricalVariableType var2 = new CategoricalVariableType(d_cats); assertEquals(d_var, var2); assertEquals(d_var.hashCode(), var2.hashCode()); var2.getCategories().add("Trans gender"); JUnitUtil.assertNotEquals(d_var, var2); }
@Test public void testSetValue() { JUnitUtil.testSetter( d_holder, "value", d_study.getCharacteristic(d_char), BasicStudyCharacteristic.Blinding.TRIPLE_BLIND); }
@Test public void testGetDependents() { ExampleData.initDefaultData(d_domain); Indication ind = ExampleData.buildIndicationDepression(); List<Entity> entities = new ArrayList<Entity>(); entities.add(ExampleData.buildStudyChouinard()); entities.add(ExampleData.buildStudyDeWilde()); entities.add(ExampleData.buildStudyBennie()); entities.add(ExampleData.buildStudyMultipleArmsperDrug()); JUnitUtil.assertAllAndOnly(entities, d_domain.getDependents(ind)); Drug fluox = ExampleData.buildDrugFluoxetine(); JUnitUtil.assertAllAndOnly(new HashSet<Entity>(entities), d_domain.getDependents(fluox)); Study s = ExampleData.buildStudyChouinard(); assertEquals(Collections.emptySet(), d_domain.getDependents(s)); OutcomeMeasure d1 = ExampleData.buildEndpointHamd(); assertEquals(new HashSet<Entity>(entities), d_domain.getDependents(d1)); }
@Test public void testClone() throws DatatypeConfigurationException { DoseUnit cloned = d_mgDay.clone(); assertEntityEquals(d_mgDay, cloned); assertNotSame(d_mgDay, cloned); cloned.setScaleModifier(ScaleModifier.KILO); JUnitUtil.assertNotEquals(d_mgDay.getScaleModifier(), cloned.getScaleModifier()); cloned.setScaleModifier(ScaleModifier.MILLI); assertEquals(d_mgDay.getScaleModifier(), cloned.getScaleModifier()); cloned.setUnit(new Unit("nonsense", "ns")); JUnitUtil.assertNotEquals(d_mgDay.getUnit(), cloned.getUnit()); cloned.setUnit(d_mgDay.getUnit()); assertEquals(d_mgDay.getUnit(), cloned.getUnit()); cloned.setPerTime(DatatypeFactory.newInstance().newDuration("P2D")); JUnitUtil.assertNotEquals(d_mgDay.getPerTime(), cloned.getPerTime()); cloned.setPerTime(d_mgDay.getPerTime()); assertEquals(d_mgDay.getPerTime(), cloned.getPerTime()); }
@Test public void testSetValueTriggersCharacteristicsChanged() { HashMap<BasicStudyCharacteristic, Object> newVal = new HashMap<BasicStudyCharacteristic, Object>(); Indication indication = new Indication(1L, "Indication"); newVal.put(d_char, indication); PropertyChangeListener l = JUnitUtil.mockListener(d_study.getCharacteristics(), MapBean.PROPERTY_CONTENTS, null, null); d_study.getCharacteristics().addPropertyChangeListener(l); d_holder.setValue(indication); verify(l); }
private static void assertRevisions( final DataSetModel model, long r0, long r1, Runnable runnable) { PropertyChangeListener listener = EasyMock.createStrictMock(PropertyChangeListener.class); for (long r = r0; r < r1; ++r) { listener.propertyChange( JUnitUtil.eqPropertyChangeEvent( new PropertyChangeEvent(model, DataSetModel.PROPERTY_REVISION, r, r + 1))); } EasyMock.replay(listener); model.addPropertyChangeListener(listener); runnable.run(); EasyMock.verify(listener); model.removePropertyChangeListener(listener); }
@Test public void testFile() { JUnitUtil.testSetter(new DataSetModel(), DataSetModel.PROPERTY_FILE, null, new File("/")); }