Search in sources :

Example 6 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagUpperCaseParameters.

@Test
public void testUpdateTagUpperCaseParameters() {
    // Create a parent tag key.
    TagKey parentTagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create a parent tag entity.
    tagDaoTestHelper.createTagEntity(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
    // Create and persist a tag entity without a parent tag.
    TagEntity tagEntity = tagDaoTestHelper.createTagEntity(tagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2);
    // Update the tag using uppercase input parameters.
    Tag updatedTag = tagService.updateTag(new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE_2.toUpperCase()), new TagUpdateRequest(TAG_DISPLAY_NAME_3.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3.toUpperCase(), new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE.toUpperCase())));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, TAG_DISPLAY_NAME_3.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3.toUpperCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), parentTagKey, 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 7 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagParentTagNoExists.

@Test
public void testUpdateTagParentTagNoExists() {
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
    // Create and persist a tag entity without a parent tag.
    tagDaoTestHelper.createTagEntity(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Try to update a tag using a non-existing parent tag.
    try {
        tagService.updateTag(tagKey, new TagUpdateRequest(TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, 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 : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 8 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagDisplayNameAlreadyExistsForThisTagType.

@Test
public void testUpdateTagDisplayNameAlreadyExistsForThisTagType() {
    // Create and persist a tag entity.
    tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Create and persist a second tag entity for the same tag type that would have the display name to be updated to.
    tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_2, TAG_DISPLAY_NAME_2.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION);
    // Try to update a tag with an already existing display name.
    try {
        tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, NO_PARENT_TAG_KEY));
        fail();
    } catch (AlreadyExistsException e) {
        assertEquals(String.format("Display name \"%s\" already exists for a tag with tag type \"%s\" and tag code \"%s\".", TAG_DISPLAY_NAME_2.toLowerCase(), TAG_TYPE, TAG_CODE_2), e.getMessage());
    }
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 9 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagDisplayNameAlreadyExistsForOtherTagType.

@Test
public void testUpdateTagDisplayNameAlreadyExistsForOtherTagType() {
    // Create and persist a tag entity.
    TagEntity tagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Create and persist a second tag entity for the another tag type that would have the display name to be updated to.
    tagDaoTestHelper.createTagEntity(TAG_TYPE_2, TAG_CODE_2, TAG_DISPLAY_NAME_2, TAG_DESCRIPTION_2);
    // Update the tag.
    Tag updatedTag = tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, NO_PARENT_TAG_KEY));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, 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 10 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagLowerCaseParameters.

@Test
public void testUpdateTagLowerCaseParameters() {
    // Create a parent tag key.
    TagKey parentTagKey = new TagKey(TAG_TYPE, TAG_CODE);
    // Create a parent tag entity.
    tagDaoTestHelper.createTagEntity(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
    // Create a tag key.
    TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
    // Create and persist a tag entity without a parent tag.
    TagEntity tagEntity = tagDaoTestHelper.createTagEntity(tagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2);
    // Update the tag using lowercase input parameters.
    Tag updatedTag = tagService.updateTag(new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE_2.toLowerCase()), new TagUpdateRequest(TAG_DISPLAY_NAME_3.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3.toLowerCase(), new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase())));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, TAG_DISPLAY_NAME_3.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3.toLowerCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), parentTagKey, 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)

Aggregations

TagKey (org.finra.herd.model.api.xml.TagKey)17 TagUpdateRequest (org.finra.herd.model.api.xml.TagUpdateRequest)17 Test (org.junit.Test)17 TagEntity (org.finra.herd.model.jpa.TagEntity)11 Tag (org.finra.herd.model.api.xml.Tag)10 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2 HashMap (java.util.HashMap)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1