NonEmptyStringValidator implements IParameterValidator, IValueValidator<String> { @Override public void validate(@Nonnull String parameterName, @Nonnull String parameterValue) throws ParameterException { checkNotNull(parameterName, "parameterName"); checkNotNull(parameterValue, "parameterValue"); if (parameterValue.isEmpty()) { throw new ParameterException(format("Value of parameter {0} is the empty string.", parameterName)); } }  @Override void validate(@Nonnull String parameterName, @Nonnull String parameterValue);  }
@Test(expected = NullPointerException.class) public void givenNullParameterName_whenValidate_thenThrowsNullPointerException() { validator.validate(null, VALID_PARAMETER_VALUE); }
@Test(expected = NullPointerException.class) public void givenNullParameterValue_whenValidate_thenThrowsNullPointerException() { validator.validate(VALID_PARAMETER_NAME, null); }
@Test(expected = ParameterException.class) public void givenEmptyParameter_whenValidate_thenParameterException() { validator.validate(VALID_PARAMETER_NAME, ""); }
@Test public void givenNonEmptyParameter_whenValidate_thenNoExceptionThrown() { validator.validate(VALID_PARAMETER_NAME, "X"); }