Search in sources :

Example 16 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagTrimParameters.

@Test
public void testUpdateTagTrimParameters() {
    // 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 input parameters with leading and trailing empty spaces.
    Tag updatedTag = tagService.updateTag(new TagKey(addWhitespace(TAG_TYPE), addWhitespace(TAG_CODE_2)), new TagUpdateRequest(addWhitespace(TAG_DISPLAY_NAME_3), TAG_SEARCH_SCORE_MULTIPLIER_3, addWhitespace(TAG_DESCRIPTION_3), new TagKey(addWhitespace(TAG_TYPE), addWhitespace(TAG_CODE.toLowerCase()))));
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), tagKey, TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER_3, addWhitespace(TAG_DESCRIPTION_3), 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 17 with TagUpdateRequest

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

the class TagServiceTest method testUpdateTagInvalidParameters.

@Test
public void testUpdateTagInvalidParameters() {
    // Try to update a tag using a parent tag with a different tag type code.
    try {
        tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, 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 update a tag using a negative search score multiplier value.
    try {
        tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2.multiply(BigDecimal.valueOf(-1)), TAG_DESCRIPTION_2, new TagKey(TAG_TYPE, TAG_CODE_2)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The searchScoreMultiplier can not have a negative value. searchScoreMultiplier=%s", TAG_SEARCH_SCORE_MULTIPLIER_2.multiply(BigDecimal.valueOf(-1))), e.getMessage());
    }
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) TagKey(org.finra.herd.model.api.xml.TagKey) 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