### Question:
MergeValidator implements ChangeListener<String> { public ValidatorSupport getValidatorSupport() { return myValidatorSupport; } MergeValidator(DataGroupController groupController, MergeModel model); @Override void changed(ObservableValue<? extends String> observable, String oldValue, String newValue); ValidatorSupport getValidatorSupport();  }### Answer:
@Test public void testChangedDuplicate() { EasyMockSupport support = new EasyMockSupport(); DataGroupInfo dataGroup = support.createMock(DataGroupInfo.class); DataGroupController groupController = createGroupController(support, dataGroup); EasyMock.expect(groupController.getDataGroupInfo(EasyMock.cmpEq("New layer"))).andReturn(null); support.replayAll(); MergeModel model = new MergeModel(New.list()); model.getNewLayerName().set(ourLayerName); MergeValidator validator = new MergeValidator(groupController, model); assertEquals(ValidationStatus.ERROR, validator.getValidatorSupport().getValidationStatus()); assertEquals("Layer name already exists.", validator.getValidatorSupport().getValidationMessage()); model.getNewLayerName().set("New layer"); assertEquals(ValidationStatus.VALID, validator.getValidatorSupport().getValidationStatus()); assertNull(validator.getValidatorSupport().getValidationMessage()); support.verifyAll(); }
@Test public void testChangedEmpty() { EasyMockSupport support = new EasyMockSupport(); DataGroupController groupController = createGroupController(support, null); support.replayAll(); MergeModel model = new MergeModel(New.list()); model.getNewLayerName().set(ourLayerName); MergeValidator validator = new MergeValidator(groupController, model); assertEquals(ValidationStatus.VALID, validator.getValidatorSupport().getValidationStatus()); assertNull(validator.getValidatorSupport().getValidationMessage()); model.getNewLayerName().set(""); assertEquals(ValidationStatus.ERROR, validator.getValidatorSupport().getValidationStatus()); assertEquals("Please type in a new layer name.", validator.getValidatorSupport().getValidationMessage()); support.verifyAll(); }