BusinessObjectDataSearchHelper { public void validateBusinessObjectDataSearchRequest(BusinessObjectDataSearchRequest businessObjectDataSearchRequest) { Assert.notNull(businessObjectDataSearchRequest, "A business object data search request must be specified."); List<BusinessObjectDataSearchFilter> businessObjectDataSearchFilters = businessObjectDataSearchRequest.getBusinessObjectDataSearchFilters(); Assert.isTrue(CollectionUtils.isNotEmpty(businessObjectDataSearchFilters), "A business object data search filter must be specified."); Assert.isTrue(businessObjectDataSearchFilters.size() == 1, "A list of business object data search filters can only have one element."); BusinessObjectDataSearchFilter businessObjectDataSearchFilter = businessObjectDataSearchFilters.get(0); List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = businessObjectDataSearchFilter.getBusinessObjectDataSearchKeys(); Assert.isTrue(CollectionUtils.isNotEmpty(businessObjectDataSearchKeys), "A business object data search key must be specified."); Assert.isTrue(businessObjectDataSearchKeys.size() == 1, "A list of business object data search keys can only have one element."); validateBusinessObjectDataSearchKey(businessObjectDataSearchKeys.get(0)); }  void validateBusinessObjectDataSearchRequest(BusinessObjectDataSearchRequest businessObjectDataSearchRequest); Integer validatePagingParameter(String parameterName, Integer parameterValue, Integer defaultParameterValue, Integer maxParameterValue);  }
@Test public void testValidateBusinessObjectDataSearchRequestInvalidValues() { try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest( new BusinessObjectDataSearchRequest(Arrays.asList(new BusinessObjectDataSearchFilter(), new BusinessObjectDataSearchFilter()))); fail(); } catch (IllegalArgumentException e) { assertEquals("A list of business object data search filters can only have one element.", e.getMessage()); } try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Collections .singletonList(new BusinessObjectDataSearchFilter(Arrays.asList(new BusinessObjectDataSearchKey(), new BusinessObjectDataSearchKey()))))); fail(); } catch (IllegalArgumentException e) { assertEquals("A list of business object data search keys can only have one element.", e.getMessage()); } }
@Test public void testValidateBusinessObjectDataSearchRequestMissingRequiredParameters() { try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(null); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data search request must be specified.", e.getMessage()); } try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest()); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data search filter must be specified.", e.getMessage()); } try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(new ArrayList<>())); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data search filter must be specified.", e.getMessage()); } try { businessObjectDataSearchHelper .validateBusinessObjectDataSearchRequest(new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter()))); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data search key must be specified.", e.getMessage()); } try { businessObjectDataSearchHelper.validateBusinessObjectDataSearchRequest( new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter(new ArrayList<>())))); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data search key must be specified.", e.getMessage()); } }