Search in sources :

Example 41 with TagKey

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);
}
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 42 with TagKey

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);
}
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 43 with TagKey

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);
}
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 44 with TagKey

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

Example 45 with TagKey

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

Aggregations

TagKey (org.finra.herd.model.api.xml.TagKey)140 Test (org.junit.Test)133 TagEntity (org.finra.herd.model.jpa.TagEntity)54 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)39 Tag (org.finra.herd.model.api.xml.Tag)38 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)37 ArrayList (java.util.ArrayList)25 BusinessObjectDefinitionSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)21 BusinessObjectDefinitionSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey)21 TagUpdateRequest (org.finra.herd.model.api.xml.TagUpdateRequest)17 TagCreateRequest (org.finra.herd.model.api.xml.TagCreateRequest)15 HashSet (java.util.HashSet)13 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)13 BusinessObjectDefinitionSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest)13 BusinessObjectDefinitionSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)12 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)12 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)11 BusinessObjectDefinitionTag (org.finra.herd.model.api.xml.BusinessObjectDefinitionTag)10 BusinessObjectDefinitionTagCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagCreateRequest)10 BusinessObjectDefinitionTagKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys)10