use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagServiceTest method testCreateTag.
@Test
public void testCreateTag() {
// Create and persist a tag type entity.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create a tag key.
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
// Create a tag.
Tag tag = tagService.createTag(new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
// Get the tag entity.
TagEntity tagEntity = tagDao.getTagByKey(tagKey);
assertNotNull(tagEntity);
// Validate the response object.
assertEquals(new Tag(tagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), tag);
}
use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagServiceTest method testSearchTagsLowerCaseParameters.
@Test
public void testSearchTagsLowerCaseParameters() {
// Create and persist database entities required for testing.
createDatabaseEntitiesForTagSearchTesting();
// Search the tags using lower case input parameters.
TagSearchResponse tagSearchResponse = tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase(), NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.DISPLAY_NAME_FIELD.toLowerCase(), TagServiceImpl.SEARCH_SCORE_MULTIPLIER_FIELD.toLowerCase(), TagServiceImpl.DESCRIPTION_FIELD.toLowerCase(), TagServiceImpl.PARENT_TAG_KEY_FIELD.toLowerCase(), TagServiceImpl.HAS_CHILDREN_FIELD.toLowerCase()));
// Validate the returned object.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, new TagKey(TAG_TYPE, TAG_CODE), TAG_HAS_NO_CHILDREN), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, new TagKey(TAG_TYPE, TAG_CODE), TAG_HAS_NO_CHILDREN))), tagSearchResponse);
}
use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagServiceTest method testCreateTagUpperCaseParameters.
@Test
public void testCreateTagUpperCaseParameters() {
// Create and persist a tag type entity.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create a tag key.
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
// Create a tag using uppercase input parameters.
Tag resultTag = tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE.toUpperCase()), TAG_DISPLAY_NAME.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toUpperCase(), NO_PARENT_TAG_KEY));
// Get the tag entity.
TagEntity tagEntity = tagDao.getTagByKey(tagKey);
assertNotNull(tagEntity);
// Validate the returned object.
assertEquals(new Tag(resultTag.getId(), new TagKey(TAG_TYPE, TAG_CODE.toUpperCase()), TAG_DISPLAY_NAME.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toUpperCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), resultTag);
}
use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagServiceTest method testDeleteTagWithParent.
@Test
public void testDeleteTagWithParent() {
// Create and persist a tag type entity.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Create a tag key.
TagKey parentTagKey = new TagKey(TAG_TYPE, TAG_CODE);
// Create a parent tag.
Tag parentTag = tagService.createTag(new TagCreateRequest(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
// Get the parent tag entity.
TagEntity parentTagEntity = tagDao.getTagByKey(parentTagKey);
assertNotNull(parentTagEntity);
// Validate the response object.
assertEquals(new Tag(parentTagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, parentTagEntity.getCreatedBy(), parentTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(parentTagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), parentTag);
// Create a tag key.
TagKey childTagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
// Create a child tag.
Tag childTag = tagService.createTag(new TagCreateRequest(childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, parentTagKey));
// Get the child tag entity.
TagEntity childTagEntity = tagDao.getTagByKey(childTagKey);
assertNotNull(childTagEntity);
assertEquals(new Tag(childTagEntity.getId(), childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, childTagEntity.getCreatedBy(), childTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(childTagEntity.getUpdatedOn()), parentTagKey, NO_TAG_HAS_CHILDREN_FLAG), childTag);
// Delete this tag.
Tag deletedTag = tagService.deleteTag(childTagKey);
// Validate the returned object.
assertEquals(new Tag(childTagEntity.getId(), childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, childTagEntity.getCreatedBy(), childTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(childTagEntity.getUpdatedOn()), parentTagKey, NO_TAG_HAS_CHILDREN_FLAG), deletedTag);
// Ensure that this tag is no longer there.
assertNull(tagDao.getTagByKey(childTagKey));
}
use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagServiceTest method testSearchTagsMissingOptionalParameters.
@Test
public void testSearchTagsMissingOptionalParameters() {
// Create and persist database entities required for testing.
createDatabaseEntitiesForTagSearchTesting();
// Search tags without specifying an optional tag search filter.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(), NO_SEARCH_RESPONSE_FIELDS));
// Search tags when an optional tag search filter is set to null.
List<TagSearchFilter> tagSearchFilters = new ArrayList<>();
tagSearchFilters.add(null);
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(tagSearchFilters), NO_SEARCH_RESPONSE_FIELDS));
// Search tags without specifying optional parameters inside the tag search filter.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), NO_SEARCH_RESPONSE_FIELDS));
// Search tags without specifying optional parameters except for the display name field option.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), TAG_DISPLAY_NAME_2, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), TAG_DISPLAY_NAME_3, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.DISPLAY_NAME_FIELD)));
// Search tags without specifying optional parameters except for the search score multiplier option.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER_3, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER_2, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.SEARCH_SCORE_MULTIPLIER_FIELD)));
// Search tags without specifying optional parameters except for the description field option.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION_3, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION_2, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.DESCRIPTION_FIELD)));
// Search tags without specifying optional parameters except for the parent tag key field option.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_HAS_CHILDREN_FLAG), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_HAS_CHILDREN_FLAG))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.PARENT_TAG_KEY_FIELD)));
// Search tags without specifying optional parameters except for the "has children" field option.
assertEquals(new TagSearchResponse(Arrays.asList(new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, TAG_HAS_CHILDREN), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_3), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, TAG_HAS_NO_CHILDREN), new Tag(NO_ID, new TagKey(TAG_TYPE, TAG_CODE_2), NO_TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_TAG_DESCRIPTION, NO_USER_ID, NO_USER_ID, NO_UPDATED_TIME, NO_PARENT_TAG_KEY, TAG_HAS_NO_CHILDREN))), tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, BLANK_TEXT, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.HAS_CHILDREN_FIELD)));
}
Aggregations