use of org.finra.herd.model.api.xml.Tag 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.Tag 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.Tag 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.Tag in project herd by FINRAOS.
the class TagRestControllerTest method testGetTag.
@Test
public void testGetTag() {
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
Tag tag = getNewTag(tagKey);
when(tagService.getTag(tagKey)).thenReturn(tag);
// Retrieve the tag.
Tag resultTag = tagRestController.getTag(TAG_TYPE, TAG_CODE);
// Verify the external calls.
verify(tagService).getTag(tagKey);
verifyNoMoreInteractions(tagService);
// Validate the returned object.
assertEquals(tag, resultTag);
}
use of org.finra.herd.model.api.xml.Tag in project herd by FINRAOS.
the class TagRestControllerTest method testCreateTag.
@Test
public void testCreateTag() {
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
TagCreateRequest request = new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY);
Tag tag = getNewTag(tagKey);
when(tagService.createTag(request)).thenReturn(tag);
// Create a tag.
Tag resultTag = tagRestController.createTag(request);
// Verify the external calls.
verify(tagService).createTag(request);
verifyNoMoreInteractions(tagService);
// Validate the returned object.
assertEquals(tag, resultTag);
}
Aggregations