Search in sources :

Example 21 with Tag

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);
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 22 with 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);
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 23 with 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);
}
Also used : TagSearchFilter(org.finra.herd.model.api.xml.TagSearchFilter) TagSearchKey(org.finra.herd.model.api.xml.TagSearchKey) TagSearchResponse(org.finra.herd.model.api.xml.TagSearchResponse) TagKey(org.finra.herd.model.api.xml.TagKey) Tag(org.finra.herd.model.api.xml.Tag) TagSearchRequest(org.finra.herd.model.api.xml.TagSearchRequest) Test(org.junit.Test)

Example 24 with Tag

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);
}
Also used : TagKey(org.finra.herd.model.api.xml.TagKey) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 25 with Tag

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);
}
Also used : TagKey(org.finra.herd.model.api.xml.TagKey) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Aggregations

Tag (org.finra.herd.model.api.xml.Tag)41 TagKey (org.finra.herd.model.api.xml.TagKey)39 Test (org.junit.Test)36 TagEntity (org.finra.herd.model.jpa.TagEntity)28 TagUpdateRequest (org.finra.herd.model.api.xml.TagUpdateRequest)11 TagCreateRequest (org.finra.herd.model.api.xml.TagCreateRequest)10 TagSearchKey (org.finra.herd.model.api.xml.TagSearchKey)9 TagSearchResponse (org.finra.herd.model.api.xml.TagSearchResponse)9 TagSearchFilter (org.finra.herd.model.api.xml.TagSearchFilter)8 TagSearchRequest (org.finra.herd.model.api.xml.TagSearchRequest)8 ArrayList (java.util.ArrayList)3 TagTypeKey (org.finra.herd.model.api.xml.TagTypeKey)3 TagChild (org.finra.herd.model.api.xml.TagChild)2 TagListResponse (org.finra.herd.model.api.xml.TagListResponse)2 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Date (java.util.Date)1