use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testCreateBusinessObjectDefinitionTagInvalidParameters.
@Test
public void testCreateBusinessObjectDefinitionTagInvalidParameters() {
// Try to create a business object definition tag when business object definition namespace contains a forward slash character.
try {
businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(addSlash(BDEF_NAMESPACE), BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition tag when business object definition name contains a forward slash character.
try {
businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, addSlash(BDEF_NAME)), new TagKey(TAG_TYPE, TAG_CODE))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition tag when business object definition namespace contains a forward slash character.
try {
businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(addSlash(TAG_TYPE), TAG_CODE))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Tag type code can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object definition tag when business object definition name contains a forward slash character.
try {
businessObjectDefinitionTagService.createBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagCreateRequest(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, addSlash(TAG_CODE)))));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Tag code can not contain a forward slash character.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagServiceTest method testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition.
@Test
public void testGetBusinessObjectDefinitionTagsByBusinessObjectDefinition() {
// Create a business object definition key.
BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
// Create tag keys.
List<TagKey> tagKeys = Arrays.asList(new TagKey(TAG_TYPE, TAG_CODE), new TagKey(TAG_TYPE_2, TAG_CODE_2));
// Create and persist business object definition tag entities.
for (TagKey tagKey : tagKeys) {
businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionKey, tagKey);
}
// Get business object definition tags by business object definition.
BusinessObjectDefinitionTagKeys result = businessObjectDefinitionTagService.getBusinessObjectDefinitionTagsByBusinessObjectDefinition(businessObjectDefinitionKey);
// Validate the returned object.
assertNotNull(result);
assertEquals(Arrays.asList(new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, tagKeys.get(0)), new BusinessObjectDefinitionTagKey(businessObjectDefinitionKey, tagKeys.get(1))), result.getBusinessObjectDefinitionTagKeys());
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class IndexSearchServiceTest method testIndexSearchInvalidIndexSearchKey.
@Test
public void testIndexSearchInvalidIndexSearchKey() {
// Create an index search key that contains both tag and result type keys.
final IndexSearchKey indexSearchKey = new IndexSearchKey(new TagKey(TAG_TYPE_CODE, TAG_CODE), new IndexSearchResultTypeKey(INDEX_SEARCH_RESULT_TYPE));
// Create an index search filter.
final IndexSearchFilter indexSearchFilter = new IndexSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Collections.singletonList(indexSearchKey));
// Create an index search request.
final IndexSearchRequest indexSearchRequest = new IndexSearchRequest(SEARCH_TERM, Collections.singletonList(indexSearchFilter), NO_INDEX_SEARCH_FACET_FIELDS, NO_ENABLE_HIT_HIGHLIGHTING);
// Create a set of fields.
final Set<String> fields = Sets.newHashSet(FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
// Try to call the method under test.
try {
indexSearchService.indexSearch(indexSearchRequest, fields, NO_MATCH);
fail();
} catch (IllegalArgumentException e) {
assertEquals("Exactly one instance of index search result type key or tag key must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class IndexSearchServiceTest method testIndexSearchWithResultTypeFilter.
@Test
public void testIndexSearchWithResultTypeFilter() {
// Create an index search key
final IndexSearchKey indexSearchKey = new IndexSearchKey();
// Create a tag key
final IndexSearchResultTypeKey resultTypeKey = new IndexSearchResultTypeKey(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
indexSearchKey.setIndexSearchResultTypeKey(resultTypeKey);
// Create an index search keys list and add the previously defined key to it
final List<IndexSearchKey> indexSearchKeys = Collections.singletonList(indexSearchKey);
// Create an index search filter with the keys previously defined
final IndexSearchFilter indexSearchFilter = new IndexSearchFilter(EXCLUSION_SEARCH_FILTER, indexSearchKeys);
List<IndexSearchFilter> indexSearchFilters = Collections.singletonList(indexSearchFilter);
// Create index search request
final IndexSearchRequest indexSearchRequest = new IndexSearchRequest(SEARCH_TERM, indexSearchFilters, null, false);
// Create a set of fields.
final Set<String> fields = Sets.newHashSet(FIELD_DISPLAY_NAME, FIELD_SHORT_DESCRIPTION);
// Create a new index search result key and populate it with a tag key
final IndexSearchResultKey indexSearchResultKeyBusinessObjectDefinition = new IndexSearchResultKey(null, new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME));
// Create a new index search result key and populate it with a tag key
final IndexSearchResultKey indexSearchResultKeyTag = new IndexSearchResultKey(new TagKey(TAG_TYPE, TAG_CODE), null);
// Create a new index search results
final IndexSearchResult indexSearchResultBusinessObjectDefinition = new IndexSearchResult(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name(), new SearchIndexKey(BUSINESS_OBJECT_DEFINITION_SEARCH_INDEX_NAME), indexSearchResultKeyBusinessObjectDefinition, BDEF_DISPLAY_NAME, BDEF_SHORT_DESCRIPTION, null);
final IndexSearchResult indexSearchResultTag = new IndexSearchResult(SearchIndexTypeEntity.SearchIndexTypes.TAG.name(), new SearchIndexKey(TAG_SEARCH_INDEX_NAME), indexSearchResultKeyTag, TAG_DISPLAY_NAME, TAG_DESCRIPTION, null);
// Create a list to contain the index search results
final List<IndexSearchResult> indexSearchResults = new ArrayList<>();
indexSearchResults.add(indexSearchResultBusinessObjectDefinition);
indexSearchResults.add(indexSearchResultTag);
// Construct an index search response
final IndexSearchResponse indexSearchResponse = new IndexSearchResponse(TOTAL_INDEX_SEARCH_RESULTS, indexSearchResults, null);
// Mock the call to the index search service
when(alternateKeyHelper.validateStringParameter("An", "index search result type", SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name())).thenReturn(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
when(searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name())).thenReturn(SEARCH_INDEX_NAME);
when(searchIndexDaoHelper.getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.TAG.name())).thenReturn(SEARCH_INDEX_NAME_2);
when(indexSearchDao.indexSearch(indexSearchRequest, fields, NO_MATCH, SEARCH_INDEX_NAME, SEARCH_INDEX_NAME_2)).thenReturn(indexSearchResponse);
// Call the method under test.
IndexSearchResponse result = indexSearchService.indexSearch(indexSearchRequest, fields, NO_MATCH);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("An", "index search result type", SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
verify(searchIndexTypeDaoHelper).getSearchIndexTypeEntity(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
verify(searchIndexDaoHelper).getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name());
verify(searchIndexDaoHelper).getActiveSearchIndex(SearchIndexTypeEntity.SearchIndexTypes.TAG.name());
verify(indexSearchDao).indexSearch(indexSearchRequest, fields, NO_MATCH, SEARCH_INDEX_NAME, SEARCH_INDEX_NAME_2);
verifyNoMoreInteractionsHelper();
// Validate the result.
assertEquals(indexSearchResponse, result);
}
use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class BusinessObjectDefinitionTagDaoTest method testGetBusinessObjectDefinitionTagsByTagEntities.
@Test
public void testGetBusinessObjectDefinitionTagsByTagEntities() {
// Create and persist two business object definition entities with display names in reverse order.
List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Arrays.asList(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME_2, NO_ATTRIBUTES), businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
// Create and persist three tag entities with display names in reverse order.
List<TagEntity> tagEntities = Arrays.asList(tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(TAG_TYPE_2, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION), tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_2, TAG_DISPLAY_NAME, TAG_DESCRIPTION));
// Create and persist two business object definition tag entities for the first two tag entities.
for (BusinessObjectDefinitionEntity businessObjectDefinitionEntity : businessObjectDefinitionEntities) {
for (TagEntity tagEntity : tagEntities.subList(0, 2)) {
businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(businessObjectDefinitionEntity, tagEntity);
}
}
// Get business object definition tags by the list of tag entities.
// Validate that the keys are ordered by business object definition display name and tag display name.
assertEquals(Arrays.asList(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE_2, BDEF_NAME_2), new TagKey(TAG_TYPE_2, TAG_CODE_2)), new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE_2, BDEF_NAME_2), new TagKey(TAG_TYPE, TAG_CODE)), new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE_2, TAG_CODE_2)), new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE))), businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagsByTagEntities(tagEntities));
// Try invalid values for all input parameters.
assertTrue(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagsByTagEntities(Arrays.asList(tagEntities.get(2))).isEmpty());
}
Aggregations