Search in sources :

Example 11 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceIndexTest method testIndexSearchBusinessObjectDefinitionWithFacetsReturnsEmptyResponseForEmptyTagEntities.

@Test
public void testIndexSearchBusinessObjectDefinitionWithFacetsReturnsEmptyResponseForEmptyTagEntities() {
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create a tag entity.
    TagEntity tagEntity = new TagEntity();
    // Create  a new business object definition search key for use in the business object definition search key list with an empty tag key
    BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = new BusinessObjectDefinitionSearchKey(tagKey, NOT_INCLUDE_TAG_HIERARCHY);
    // Create a new business object definition search key list with the tag key and the include tag hierarchy boolean flag
    List<BusinessObjectDefinitionSearchKey> businessObjectDefinitionSearchKeyList = new ArrayList<>();
    businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKey);
    // Create a new business object definition search filter list with the new business object definition search key list
    List<BusinessObjectDefinitionSearchFilter> businessObjectDefinitionSearchFilterList = new ArrayList<>();
    businessObjectDefinitionSearchFilterList.add(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, businessObjectDefinitionSearchKeyList));
    // Create a new business object definition search request that will be used when testing the index search business object definitions method
    BusinessObjectDefinitionIndexSearchRequest businessObjectDefinitionIndexSearchRequest = new BusinessObjectDefinitionIndexSearchRequest(businessObjectDefinitionSearchFilterList, Collections.singletonList("TAG"));
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class)).thenReturn(SHORT_DESCRIPTION_LENGTH);
    when(searchIndexDaoHelper.getActiveSearchIndex(SEARCH_INDEX_TYPE_BDEF)).thenReturn(SEARCH_INDEX_NAME);
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn(SEARCH_INDEX_DOCUMENT_TYPE);
    when(tagDaoHelper.getTagEntity(tagKey)).thenReturn(tagEntity);
    when(businessObjectDefinitionIndexSearchDao.searchBusinessObjectDefinitionsByTags(any(), any(), any(), any())).thenReturn(new ElasticsearchResponseDto());
    // Call the method under test
    BusinessObjectDefinitionIndexSearchResponse businessObjectDefinitionSearchResponse = businessObjectDefinitionService.indexSearchBusinessObjectDefinitions(businessObjectDefinitionIndexSearchRequest, new HashSet<>());
    assertThat("Expected empty response", CollectionUtils.isEmpty(businessObjectDefinitionSearchResponse.getBusinessObjectDefinitions()));
    // Verify the calls to external methods
    verify(searchIndexDaoHelper).getActiveSearchIndex(SEARCH_INDEX_TYPE_BDEF);
    verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagHelper).validateTagKey(tagKey);
    verify(tagDaoHelper).getTagEntity(tagKey);
    verify(businessObjectDefinitionIndexSearchDao).searchBusinessObjectDefinitionsByTags(any(), any(), any(), any());
    verifyNoMoreInteractionsHelper();
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) ArrayList(java.util.ArrayList) BusinessObjectDefinitionIndexSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchRequest) ElasticsearchResponseDto(org.finra.herd.model.dto.ElasticsearchResponseDto) BusinessObjectDefinitionIndexSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchResponse) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) Test(org.junit.Test)

Example 12 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceIndexTest method testIndexSearchBusinessObjectDefinitionsDoNotIncludeTagHierarchy.

