### Question:
DurationPresentation extends AbstractObservable { public void setUnits(DateUnits units) { if (getDefined()) { DateUnits oldValue = d_data.units; d_data = new Data(units, d_data.quantity); d_bean.setDuration(d_data.getDuration()); firePropertyChange(PROPERTY_DURATION_UNITS, oldValue, units); } } DurationPresentation(T bean); static Data parseDuration(Duration duration, DateUnits prevUnits); DateUnits getUnits(); void setUnits(DateUnits units); int getQuantity(); void setQuantity(int quantity); boolean getDefined(); void setDefined(boolean defined); static Duration generateDuration(String duration); String getLabel(); @Override String toString(); static final String PROPERTY_DEFINED; static final String PROPERTY_DURATION_QUANTITY; static final String PROPERTY_DURATION_UNITS; static final String PROPERTY_LABEL; }### Answer:
@Test public void testSetUnits() throws DatatypeConfigurationException { d_epoch1.setDuration(DatatypeFactory.newInstance().newDuration("PT3H")); assertEquals(DateUnits.Hours, d_pm1.getUnits()); d_pm1.setUnits(DateUnits.Minutes); assertEquals(DateUnits.Minutes, d_pm1.getUnits()); assertEquals(3, d_pm1.getQuantity()); assertEquals(DatatypeFactory.newInstance().newDuration("PT3M"), d_epoch1.getDuration()); d_pm1.setUnits(DateUnits.Weeks); assertEquals(DateUnits.Weeks, d_pm1.getUnits()); assertEquals(3, d_pm1.getQuantity()); assertEquals(DatatypeFactory.newInstance().newDuration("P21D"), d_epoch1.getDuration()); d_epoch1.setDuration(DatatypeFactory.newInstance().newDuration("P28D")); assertEquals(DateUnits.Weeks, d_pm1.getUnits()); assertEquals(4, d_pm1.getQuantity()); d_pm1.setQuantity(14); d_pm1.setUnits(DateUnits.Days); assertEquals(DateUnits.Days, d_pm1.getUnits()); assertEquals(14, d_pm1.getQuantity()); assertEquals(DatatypeFactory.newInstance().newDuration("P14D"), d_epoch1.getDuration()); d_epoch1.setDuration(DatatypeFactory.newInstance().newDuration("P28D")); assertEquals(DateUnits.Days, d_pm1.getUnits()); assertEquals(28, d_pm1.getQuantity()); }