BusinessObjectDataSearchHelper { public Integer validatePagingParameter(String parameterName, Integer parameterValue, Integer defaultParameterValue, Integer maxParameterValue) { if (parameterValue == null) { parameterValue = defaultParameterValue; } else if (parameterValue < 1) { throw new IllegalArgumentException(String.format("A %s greater than 0 must be specified.", parameterName)); } else if (parameterValue > maxParameterValue) { throw new IllegalArgumentException(String.format("A %s less than %d must be specified.", parameterName, maxParameterValue)); } return parameterValue; }  void validateBusinessObjectDataSearchRequest(BusinessObjectDataSearchRequest businessObjectDataSearchRequest); Integer validatePagingParameter(String parameterName, Integer parameterValue, Integer defaultParameterValue, Integer maxParameterValue);  }
@Test public void testValidatePagingParameter() { assertEquals(INTEGER_VALUE, businessObjectDataSearchHelper.validatePagingParameter(PARAMETER_NAME, INTEGER_VALUE, null, Integer.MAX_VALUE)); assertEquals(INTEGER_VALUE_2, businessObjectDataSearchHelper.validatePagingParameter(PARAMETER_NAME, null, INTEGER_VALUE_2, Integer.MAX_VALUE)); try { businessObjectDataSearchHelper.validatePagingParameter(PARAMETER_NAME, 0, null, Integer.MAX_VALUE); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A %s greater than 0 must be specified.", PARAMETER_NAME), e.getMessage()); } try { businessObjectDataSearchHelper.validatePagingParameter(PARAMETER_NAME, Integer.MAX_VALUE, null, Integer.MAX_VALUE - 1); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A %s less than %d must be specified.", PARAMETER_NAME, Integer.MAX_VALUE - 1), e.getMessage()); } }