Search in sources :

Example 1 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceImpl method validateBusinessObjectDefinitionSearchRequest.

/**
 * Validate the business object definition search request. This method also trims the request parameters.
 *
 * @param businessObjectDefinitionSearchRequest the business object definition search request
 */
private void validateBusinessObjectDefinitionSearchRequest(BusinessObjectDefinitionSearchRequest businessObjectDefinitionSearchRequest) {
    if (CollectionUtils.size(businessObjectDefinitionSearchRequest.getBusinessObjectDefinitionSearchFilters()) == 1 && businessObjectDefinitionSearchRequest.getBusinessObjectDefinitionSearchFilters().get(0) != null) {
        // Get the business object definition search filter.
        BusinessObjectDefinitionSearchFilter businessObjectDefinitionSearchFilter = businessObjectDefinitionSearchRequest.getBusinessObjectDefinitionSearchFilters().get(0);
        Assert.isTrue(CollectionUtils.size(businessObjectDefinitionSearchFilter.getBusinessObjectDefinitionSearchKeys()) == 1 && businessObjectDefinitionSearchFilter.getBusinessObjectDefinitionSearchKeys().get(0) != null, "Exactly one business object definition search key must be specified.");
        // Get the tag search key.
        BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = businessObjectDefinitionSearchFilter.getBusinessObjectDefinitionSearchKeys().get(0);
        tagHelper.validateTagKey(businessObjectDefinitionSearchKey.getTagKey());
    } else {
        Assert.isTrue(CollectionUtils.size(businessObjectDefinitionSearchRequest.getBusinessObjectDefinitionSearchFilters()) == 1 && businessObjectDefinitionSearchRequest.getBusinessObjectDefinitionSearchFilters().get(0) != null, "Exactly one business object definition search filter must be specified.");
    }
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)

Example 2 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionsOnlyShortDescription.

@Test
public void testSearchBusinessObjectDefinitionsOnlyShortDescription() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = new HashSet<>(setUpTestEntitiesForSearchTesting());
    // Remove fields which are not expected from the expected business object definition objects.
    for (BusinessObjectDefinition businessObjectDefinition : expectedBusinessObjectDefinitions) {
        businessObjectDefinition.setDisplayName(null);
        businessObjectDefinition.setDataProviderName(null);
    }
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_SHORT_DESCRIPTION));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertTrue(CollectionUtils.isEqualCollection(expectedBusinessObjectDefinitions, actualBusinessObjectDefinitions));
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) HashSet(java.util.HashSet) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) Test(org.junit.Test)

Example 3 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionInvalidParams.

@Test
public void testSearchBusinessObjectDefinitionInvalidParams() {
    // Try to search business object definition when empty search filter is specified.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter())), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition search key must be specified.", e.getMessage());
    }
    // Try to search business object definition when there are more than one business object definition search filter is specified.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(), new BusinessObjectDefinitionSearchFilter())), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition search filter must be specified.", e.getMessage());
    }
    // Try to search business object definition when there are more than one business object definition search key is specified.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(), new BusinessObjectDefinitionSearchKey())))), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Exactly one business object definition search key must be specified.", e.getMessage());
    }
    // Try to search business object definitions for a non-existing tag type.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey("I_DO_NOT_EXIST", "I_DO_NO_EXIST"), NOT_INCLUDE_TAG_HIERARCHY))))), NO_SEARCH_RESPONSE_FIELDS);
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals("Tag with code \"I_DO_NO_EXIST\" doesn't exist for tag type \"I_DO_NOT_EXIST\".", e.getMessage());
    }
    // Try to retrieve the actual business object definition objects using an un-supported search field.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet("I_DO_NOT_EXIST"));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Search response field \"i_do_not_exist\" is not supported.", e.getMessage());
    }
    // Try to retrieve the actual business object definition object using an un-supported search field in the mix of supported search fields.
    try {
        businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_DISPLAY_NAME, "I_DO_NOT_EXIST", FIELD_DATA_PROVIDER_NAME));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Search response field \"i_do_not_exist\" is not supported.", e.getMessage());
    }
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) Test(org.junit.Test)

Example 4 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionLowerCaseParams.

@Test
public void testSearchBusinessObjectDefinitionLowerCaseParams() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = setUpTestEntitiesForSearchTesting();
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_DATA_PROVIDER_NAME.toLowerCase(), FIELD_DISPLAY_NAME.toLowerCase(), FIELD_SHORT_DESCRIPTION.toLowerCase()));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(expectedBusinessObjectDefinitions, actualBusinessObjectDefinitions);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceTest method testBusinessObjectDefinitionNoHtmlInShortDescription.

@Test
public void testBusinessObjectDefinitionNoHtmlInShortDescription() {
    // Set up test data.
    setUpTestEntitiesForSearchTesting();
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE_4), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_SHORT_DESCRIPTION));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(1, actualBusinessObjectDefinitions.size());
    for (BusinessObjectDefinition actualBdef : actualBusinessObjectDefinitions) {
        assertEquals("Test Description. Value should be <30> value should be <40>", actualBdef.getShortDescription());
        break;
    }
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey)24 BusinessObjectDefinitionSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)23 TagKey (org.finra.herd.model.api.xml.TagKey)21 Test (org.junit.Test)21 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)15 BusinessObjectDefinitionSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest)13 BusinessObjectDefinitionSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)13 HashSet (java.util.HashSet)12 ArrayList (java.util.ArrayList)10 BusinessObjectDefinitionIndexSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchResponse)9 TagEntity (org.finra.herd.model.jpa.TagEntity)9 BusinessObjectDefinitionIndexSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchRequest)8 ElasticsearchResponseDto (org.finra.herd.model.dto.ElasticsearchResponseDto)8 BusinessObjectDefinitionIndexSearchResponseDto (org.finra.herd.model.dto.BusinessObjectDefinitionIndexSearchResponseDto)6 DataProvider (org.finra.herd.model.dto.DataProvider)5 Namespace (org.finra.herd.model.dto.Namespace)5 Facet (org.finra.herd.model.api.xml.Facet)2 TagIndexSearchResponseDto (org.finra.herd.model.dto.TagIndexSearchResponseDto)2 TagTypeIndexSearchResponseDto (org.finra.herd.model.dto.TagTypeIndexSearchResponseDto)2 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)2