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());
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations