Search in sources :

Example 1 with TagCreateRequest

use of org.finra.herd.model.api.xml.TagCreateRequest 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 2 with TagCreateRequest

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

the class TagServiceTest method testCreateTagLowerCaseParameters.

@Test
public void testCreateTagLowerCaseParameters() {
    // 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 using lowercase input parameters.
    Tag resultTag = tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase()), TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toLowerCase(), NO_PARENT_TAG_KEY));
    // Get the tag entity.
    TagEntity tagEntity = tagDao.getTagByKey(tagKey);
    assertNotNull(tagEntity);
    // Validate the returned object.
    assertEquals(new Tag(tagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE.toLowerCase()), TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toLowerCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), resultTag);
}
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 3 with TagCreateRequest

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

the class TagServiceTest method testCreateTagMissingOptionalParametersPassedAsWhitespace.

@Test
public void testCreateTagMissingOptionalParametersPassedAsWhitespace() {
    // 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 whitespace.
    Tag tag = tagService.createTag(new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, NO_TAG_SEARCH_SCORE_MULTIPLIER, BLANK_TEXT, 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, BLANK_TEXT, 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 4 with TagCreateRequest

use of org.finra.herd.model.api.xml.TagCreateRequest 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 5 with TagCreateRequest

use of org.finra.herd.model.api.xml.TagCreateRequest 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)

Aggregations

TagCreateRequest (org.finra.herd.model.api.xml.TagCreateRequest)15 TagKey (org.finra.herd.model.api.xml.TagKey)15 Test (org.junit.Test)15 Tag (org.finra.herd.model.api.xml.Tag)9 TagEntity (org.finra.herd.model.jpa.TagEntity)8 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)2