use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter in project herd by FINRAOS.
the class BusinessObjectDataSearchHelperTest method testValidateBusinessObjectDataSearchRequestIllegalArgumentExceptions.
@Test
public void testValidateBusinessObjectDataSearchRequestIllegalArgumentExceptions() {
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(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())));
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());
}
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());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithAttributeFilterValuesWithMixedCaseAndSpace.
@Test
public void testSearchBusinessObjectDataWithAttributeFilterValuesWithMixedCaseAndSpace() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
key.setNamespace(NAMESPACE);
key.setBusinessObjectDefinitionName(BDEF_NAME);
List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(" " + ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase() + " ", ATTRIBUTE_VALUE_1));
key.setAttributeValueFilters(attributeValueFilters);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
List<BusinessObjectData> resultList = result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements();
assertEquals(1, resultList.size());
for (BusinessObjectData data : resultList) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(ATTRIBUTE_NAME_1_MIXED_CASE, data.getAttributes().get(0).getName());
assertEquals(ATTRIBUTE_VALUE_1, data.getAttributes().get(0).getValue());
}
// Validate the paging information.
assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
assertEquals(Long.valueOf(1), result.getPageCount());
assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(1), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithAttributeFilterValues.
@Test
public void testSearchBusinessObjectDataWithAttributeFilterValues() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
key.setNamespace(NAMESPACE);
key.setBusinessObjectDefinitionName(BDEF_NAME);
List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1));
key.setAttributeValueFilters(attributeValueFilters);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
List<BusinessObjectData> resultList = result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements();
assertEquals(1, resultList.size());
for (BusinessObjectData data : resultList) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
assertEquals(ATTRIBUTE_NAME_1_MIXED_CASE, data.getAttributes().get(0).getName());
assertEquals(ATTRIBUTE_VALUE_1, data.getAttributes().get(0).getValue());
}
// Validate the paging information.
assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
assertEquals(Long.valueOf(1), result.getPageCount());
assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(1), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
Aggregations