### Question:
RuleSelector extends Composite implements HasValueChangeHandlers<String>,
                   HasEnabled { public String getRuleName() { final String ruleName = ruleNameSelector.getValue(); if (!(ruleName == null || ruleName.equals(NONE_SELECTED))) { return ruleName; } else { return ""; } } RuleSelector(); void setRuleNames(final Collection<String> ruleNames,
                             final String exclude); void setRuleNames(final Collection<String> ruleNames); String getRuleName(); void setRuleName(final String ruleName); @Override HandlerRegistration addValueChangeHandler(final ValueChangeHandler<String> handler); @Override boolean isEnabled(); @Override void setEnabled(final boolean enabled); final static String NONE_SELECTED; }### Answer:
@Test public void checkGetRuleNameWhenNoneSelected() { when(ruleNameSelector.getValue()).thenReturn(RuleSelector.NONE_SELECTED); assertEquals("", ruleSelector.getRuleName()); }
@Test public void checkGetRuleNameWhenEmpty() { when(ruleNameSelector.getValue()).thenReturn(""); assertEquals("", ruleSelector.getRuleName()); }
@Test public void checkGetRuleNameWhenNotEmpty() { when(ruleNameSelector.getValue()).thenReturn("rule1"); assertEquals("rule1", ruleSelector.getRuleName()); }