Search in sources :

Example 21 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testGetTagMissingRequiredParameters.

@Test
public void testGetTagMissingRequiredParameters() {
    // Try to get a tag when tag type is not specified.
    try {
        tagService.getTag(new TagKey(BLANK_TEXT, TAG_CODE));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A tag type code must be specified.", e.getMessage());
    }
    // Try to get a tag when tag code is not specified.
    try {
        tagService.getTag(new TagKey(TAG_TYPE, BLANK_TEXT));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A tag code must be specified.", e.getMessage());
    }
}
Also used : TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 22 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testDeleteTagLowerCaseParameters.

@Test
public void testDeleteTagLowerCaseParameters() {
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create and persist a tag entity.
    tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Validate that this tag exists.
    TagEntity tagEntity = tagDao.getTagByKey(tagKey);
    assertNotNull(tagEntity);
    // Delete this tag using uppercase input parameters.
    Tag deletedTag = tagService.deleteTag(new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase()));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, 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), deletedTag);
    // Ensure that this tag is no longer there.
    assertNull(tagDao.getTagByKey(tagKey));
}
Also used : TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 23 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testUpdateTagNoChangesToDisplayNameExceptForCase.

@Test
public void testUpdateTagNoChangesToDisplayNameExceptForCase() {
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create and persist a tag entity.
    TagEntity tagEntity = tagDaoTestHelper.createTagEntity(tagKey, TAG_DISPLAY_NAME.toUpperCase(), TAG_DESCRIPTION);
    // Update the tag without changing it's display name except for the case.
    Tag updatedTag = tagService.updateTag(tagKey, new TagUpdateRequest(TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, NO_PARENT_TAG_KEY));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), updatedTag);
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) TagEntity(org.finra.herd.model.jpa.TagEntity) TagKey(org.finra.herd.model.api.xml.TagKey) Tag(org.finra.herd.model.api.xml.Tag) Test(org.junit.Test)

Example 24 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testCreateTagInvalidParameters.

@Test
public void testCreateTagInvalidParameters() {
    // Try to create a tag when tag type contains a forward slash character.
    try {
        tagService.createTag(new TagCreateRequest(new TagKey(addSlash(TAG_TYPE), TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Tag type code can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a tag when tag code contains a forward slash character.
    try {
        tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, addSlash(TAG_CODE)), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Tag code can not contain a forward slash character.", e.getMessage());
    }
    // Try to create a tag with parent tag type is not the same as the requested.
    try {
        tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, new TagKey(TAG_TYPE_2, TAG_CODE_2)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Tag type code in parent tag key must match the tag type code in the request.", e.getMessage());
    }
    // Try to create a tag with a negative search score multiplier value.
    try {
        tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER.multiply(BigDecimal.valueOf(-1)), TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The searchScoreMultiplier can not have a negative value. searchScoreMultiplier=%s", TAG_SEARCH_SCORE_MULTIPLIER.multiply(BigDecimal.valueOf(-1))), e.getMessage());
    }
}
Also used : TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 25 with TagKey

use of org.finra.herd.model.api.xml.TagKey in project herd by FINRAOS.

the class TagServiceTest method testUpdateTagParentTagIsChild.

@Test
public void testUpdateTagParentTagIsChild() {
    // Create and persist a root tag entity.
    TagEntity rootTagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Create a child tag entity.
    TagEntity childTagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_2, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, rootTagEntity);
    // Create a grandchild tag entity.
    TagEntity grandchildTagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_3, TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, childTagEntity);
    // Try to update the root tag using a parent tag set to the tag itself and it's children.
    for (TagEntity tagEntity : Arrays.asList(rootTagEntity, childTagEntity, grandchildTagEntity)) {
        try {
            tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_4, TAG_SEARCH_SCORE_MULTIPLIER_4, TAG_DESCRIPTION_4, new TagKey(tagEntity.getTagType().getCode(), tagEntity.getTagCode())));
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals("Parent tag key cannot be the requested tag key or any of its children’s tag keys.", e.getMessage());
        }
    }
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) TagEntity(org.finra.herd.model.jpa.TagEntity) 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