@Test
public void testIndexSearchBusinessObjectDefinitionsDoNotIncludeTagHierarchy() {
    // Create a new tag key with a tag type and a tag code
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create  a new business object definition search key for use in the business object definition search key list
    BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = new BusinessObjectDefinitionSearchKey(tagKey, NOT_INCLUDE_TAG_HIERARCHY);
    // Create a new business object definition search key list with the tag key and the include tag hierarchy boolean flag
    List<BusinessObjectDefinitionSearchKey> businessObjectDefinitionSearchKeyList = new ArrayList<>();
    businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKey);
    // Create a new business object definition search filter list with the new business object definition search key list
    List<BusinessObjectDefinitionSearchFilter> businessObjectDefinitionSearchFilterList = new ArrayList<>();
    businessObjectDefinitionSearchFilterList.add(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, businessObjectDefinitionSearchKeyList));
    // Create a new business object definition search request that will be used when testing the index search business object definitions method
    BusinessObjectDefinitionIndexSearchRequest businessObjectDefinitionIndexSearchRequest = new BusinessObjectDefinitionIndexSearchRequest(businessObjectDefinitionSearchFilterList, new ArrayList<>());
    // Create a new fields set that will be used when testing the index search business object definitions method
    Set<String> fields = Sets.newHashSet(FIELD_DATA_PROVIDER_NAME, FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
    // Create a tag entity to return from the tag dao helper get tag entity method
    TagEntity tagEntity = new TagEntity();
    tagEntity.setTagCode(TAG_CODE);
    List<BusinessObjectDefinitionIndexSearchResponseDto> businessObjectDefinitionIndexSearchResponseDtoList = new ArrayList<>();
    BusinessObjectDefinitionIndexSearchResponseDto businessObjectDefinitionIndexSearchResponseDto1 = new BusinessObjectDefinitionIndexSearchResponseDto(new DataProvider(DATA_PROVIDER_NAME), BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, BDEF_NAME, new Namespace(NAMESPACE));
    BusinessObjectDefinitionIndexSearchResponseDto businessObjectDefinitionIndexSearchResponseDto2 = new BusinessObjectDefinitionIndexSearchResponseDto(new DataProvider(DATA_PROVIDER_NAME_2), BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, BDEF_NAME_2, new Namespace(NAMESPACE));
    businessObjectDefinitionIndexSearchResponseDtoList.add(businessObjectDefinitionIndexSearchResponseDto1);
    businessObjectDefinitionIndexSearchResponseDtoList.add(businessObjectDefinitionIndexSearchResponseDto2);
    ElasticsearchResponseDto elasticsearchResponseDto = new ElasticsearchResponseDto();
    elasticsearchResponseDto.setBusinessObjectDefinitionIndexSearchResponseDtos(businessObjectDefinitionIndexSearchResponseDtoList);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class)).thenReturn(SHORT_DESCRIPTION_LENGTH);
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn(SEARCH_INDEX_DOCUMENT_TYPE);
    when(tagDaoHelper.getTagEntity(businessObjectDefinitionSearchKey.getTagKey())).thenReturn(tagEntity);
    when(businessObjectDefinitionIndexSearchDao.searchBusinessObjectDefinitionsByTags(any(), any(), any(), any())).thenReturn(elasticsearchResponseDto);
    // Call the method under test
    BusinessObjectDefinitionIndexSearchResponse businessObjectDefinitionSearchResponse = businessObjectDefinitionService.indexSearchBusinessObjectDefinitions(businessObjectDefinitionIndexSearchRequest, fields);
    assertThat("Business object definition service index search business object definitions method response is null, but it should not be.", businessObjectDefinitionSearchResponse, not(nullValue()));
    assertThat("The first business object definition name in the search response is not correct.", businessObjectDefinitionSearchResponse.getBusinessObjectDefinitions().get(0).getBusinessObjectDefinitionName(), is(BDEF_NAME));
    assertThat("The second business object definition name in the search response is not correct.", businessObjectDefinitionSearchResponse.getBusinessObjectDefinitions().get(1).getBusinessObjectDefinitionName(), is(BDEF_NAME_2));
    // Verify the calls to external methods
    verify(configurationHelper, times(2)).getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class);
    verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(tagHelper).validateTagKey(tagKey);
    verify(tagDaoHelper).getTagEntity(businessObjectDefinitionSearchKey.getTagKey());
    verify(businessObjectDefinitionIndexSearchDao).searchBusinessObjectDefinitionsByTags(any(), any(), any(), any());
    verifyNoMoreInteractionsHelper();
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) ArrayList(java.util.ArrayList) BusinessObjectDefinitionIndexSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) Namespace(org.finra.herd.model.dto.Namespace) DataProvider(org.finra.herd.model.dto.DataProvider) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionIndexSearchResponseDto(org.finra.herd.model.dto.BusinessObjectDefinitionIndexSearchResponseDto) TagKey(org.finra.herd.model.api.xml.TagKey) ElasticsearchResponseDto(org.finra.herd.model.dto.ElasticsearchResponseDto) BusinessObjectDefinitionIndexSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchResponse) Test(org.junit.Test)

Example 13 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceIndexTest method testIndexSearchBusinessObjectDefinitionsIncludeTagHierarchy.

