### Question:
TextPM extends AbstractValuePM implements ITextPM { public void setText(String aText) { if (aText == null) { aText = ""; } if (equals(text, aText)) { return; } String old = text; text = aText; revalidate(); updateModified(); getPropertyChangeSupport().firePropertyChange("text", old, text); } 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 setText() { TextPM pModel = new TextPM(); Counter l = new Counter(); pModel.addPropertyChangeListener(l); pModel.setText("hello, world!"); assertEquals("l.eventCount", 2, l.eventCount); pModel.setText("hello, moon!"); assertEquals("l.eventCount", 3, l.eventCount); pModel.setText("hello, moon!"); assertEquals("l.eventCount", 3, l.eventCount); }
@Test public void isValidWhenEmptyAndOptional() { TextPM pModel = new TextPM(); pModel.setMandatory(false); pModel.setText(null); assertEquals("pModel.isValid()", true, pModel.isValid()); pModel.getValidator().add(new ValidationRule() { public ValidationState validate() { return new ValidationState("baeh!"); } }); assertEquals("pModel.isValid()", true, pModel.isValid()); }