use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagTagAlreadyExists.
@Test
public void testCreateTagTagAlreadyExists() {
// Create and persist a tag entity.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE.toUpperCase(), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
// Try to create a duplicate tag (uses the same tag type and tag name).
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE.toLowerCase()), TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, NO_PARENT_TAG_KEY));
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Unable to create tag with tag type code \"%s\" and tag code \"%s\" because it already exists.", TAG_TYPE, TAG_CODE.toLowerCase()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagRestControllerTest method testCreateTag.
@Test
public void testCreateTag() {
TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE);
TagCreateRequest request = new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY);
Tag tag = getNewTag(tagKey);
when(tagService.createTag(request)).thenReturn(tag);
// Create a tag.
Tag resultTag = tagRestController.createTag(request);
// Verify the external calls.
verify(tagService).createTag(request);
verifyNoMoreInteractions(tagService);
// Validate the returned object.
assertEquals(tag, resultTag);
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagMissingRequiredParams.
@Test
public void testCreateTagMissingRequiredParams() {
// Missing tag key.
try {
tagService.createTag(new TagCreateRequest(null, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag key must be specified.", e.getMessage());
}
// Missing tag type code in the key.
try {
tagService.createTag(new TagCreateRequest(new TagKey(null, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag type code must be specified.", e.getMessage());
}
// Missing tag code in the key.
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, null), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A tag code must be specified.", e.getMessage());
}
// Missing display name in the request.
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE), null, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (IllegalArgumentException e) {
assertEquals("A display name must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTag.
@Test
public void testCreateTag() {
// 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.
Tag tag = tagService.createTag(new TagCreateRequest(tagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, 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, 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 testCreateTagUpperCaseParameters.
@Test
public void testCreateTagUpperCaseParameters() {
// 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 uppercase input parameters.
Tag resultTag = tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE.toUpperCase(), TAG_CODE.toUpperCase()), TAG_DISPLAY_NAME.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toUpperCase(), NO_PARENT_TAG_KEY));
// Get the tag entity.
TagEntity tagEntity = tagDao.getTagByKey(tagKey);
assertNotNull(tagEntity);
// Validate the returned object.
assertEquals(new Tag(resultTag.getId(), new TagKey(TAG_TYPE, TAG_CODE.toUpperCase()), TAG_DISPLAY_NAME.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION.toUpperCase(), tagEntity.getCreatedBy(), tagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(tagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), resultTag);
}
Aggregations