@Test public void validatorIsNotEmpty() { when(singleProperty.getLogicalName()).thenReturn("my.property"); NotEmptyValidator<Object> validator = new NotEmptyValidator<>(); when(singleProperty.getValue()).thenReturn("Some string"); verifyZeroInteractions(propertyValidation); when(singleProperty.getValue()).thenReturn(""); validator.validate(singleProperty, propertyValidation); when(singleProperty.getValue()).thenReturn(Collections.emptyList()); validator.validate(singleProperty, propertyValidation); when(singleProperty.getValue()).thenReturn(Collections.emptyMap()); validator.validate(singleProperty, propertyValidation); verify(propertyValidation, times(3)).addValidationError(Matchers.<ValidationError> anyObject()); }
property1.addValidator(new NotEmptyValidator<String>()); section.addProperty(property1);