use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.
the class TagServiceTest method testCreateTagMissingOptionalParametersPassedAsNulls.
@Test
public void testCreateTagMissingOptionalParametersPassedAsNulls() {
// 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 with description passed in as null.
Tag tag = tagService.createTag(new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_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(), tagKey, TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, NO_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.TagKey in project herd by FINRAOS.
the class TagServiceTest method testCreateTagTrimParameters.
@Test
public void testCreateTagTrimParameters() {
// 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 with parameters padded with whitespace.
Tag tag = tagService.createTag(new TagCreateRequest(new TagKey(addWhitespace(TAG_TYPE), addWhitespace(TAG_CODE)), addWhitespace(TAG_DISPLAY_NAME), TAG_SEARCH_SCORE_MULTIPLIER, addWhitespace(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, addWhitespace(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.TagKey in project herd by FINRAOS.
the class TagServiceTest method testSearchTags.
@Test
public void testSearchTags() {
// Create and persist database entities required for testing.
createDatabaseEntitiesForTagSearchTesting();
// Search the tags.
TagSearchResponse tagSearchResponse = tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(TAG_TYPE, TAG_CODE, NO_IS_PARENT_TAG_NULL_FLAG))))), Sets.newHashSet(TagServiceImpl.DISPLAY_NAME_FIELD, TagServiceImpl.SEARCH_SCORE_MULTIPLIER_FIELD, TagServiceImpl.DESCRIPTION_FIELD, TagServiceImpl.PARENT_TAG_KEY_FIELD, TagServiceImpl.HAS_CHILDREN_FIELD));
// 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.TagKey in project herd by FINRAOS.
the class TagServiceTest method testUpdateTagMissingRequiredParameters.
@Test
public void testUpdateTagMissingRequiredParameters() {
// Try to update a tag when tag type is not specified.
try {
tagService.updateTag(new TagKey(BLANK_TEXT, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag type code must be specified.", e.getMessage());
}
// Try to update a tag when tag code is not specified.
try {
tagService.updateTag(new TagKey(TAG_TYPE, BLANK_TEXT), new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag code must be specified.", e.getMessage());
}
// Try to update a tag when tag display name is not specified.
try {
tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(BLANK_TEXT, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A display name must be specified.", e.getMessage());
}
// Try to update a tag when parent tag type is not specified.
try {
tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE_2), new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, new TagKey(BLANK_TEXT, TAG_CODE)));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag type code must be specified.", e.getMessage());
}
// Try to update a tag when parent tag code is not specified.
try {
tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE_2), new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, 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 TagServiceTest method testGetTagTagNoExists.
@Test
public void testGetTagTagNoExists() {
// Try to get a non-existing tag.
try {
tagService.getTag(new TagKey(TAG_TYPE, TAG_CODE));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE, TAG_TYPE), e.getMessage());
}
}
Aggregations