### Question:
OptionsEnabledModel { public ValueHolder<Boolean> getEnabledModel(E option) { int idx = Collections.binarySearch(d_enabled, new Option<E>(option, false)); if (idx >= 0) { return d_enabled.get(idx).toggle; } return null; } OptionsEnabledModel(SelectableOptionsModel<E> selectModel, boolean listenToSelection); abstract boolean optionShouldBeEnabled(E option); void update(); ValueHolder<Boolean> getEnabledModel(E option);  }### Answer:
@Test public void testInit() { assertFalse(d_enabled.getEnabledModel("pick1").getValue()); assertTrue(d_enabled.getEnabledModel("pick2").getValue()); assertFalse(d_enabled.getEnabledModel("icepick").getValue()); assertNull(d_enabled.getEnabledModel("nonsense")); }
@Test public void testSync() { d_select.clear(); assertNull(d_enabled.getEnabledModel("pick1")); d_select.addOptions(Arrays.asList("nick", "jay-Z", "boyz2men"), false); assertNotNull(d_enabled.getEnabledModel("nick")); assertNotNull(d_enabled.getEnabledModel("jay-Z")); assertNotNull(d_enabled.getEnabledModel("boyz2men")); }
@Test public void testUpdateOnSelection() { d_enabled = new OptionsEnabledModel<String>(d_select, true) { public boolean optionShouldBeEnabled(String option) { return d_select.getSelectedOptions().size() < 2 || d_select.getSelectedModel(option).getValue(); } }; ValueHolder<Boolean> pick1Enabled = d_enabled.getEnabledModel("pick1"); ValueHolder<Boolean> pick2Enabled = d_enabled.getEnabledModel("pick2"); PropertyChangeListener listener1 = EasyMock.createStrictMock(PropertyChangeListener.class); PropertyChangeListener listener2 = EasyMock.createStrictMock(PropertyChangeListener.class); listener2.propertyChange(JUnitUtil.eqPropertyChangeEvent(new PropertyChangeEvent(pick2Enabled, "value", true, false))); EasyMock.replay(listener1, listener2); pick1Enabled.addValueChangeListener(listener1); pick2Enabled.addValueChangeListener(listener2); d_select.getSelectedModel("pick1").setValue(true); d_select.getSelectedModel("icepick").setValue(true); assertTrue(d_enabled.getEnabledModel("pick1").getValue()); assertFalse(d_enabled.getEnabledModel("pick2").getValue()); assertTrue(d_enabled.getEnabledModel("icepick").getValue()); assertNull(d_enabled.getEnabledModel("nonsense")); EasyMock.verify(listener1, listener2); }