@Test
public void testIndexSearchBusinessObjectDefinitionsIncludeTagHierarchy() {
    // Create a new tag key with a tag type and a tag code
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create  a new business object definition search key for use in the business object definition search key list
    BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = new BusinessObjectDefinitionSearchKey(tagKey, INCLUDE_TAG_HIERARCHY);
    // Create a new business object definition search key list with the tag key and the include tag hierarchy boolean flag
    List<BusinessObjectDefinitionSearchKey> businessObjectDefinitionSearchKeyList = new ArrayList<>();
    businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKey);
    // Create a new business object definition search filter list with the new business object definition search key list
    List<BusinessObjectDefinitionSearchFilter> businessObjectDefinitionSearchFilterList = new ArrayList<>();
    businessObjectDefinitionSearchFilterList.add(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, businessObjectDefinitionSearchKeyList));
    // Create a new business object definition search request that will be used when testing the index search business object definitions method
    BusinessObjectDefinitionIndexSearchRequest businessObjectDefinitionIndexSearchRequest = new BusinessObjectDefinitionIndexSearchRequest(businessObjectDefinitionSearchFilterList, new ArrayList<>());
    // Create a new fields set that will be used when testing the index search business object definitions method
    Set<String> fields = Sets.newHashSet(FIELD_DATA_PROVIDER_NAME, FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
    // Create a tag entity to return from the tag dao helper get tag entity method
    TagEntity tagEntity = new TagEntity();
    tagEntity.setTagCode(TAG_CODE);
    // Create a tag child entity to enter into the tag children entities list
    TagEntity tagChildEntity = new TagEntity();
    tagChildEntity.setTagCode(TAG_CODE_2);
    // Create a tag children entity list to return from the tag dao helper tag children entities method
    List<TagEntity> tagChildrenEntityList = new ArrayList<>();
    tagChildrenEntityList.add(tagChildEntity);
    List<BusinessObjectDefinitionIndexSearchResponseDto> businessObjectDefinitionIndexSearchResponseDtoList = new ArrayList<>();
    BusinessObjectDefinitionIndexSearchResponseDto businessObjectDefinitionIndexSearchResponseDto1 = new BusinessObjectDefinitionIndexSearchResponseDto(new DataProvider(DATA_PROVIDER_NAME), BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, BDEF_NAME, new Namespace(NAMESPACE));
    BusinessObjectDefinitionIndexSearchResponseDto businessObjectDefinitionIndexSearchResponseDto2 = new BusinessObjectDefinitionIndexSearchResponseDto(new DataProvider(DATA_PROVIDER_NAME_2), BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, BDEF_NAME_2, new Namespace(NAMESPACE));
    businessObjectDefinitionIndexSearchResponseDtoList.add(businessObjectDefinitionIndexSearchResponseDto1);
    businessObjectDefinitionIndexSearchResponseDtoList.add(businessObjectDefinitionIndexSearchResponseDto2);
    ElasticsearchResponseDto elasticsearchResponseDto = new ElasticsearchResponseDto();
    elasticsearchResponseDto.setBusinessObjectDefinitionIndexSearchResponseDtos(businessObjectDefinitionIndexSearchResponseDtoList);
    // Mock the call to external methods
    when(configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class)).thenReturn(SHORT_DESCRIPTION_LENGTH);
    when(searchIndexDaoHelper.getActiveSearchIndex(SEARCH_INDEX_TYPE_BDEF)).thenReturn(SEARCH_INDEX_NAME);
    when(configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class)).thenReturn(SEARCH_INDEX_DOCUMENT_TYPE);
    when(tagDaoHelper.getTagEntity(businessObjectDefinitionSearchKey.getTagKey())).thenReturn(tagEntity);
    when(tagDaoHelper.getTagChildrenEntities(tagEntity)).thenReturn(tagChildrenEntityList);
    when(businessObjectDefinitionIndexSearchDao.searchBusinessObjectDefinitionsByTags(any(), any(), any(), any())).thenReturn(elasticsearchResponseDto);
    // Call the method under test
    BusinessObjectDefinitionIndexSearchResponse businessObjectDefinitionSearchResponse = businessObjectDefinitionService.indexSearchBusinessObjectDefinitions(businessObjectDefinitionIndexSearchRequest, fields);
    assertThat("Business object definition service index search business object definitions method response is null, but it should not be.", businessObjectDefinitionSearchResponse, not(nullValue()));
    assertThat("The first business object definition name in the search response is not correct.", businessObjectDefinitionSearchResponse.getBusinessObjectDefinitions().get(0).getBusinessObjectDefinitionName(), is(BDEF_NAME));
    assertThat("The second business object definition name in the search response is not correct.", businessObjectDefinitionSearchResponse.getBusinessObjectDefinitions().get(1).getBusinessObjectDefinitionName(), is(BDEF_NAME_2));
    // Verify the calls to external methods
    verify(configurationHelper, times(2)).getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class);
    verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    verify(searchIndexDaoHelper).getActiveSearchIndex(SEARCH_INDEX_TYPE_BDEF);
    verify(tagHelper).validateTagKey(tagKey);
    verify(tagDaoHelper).getTagEntity(businessObjectDefinitionSearchKey.getTagKey());
    verify(tagDaoHelper).getTagChildrenEntities(tagEntity);
    verify(businessObjectDefinitionIndexSearchDao).searchBusinessObjectDefinitionsByTags(any(), any(), any(), any());
    verifyNoMoreInteractionsHelper();
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) ArrayList(java.util.ArrayList) BusinessObjectDefinitionIndexSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) Namespace(org.finra.herd.model.dto.Namespace) DataProvider(org.finra.herd.model.dto.DataProvider) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionIndexSearchResponseDto(org.finra.herd.model.dto.BusinessObjectDefinitionIndexSearchResponseDto) TagKey(org.finra.herd.model.api.xml.TagKey) ElasticsearchResponseDto(org.finra.herd.model.dto.ElasticsearchResponseDto) BusinessObjectDefinitionIndexSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchResponse) Test(org.junit.Test)

