use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testDeleteTagWithParent.
@Test
public void testDeleteTagWithParent() {
// 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 parentTagKey = new TagKey(TAG_TYPE, TAG_CODE);
// Create a parent tag.
Tag parentTag = tagService.createTag(new TagCreateRequest(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
// Get the parent tag entity.
TagEntity parentTagEntity = tagDao.getTagByKey(parentTagKey);
assertNotNull(parentTagEntity);
// Validate the response object.
assertEquals(new Tag(parentTagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, parentTagEntity.getCreatedBy(), parentTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(parentTagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), parentTag);
// Create a tag key.
TagKey childTagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
// Create a child tag.
Tag childTag = tagService.createTag(new TagCreateRequest(childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, parentTagKey));
// Get the child tag entity.
TagEntity childTagEntity = tagDao.getTagByKey(childTagKey);
assertNotNull(childTagEntity);
assertEquals(new Tag(childTagEntity.getId(), childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, childTagEntity.getCreatedBy(), childTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(childTagEntity.getUpdatedOn()), parentTagKey, NO_TAG_HAS_CHILDREN_FLAG), childTag);
// Delete this tag.
Tag deletedTag = tagService.deleteTag(childTagKey);
// Validate the returned object.
assertEquals(new Tag(childTagEntity.getId(), childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, childTagEntity.getCreatedBy(), childTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(childTagEntity.getUpdatedOn()), parentTagKey, NO_TAG_HAS_CHILDREN_FLAG), deletedTag);
// Ensure that this tag is no longer there.
assertNull(tagDao.getTagByKey(childTagKey));
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagDisplayNameAlreadyExists.
@Test
public void testCreateTagDisplayNameAlreadyExists() {
// Create and persist a tag entity.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME.toUpperCase(), TAG_DESCRIPTION);
// Try to create a tag with a duplicate tag display name.
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE_2), TAG_DISPLAY_NAME.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, 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.toLowerCase(), TAG_TYPE, TAG_CODE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagTagTypeNoExists.
@Test
public void testCreateTagTagTypeNoExists() {
// Try to create a tag using non-existing tag type.
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagParentTagNoExists.
@Test
public void testCreateTagParentTagNoExists() {
// Create and persist a tag type entity.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
// Try to create a tag with a non-existing parent tag.
try {
tagService.createTag(new TagCreateRequest(new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, new TagKey(TAG_TYPE, TAG_CODE_2)));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Tag with code \"%s\" doesn't exist for tag type \"%s\".", TAG_CODE_2, TAG_TYPE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.TagCreateRequest in project herd by FINRAOS.
the class TagServiceTest method testCreateTagWithParent.
@Test
public void testCreateTagWithParent() {
// 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 parentTagKey = new TagKey(TAG_TYPE, TAG_CODE);
// Create a parent tag.
Tag parentTag = tagService.createTag(new TagCreateRequest(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY));
// Get the parent tag entity.
TagEntity parentTagEntity = tagDao.getTagByKey(parentTagKey);
assertNotNull(parentTagEntity);
// Validate the response object.
assertEquals(new Tag(parentTagEntity.getId(), new TagKey(TAG_TYPE, TAG_CODE), TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, parentTagEntity.getCreatedBy(), parentTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(parentTagEntity.getUpdatedOn()), NO_PARENT_TAG_KEY, NO_TAG_HAS_CHILDREN_FLAG), parentTag);
// Create a tag key.
TagKey childTagKey = new TagKey(TAG_TYPE, TAG_CODE_2);
// Create a child tag.
Tag childTag = tagService.createTag(new TagCreateRequest(childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, parentTagKey));
// Get the child tag entity.
TagEntity childTagEntity = tagDao.getTagByKey(childTagKey);
assertNotNull(childTagEntity);
assertEquals(new Tag(childTagEntity.getId(), childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, childTagEntity.getCreatedBy(), childTagEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(childTagEntity.getUpdatedOn()), parentTagKey, NO_TAG_HAS_CHILDREN_FLAG), childTag);
}
Aggregations