Search in sources :

Example 6 with BusinessObjectDataSearchFilter

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter 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());
    }
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) AttributeValueFilter(org.finra.herd.model.api.xml.AttributeValueFilter) Test(org.junit.Test)

Example 7 with BusinessObjectDataSearchFilter

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter 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());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 8 with BusinessObjectDataSearchFilter

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter 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());
    }
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) PartitionValueFilter(org.finra.herd.model.api.xml.PartitionValueFilter) Test(org.junit.Test)

Example 9 with BusinessObjectDataSearchFilter

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter 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;
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)

Example 10 with BusinessObjectDataSearchFilter

use of org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter in project herd by FINRAOS.

the class SearchBusinessObjectDataTest method getBusinessObjectDataSearchRequest.

private BusinessObjectDataSearchRequest getBusinessObjectDataSearchRequest() {
    BusinessObjectDataSearchRequest businessObjectDataSearchRequest = new BusinessObjectDataSearchRequest();
    List<BusinessObjectDataSearchFilter> businessObjectDataSearchFilters = new ArrayList<>();
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(NAMESPACE);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(BDEF_NAME);
    businessObjectDataSearchKey.setBusinessObjectFormatFileType(FORMAT_FILE_TYPE_CODE);
    businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
    BusinessObjectDataSearchFilter businessObjectDataSearchFilter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    businessObjectDataSearchFilters.add(businessObjectDataSearchFilter);
    businessObjectDataSearchRequest.setBusinessObjectDataSearchFilters(businessObjectDataSearchFilters);
    return businessObjectDataSearchRequest;
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)

Aggregations

BusinessObjectDataSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter)13 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)13 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)9 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)5 BusinessObjectDataSearchResultPagingInfoDto (org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto)5 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)4 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)2 HashMap (java.util.HashMap)1 BusinessObjectDataSearchResult (org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)1 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1