use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceIndexTest method testIndexSearchBusinessObjectDefinitionsWithMultipleTagsIncludeTagHierarchy.
@Test
public void testIndexSearchBusinessObjectDefinitionsWithMultipleTagsIncludeTagHierarchy() {
// Create new tag keys
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
TagKey tagKeyTwo = new TagKey(TAG_TYPE_2, TAG_CODE_2);
// 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 another new business object definition search key for use in the business object definition search key list
BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKeyTwo = new BusinessObjectDefinitionSearchKey(tagKeyTwo, INCLUDE_TAG_HIERARCHY);
// Create a new business object definition search key list with both the tag keys and the include tag hierarchy boolean flag
List<BusinessObjectDefinitionSearchKey> businessObjectDefinitionSearchKeyList = new ArrayList<>();
businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKey);
businessObjectDefinitionSearchKeyList.add(businessObjectDefinitionSearchKeyTwo);
// 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 entity to return from the tag dao helper get tag entity method
TagEntity tagEntityTwo = new TagEntity();
tagEntity.setTagCode(TAG_CODE_2);
// 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.getTagEntity(businessObjectDefinitionSearchKeyTwo.getTagKey())).thenReturn(tagEntityTwo);
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(searchIndexDaoHelper).getActiveSearchIndex(SEARCH_INDEX_TYPE_BDEF);
verify(configurationHelper).getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
verify(tagHelper).validateTagKey(businessObjectDefinitionSearchKey.getTagKey());
verify(tagHelper).validateTagKey(businessObjectDefinitionSearchKeyTwo.getTagKey());
verify(tagDaoHelper).getTagEntity(businessObjectDefinitionSearchKey.getTagKey());
verify(tagDaoHelper).getTagEntity(businessObjectDefinitionSearchKeyTwo.getTagKey());
verify(tagDaoHelper).getTagChildrenEntities(tagEntity);
verify(tagDaoHelper).getTagChildrenEntities(tagEntityTwo);
verify(businessObjectDefinitionIndexSearchDao).searchBusinessObjectDefinitionsByTags(any(), any(), any(), any());
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testGetBusinessObjectDefinitionTagsByTagMissingRequiredParameters.
@Test
public void testGetBusinessObjectDefinitionTagsByTagMissingRequiredParameters() {
// Try to get business object definition tags by tag when when tag type is not specified.
try {
businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByTag(new TagKey(BLANK_TEXT, TAG_CODE));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag type code must be specified.", e.getMessage());
}
// Try to get business object definition tags by tag when tag code is not specified.
try {
businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByTag(new TagKey(TAG_TYPE, BLANK_TEXT));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag code must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testCreateBusinessObjectDefinitionTagUpperCaseParameters.
@Test
public void testCreateBusinessObjectDefinitionTagUpperCaseParameters() {
// Create and persist a business object definition entity.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), DATA_PROVIDER_NAME, DESCRIPTION);
// Create and persist a tag entity.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION);
// Create a business object definition tag using upper case parameter values.
BusinessObjectDefinitionTag result = businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase()), new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE.toUpperCase()))));
// Validate the returned object.
assertEquals(new BusinessObjectDefinitionTag(result.getId(), new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE))), result);
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testCreateBusinessObjectDefinitionTag.
@Test
public void testCreateBusinessObjectDefinitionTag() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create a business object definition tag key.
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, new TagKey(TAG_TYPE, TAG_CODE));
// Create and persist a business object definition entity.
businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionKey, DATA_PROVIDER_NAME, DESCRIPTION);
// Create and persist a tag entity.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION);
// Create a business object definition tag.
BusinessObjectDefinitionTag result = businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(businessObjectDefinitionTagKey));
// Validate the returned object.
assertEquals(new BusinessObjectDefinitionTag(result.getId(), businessObjectDefinitionTagKey), result);
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testDeleteBusinessObjectDefinitionTagTrimParameters.
@Test
public void testDeleteBusinessObjectDefinitionTagTrimParameters() {
// Create a business object definition tag key.
BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
// Create and persist a business object definition tag entity.
BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
// Validate that this business object definition tag exists.
assertNotNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(businessObjectDefinitionTagKey));
// Delete this business object definition tag using input parameters with leading and trailing empty spaces.
BusinessObjectDefinitionTag result = businessObjectDefinitionTagService.deleteBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(addWhitespace(BDEF_NAMESPACE), addWhitespace(BDEF_NAME)), new TagKey(addWhitespace(TAG_TYPE), addWhitespace(TAG_CODE))));
// Validate the returned object.
assertEquals(new BusinessObjectDefinitionTag(businessObjectDefinitionTagEntity.getId(), businessObjectDefinitionTagKey), result);
// Ensure that this business object definition tag is no longer there.
assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(businessObjectDefinitionTagKey));
}
Aggregations