### Question:
TextPM extends AbstractValuePM implements ITextPM { public void setOptions(Options newOptions) { if (options == newOptions) { return; } Options old = options; if (options != null) { options.removeOptionsListener(optionsListener); } options = newOptions; if (options != null) { options.addOptionsListener(optionsListener); } revalidate(); getPropertyChangeSupport().firePropertyChange("options", old, options); } TextPM(String initialText);  TextPM(); String getText(); String getText(boolean convertWhitespaceStringToNull); void setText(String aText); boolean isRestrictedToOptions(); void setRestrictedToOptions(boolean restrictedToOptions); boolean isEmpty(); boolean isModified(); void reset(); void preset(); void reformat(); Options getOptions(); void setOptions(Options newOptions); @Override Comparable<?> getComparable();  }### Answer:
@Test public void setOptions() { ITextPM pModel = new TextPM(); Options<Integer> opt = new Options<Integer>(); opt.put(1, "one"); opt.put(2, "two"); opt.put(3, "three"); Counter counter = new Counter(); pModel.addPropertyChangeListener(counter); pModel.setOptions(opt); assertEquals("eventCount", 1, counter.eventCount); opt.put(4, "four"); assertEquals("eventCount", 2, counter.eventCount); }
@Test public void removeOptions() { ITextPM pModel = new TextPM(); Options<Integer> opt = new Options<Integer>(); pModel.setOptions(opt); Counter counter = new Counter(); pModel.addPropertyChangeListener(counter); assertEquals("counter.eventCount", 0, counter.eventCount); pModel.setOptions(null); assertEquals("counter.eventCount", 1, counter.eventCount); opt.put(1, "one"); assertEquals("counter.eventCount", 1, counter.eventCount); }