### Question:
EllipseController { public void applyUnits() { List<String> units = New.list(); Collection<Class<? extends Length>> availableUnits = myUnitsRegistry.getAvailableUnits(Length.class, false); for (Class<? extends Length> lengthType : availableUnits) { String selectionLabel = Length.getSelectionLabel(lengthType); units.add(selectionLabel); } myModel.getAvailableUnits().addAll(units); if (StringUtils.isEmpty(myModel.getSemiMajorUnits()) || StringUtils.isEmpty(myModel.getSemiMinorUnits())) { String defaultUnit = Length.getSelectionLabel(myUnitsRegistry.getPreferredUnits(Length.class)); if (!units.contains(defaultUnit)) { defaultUnit = units.get(0); } if (StringUtils.isEmpty(myModel.getSemiMajorUnits())) { myModel.setSemiMajorUnits(defaultUnit); } if (StringUtils.isEmpty(myModel.getSemiMinorUnits())) { myModel.setSemiMinorUnits(defaultUnit); } } } EllipseController(UnitsRegistry unitsRegistry, EllipseModel model); void applyUnits();  }### Answer:
@Test public void test() { EasyMockSupport support = new EasyMockSupport(); UnitsRegistry unitRegistry = createRegistry(support, Feet.class); support.replayAll(); EllipseModel model = new EllipseModel(); EllipseController controller = new EllipseController(unitRegistry, model); controller.applyUnits(); assertEquals(New.list("nautical miles", "statute miles", "feet"), model.getAvailableUnits()); assertEquals("feet", model.getSemiMajorUnits()); assertEquals("feet", model.getSemiMinorUnits()); support.verifyAll(); }
@Test public void testAutoDefault() { EasyMockSupport support = new EasyMockSupport(); UnitsRegistry unitRegistry = createRegistry(support, AutoscaleImperial.class); support.replayAll(); EllipseModel model = new EllipseModel(); EllipseController controller = new EllipseController(unitRegistry, model); controller.applyUnits(); assertEquals(New.list("nautical miles", "statute miles", "feet"), model.getAvailableUnits()); assertEquals("nautical miles", model.getSemiMajorUnits()); assertEquals("nautical miles", model.getSemiMinorUnits()); support.verifyAll(); }