Search in sources :

Example 6 with BusinessObjectDataSearchKey

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

Example 7 with BusinessObjectDataSearchKey

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());
    }
}
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 8 with BusinessObjectDataSearchKey

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());
}
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 9 with BusinessObjectDataSearchKey

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());
    }
}
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 10 with BusinessObjectDataSearchKey

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;
}
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

BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)40 Test (org.junit.Test)35 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)28 ArrayList (java.util.ArrayList)21 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)15 BusinessObjectDataSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter)13 BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)12 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)11 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)8 BusinessObjectDataSearchResultPagingInfoDto (org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto)6 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)6 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)4 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)3 BusinessObjectDataSearchResult (org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)2 RetentionTypeEntity (org.finra.herd.model.jpa.RetentionTypeEntity)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 LatestBeforePartitionValue (org.finra.herd.model.api.xml.LatestBeforePartitionValue)1