use of org.finra.herd.model.api.xml.BusinessObjectDataSearchKey in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectData.
@Test
public void testSearchBusinessObjectData() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
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);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
assertTrue(result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size() == 2);
for (BusinessObjectData data : result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements()) {
assertEquals(NAMESPACE, data.getNamespace());
assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
}
// 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(2), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(2), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchKey in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithAttributeFilterBadRequest.
@Test
public void testSearchBusinessObjectDataWithAttributeFilterBadRequest() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(NAMESPACE);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
// Try to search with a null attribute name and a null attribute value.
List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(null, null));
businessObjectDataSearchKey.setAttributeValueFilters(attributeValueFilters);
try {
businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Either attribute name or attribute value filter must be specified.", ex.getMessage());
}
// Try to search with an empty attribute name and a null attribute value.
attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(" ", null));
businessObjectDataSearchKey.setAttributeValueFilters(attributeValueFilters);
try {
businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Either attribute name or attribute value filter must be specified.", ex.getMessage());
}
// Try to search with an empty attribute name and empty attribute value.
attributeValueFilters = new ArrayList<>();
attributeValueFilters.add(new AttributeValueFilter(" ", ""));
businessObjectDataSearchKey.setAttributeValueFilters(attributeValueFilters);
try {
businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Either attribute name or attribute value filter must be specified.", ex.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchKey in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithPartitionFilterValues.
@Test
public void testSearchBusinessObjectDataWithPartitionFilterValues() {
businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
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<PartitionValueFilter> partitionValueFilters = new ArrayList<>();
PartitionValueFilter partitionValueFilter = new PartitionValueFilter();
partitionValueFilters.add(partitionValueFilter);
partitionValueFilter.setPartitionKey(PARTITION_KEY);
List<String> values = new ArrayList<>();
values.add(PARTITION_VALUE);
partitionValueFilter.setPartitionValues(values);
key.setPartitionValueFilters(partitionValueFilters);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
// The result list should be empty, as no schema column is registered.
assertEquals(0, result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size());
// Validate the paging information.
assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
assertEquals(Long.valueOf(0), result.getPageCount());
assertEquals(Long.valueOf(0), result.getTotalRecordsOnPage());
assertEquals(Long.valueOf(0), result.getTotalRecordCount());
assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchKey in project herd by FINRAOS.
the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithPartitionFilterBadRequest.
@Test
public void testSearchBusinessObjectDataWithPartitionFilterBadRequest() {
try {
businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter(Collections.singletonList(new BusinessObjectDataSearchKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, Collections.singletonList(new PartitionValueFilter(NO_PARTITION_KEY, NO_PARTITION_VALUES, NO_PARTITION_VALUE_RANGE, NO_LATEST_BEFORE_PARTITION_VALUE, NO_LATEST_AFTER_PARTITION_VALUE)), NO_ATTRIBUTE_VALUE_FILTERS, NO_FILTER_ON_LATEST_VALID_VERSION, NO_FILTER_ON_RETENTION_EXPIRATION))))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A partition key must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataSearchKey in project herd by FINRAOS.
the class BusinessObjectDataServiceTestHelper method createSimpleBusinessObjectDataSearchRequest.
/**
* Creates a simple business object data search request.
*
* @param namespace the namespace to search for
* @param bdefName the bdef name to search for
*
* @return the newly created business object data search request
*/
public BusinessObjectDataSearchRequest createSimpleBusinessObjectDataSearchRequest(final String namespace, final String bdefName) {
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
key.setNamespace(namespace);
key.setBusinessObjectDefinitionName(bdefName);
businessObjectDataSearchKeys.add(key);
BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
filters.add(filter);
request.setBusinessObjectDataSearchFilters(filters);
return request;
}
Aggregations