Example 14 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionRestControllerIndexTest method testIndexSearchBusinessObjectDefinitions.

@Test
public void testIndexSearchBusinessObjectDefinitions() {
    // Create a new tag key with a tag type and a tag code
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create  a new business object definition search key for use in the business object definition search key list
    BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = new BusinessObjectDefinitionSearchKey(tagKey, INCLUDE_TAG_HIERARCHY);
    // Create a new business object definition search key list with the tag key and the include tag hierarchy boolean flag
    List<BusinessObjectDefinitionSearchKey> businessObjectDefinitionSearchKeyList = new ArrayList<>();
    businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKey);
    // Create a new business object definition search filter list with the new business object definition search key list
    List<BusinessObjectDefinitionSearchFilter> businessObjectDefinitionSearchFilterList = new ArrayList<>();
    businessObjectDefinitionSearchFilterList.add(new BusinessObjectDefinitionSearchFilter(false, businessObjectDefinitionSearchKeyList));
    // Create a list of facet fields
    List<String> facetFields = new ArrayList<>();
    facetFields.add("Invalid");
    // Create a new business object definition search request that will be used when testing the index search business object definitions method
    BusinessObjectDefinitionIndexSearchRequest businessObjectDefinitionSearchRequest = new BusinessObjectDefinitionIndexSearchRequest(businessObjectDefinitionSearchFilterList, facetFields);
    // Create a new fields set that will be used when testing the index search business object definitions method
    Set<String> fields = Sets.newHashSet(FIELD_DATA_PROVIDER_NAME, FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
    // Create a business object definition entity list to return from the search business object definitions by tags function
    List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntityList = new ArrayList<>();
    businessObjectDefinitionEntityList.add(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes()));
    businessObjectDefinitionEntityList.add(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes()));
    // Create a list to hold the business object definitions that will be returned as part of the search response
    List<BusinessObjectDefinition> businessObjectDefinitions = new ArrayList<>();
    // Retrieve all unique business object definition entities and construct a list of business object definitions based on the requested fields.
    for (BusinessObjectDefinitionEntity businessObjectDefinitionEntity : ImmutableSet.copyOf(businessObjectDefinitionEntityList)) {
        // Convert the business object definition entity to a business object definition and add it to the list of business object definitions that will be
        // returned as a part of the search response
        BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition();
        // Populate the business object definition
        businessObjectDefinition.setNamespace(businessObjectDefinitionEntity.getNamespace().getCode());
        businessObjectDefinition.setBusinessObjectDefinitionName(businessObjectDefinitionEntity.getName());
        businessObjectDefinition.setDataProviderName(businessObjectDefinitionEntity.getDataProvider().getName());
        businessObjectDefinition.setShortDescription(StringUtils.left(businessObjectDefinitionEntity.getDescription(), SHORT_DESCRIPTION_LENGTH));
        businessObjectDefinition.setDisplayName(businessObjectDefinitionEntity.getDisplayName());
        businessObjectDefinitions.add(businessObjectDefinition);
    }
    List<TagTypeIndexSearchResponseDto> tagTypeIndexSearchResponseDtos = new ArrayList<>();
    List<TagIndexSearchResponseDto> tagIndexSearchResponseDtos = new ArrayList<>();
    tagIndexSearchResponseDtos.add(new TagIndexSearchResponseDto(TAG_CODE, TAG_COUNT, TAG_DISPLAY_NAME));
    tagIndexSearchResponseDtos.add(new TagIndexSearchResponseDto(TAG_CODE_2, TAG_COUNT, TAG_DISPLAY_NAME_2));
    TagTypeIndexSearchResponseDto tagTypeIndexSearchResponseDto = new TagTypeIndexSearchResponseDto(TAG_TYPE, tagIndexSearchResponseDtos, TAG_TYPE_DISPLAY_NAME);
    tagTypeIndexSearchResponseDtos.add(tagTypeIndexSearchResponseDto);
    List<Facet> tagTypeFacets = new ArrayList<>();
    for (TagTypeIndexSearchResponseDto tagTypeIndexSearchResponse : ImmutableSet.copyOf(tagTypeIndexSearchResponseDtos)) {
        List<Facet> tagFacets = new ArrayList<>();
        for (TagIndexSearchResponseDto tagIndexSearchResponseDto : tagTypeIndexSearchResponse.getTagIndexSearchResponseDtos()) {
            Facet tagFacet = new Facet(tagIndexSearchResponseDto.getTagDisplayName(), tagIndexSearchResponseDto.getCount(), FacetTypeEnum.TAG.value(), tagIndexSearchResponseDto.getTagCode(), null);
            tagFacets.add(tagFacet);
        }
        tagTypeFacets.add(new Facet(tagTypeIndexSearchResponse.getDisplayName(), null, FacetTypeEnum.TAG_TYPE.value(), tagTypeIndexSearchResponse.getCode(), tagFacets));
    }
    // Construct business object search response.
    BusinessObjectDefinitionIndexSearchResponse businessObjectDefinitionSearchResponse = new BusinessObjectDefinitionIndexSearchResponse();
    businessObjectDefinitionSearchResponse.setBusinessObjectDefinitions(businessObjectDefinitions);
    businessObjectDefinitionSearchResponse.setFacets(tagTypeFacets);
    // Mock the call to the business object definition service
    when(businessObjectDefinitionService.indexSearchBusinessObjectDefinitions(businessObjectDefinitionSearchRequest, fields)).thenReturn(businessObjectDefinitionSearchResponse);
    // Create a business object definition.
    BusinessObjectDefinitionIndexSearchResponse businessObjectDefinitionSearchResponseFromRestCall = businessObjectDefinitionRestController.indexSearchBusinessObjectDefinitions(fields, businessObjectDefinitionSearchRequest);
    // Verify the method call to businessObjectDefinitionService.indexAllBusinessObjectDefinitions()
    verify(businessObjectDefinitionService, times(1)).indexSearchBusinessObjectDefinitions(businessObjectDefinitionSearchRequest, fields);
    // Validate the returned object.
    assertThat("Business object definition index search response was null.", businessObjectDefinitionSearchResponseFromRestCall, not(nullValue()));
    assertThat("Business object definition index search response was not correct.", businessObjectDefinitionSearchResponseFromRestCall, is(businessObjectDefinitionSearchResponse));
    assertThat("Business object definition index search response was not an instance of BusinessObjectDefinitionSearchResponse.class.", businessObjectDefinitionSearchResponseFromRestCall, instanceOf(BusinessObjectDefinitionIndexSearchResponse.class));
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) TagIndexSearchResponseDto(org.finra.herd.model.dto.TagIndexSearchResponseDto) ArrayList(java.util.ArrayList) BusinessObjectDefinitionIndexSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) TagKey(org.finra.herd.model.api.xml.TagKey) TagTypeIndexSearchResponseDto(org.finra.herd.model.dto.TagTypeIndexSearchResponseDto) BusinessObjectDefinitionIndexSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionIndexSearchResponse) Facet(org.finra.herd.model.api.xml.Facet) Test(org.junit.Test)

Example 15 with BusinessObjectDefinitionSearchKey

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

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionsOnlyShortDescriptionAndDisplayName.

@Test
public void testSearchBusinessObjectDefinitionsOnlyShortDescriptionAndDisplayName() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = setUpTestEntitiesForSearchTesting();
    // Remove fields which are not expected from the expected business object definition objects.
    for (BusinessObjectDefinition businessObjectDefinition : expectedBusinessObjectDefinitions) {
        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, FIELD_DISPLAY_NAME));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(actualBusinessObjectDefinitions, expectedBusinessObjectDefinitions);
}
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)

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