### Question:
DrugTreatmentPresentation extends PresentationModel<DrugTreatment> { public DosePresentation getDoseModel() { return new DosePresentationImpl(this); } DrugTreatmentPresentation(DrugTreatment bean); DosePresentation getDoseModel();  }### Answer:
@Test public void testFixedDoseModelInitialValues() { FixedDose dose = new FixedDose(25.5, DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); assertEquals(dose.getQuantity(), d_pm.getDoseModel().getMinModel().getValue()); assertEquals(dose.getQuantity(), d_pm.getDoseModel().getMaxModel().getValue()); }
@Test public void testFlexibleDoseModelInitialValues() { FlexibleDose dose = new FlexibleDose(new Interval<Double>(25.5, 30.2), DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); assertEquals(dose.getFlexibleDose().getLowerBound(), d_pm.getDoseModel().getMinModel().getValue()); assertEquals(dose.getFlexibleDose().getUpperBound(), d_pm.getDoseModel().getMaxModel().getValue()); }
@Test public void testFixedToFlexible() { FixedDose dose = new FixedDose(25.5, DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); d_pm.getDoseModel().getMaxModel().setValue(dose.getQuantity() + 2); assertTrue(d_pm.getBean().getDose() instanceof FlexibleDose); }
@Test public void testFlexibleToFixed() { FlexibleDose dose = new FlexibleDose(new Interval<Double>(25.5, 30.2), DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); d_pm.getDoseModel().getMaxModel().setValue(dose.getFlexibleDose().getLowerBound()); assertTrue(d_pm.getBean().getDose() instanceof FixedDose); }
@Test public void testSetMaxLowerThanMinDose() { FlexibleDose dose = new FlexibleDose(new Interval<Double>(10.0, 20.0), DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); d_pm.getDoseModel().getMaxModel().setValue(8d); assertEquals(8d, d_pm.getDoseModel().getMaxModel().doubleValue(), 0.001); assertEquals(8d, d_pm.getDoseModel().getMinModel().doubleValue(), 0.001); assertTrue(d_pm.getBean().getDose() instanceof FixedDose); }
@Test public void testSetMinHigherThanMaxDose() { FlexibleDose dose = new FlexibleDose(new Interval<Double>(10.0, 20.0), DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); d_pm.getDoseModel().getMinModel().setValue(25d); assertEquals(25d, d_pm.getDoseModel().getMaxModel().doubleValue(), 0.001); assertEquals(25d, d_pm.getDoseModel().getMinModel().doubleValue(), 0.001); assertTrue(d_pm.getBean().getDose() instanceof FixedDose); }
@Test public void testSetDoseUnit() { FlexibleDose dose = new FlexibleDose(new Interval<Double>(10.0,20.0), DoseUnit.createMilliGramsPerDay()); d_drugTreatment.setDose(dose); assertEntityEquals(d_pm.getDoseModel().getDoseUnitPresentation().getBean(), d_drugTreatment.getDose().getDoseUnit()); }