ParametersValidator { public static void checkAtLeastOneNotBlank(String errorMessage, String... values) throws ParametersException { for (String value : values) { if (StringUtils.isNotBlank(value)) { return; } } throw new ParametersException(errorMessage); } private  ParametersValidator(); static void checkRange(int value, int min, int max, String errorMessage); static void checkNotBlank(String value, String errorMessage); static void checkAtLeastOneNotBlank(String errorMessage, String... values); static void checkParameter(boolean expression, String errorMessage);  }
@Test public void testCheckAtLeastOneNotBlank_whenAtLeastOneInputNotEmpty_validationPassed() throws Exception { ParametersValidator.checkAtLeastOneNotBlank("Error", "param-a"); ParametersValidator.checkAtLeastOneNotBlank("Error", "", "param-b"); ParametersValidator.checkAtLeastOneNotBlank("Error", "", "", "param-c"); ParametersValidator.checkAtLeastOneNotBlank("Error", "", "param-b", ""); ParametersValidator.checkAtLeastOneNotBlank("Error", "param-a", "", ""); ParametersValidator.checkAtLeastOneNotBlank("Error", "param-a", "param-b", "param-c"); }
@Test(expected = ParametersException.class) public void testCheckAtLeastOneNotBlank_whenEmptyParameterArePassed_expectException() throws Exception { ParametersValidator.checkAtLeastOneNotBlank("Error", "", ""); }
@Test(expected = ParametersException.class) public void testCheckAtLeastOneNotBlank_whenNullParameterArePassed_expectException() throws Exception { ParametersValidator.checkAtLeastOneNotBlank("Error", null, ""); }