use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class TagServiceTest method testUpdateTagDisplayNameAlreadyExistsForThisTagType.
@Test
public void testUpdateTagDisplayNameAlreadyExistsForThisTagType() {
// Create and persist a tag entity.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION);
// Create and persist a second tag entity for the same tag type that would have the display name to be updated to.
tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_2, TAG_DISPLAY_NAME_2.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION);
// Try to update a tag with an already existing display name.
try {
tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, 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_2.toLowerCase(), TAG_TYPE, TAG_CODE_2), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class TagTypeServiceTest method testUpdateTagTypeDisplayNameAlreadyExists.
@Test
public void testUpdateTagTypeDisplayNameAlreadyExists() {
// Create and persist two tag type entities with the second one having display name that we want to update to.
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE_2, TAG_TYPE_DISPLAY_NAME_2, TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2);
// Try to update a tag type instance when display name already exists.
try {
tagTypeService.updateTagType(new TagTypeKey(TAG_TYPE), new TagTypeUpdateRequest(TAG_TYPE_DISPLAY_NAME_2, TAG_TYPE_ORDER_2, TAG_TYPE_DESCRIPTION_2));
fail();
} catch (AlreadyExistsException e) {
assertEquals(String.format("Display name \"%s\" already exists for tag type \"%s\".", TAG_TYPE_DISPLAY_NAME_2, TAG_TYPE_2), e.getMessage());
}
}
use of org.finra.herd.model.AlreadyExistsException 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.AlreadyExistsException in project herd by FINRAOS.
the class AlreadyExistsExceptionTest method testExceptionThrowableConstructor.
@Test
public void testExceptionThrowableConstructor() throws Exception {
Exception exception = new Exception(TEST_MESSAGE_2);
AlreadyExistsException alreadyExistsException = new AlreadyExistsException(exception);
assertTrue(alreadyExistsException.getCause().getMessage().equals(TEST_MESSAGE_2));
}
use of org.finra.herd.model.AlreadyExistsException in project herd by FINRAOS.
the class AlreadyExistsExceptionTest method testExceptionNoArgConstructor.
@Test
public void testExceptionNoArgConstructor() throws Exception {
AlreadyExistsException exception = new AlreadyExistsException();
assertTrue(exception.getMessage() == null);
}
Aggregations