Search in sources :

Example 26 with AlreadyExistsException

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());
    }
}
Also used : TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 27 with AlreadyExistsException

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());
    }
}
Also used : TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) TagTypeUpdateRequest(org.finra.herd.model.api.xml.TagTypeUpdateRequest) Test(org.junit.Test)

Example 28 with AlreadyExistsException

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());
    }
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) TagKey(org.finra.herd.model.api.xml.TagKey) Test(org.junit.Test)

Example 29 with AlreadyExistsException

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));
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 30 with AlreadyExistsException

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);
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Aggregations

AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)62 Test (org.junit.Test)35 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)12 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)11 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)9 ArrayList (java.util.ArrayList)7 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)7 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 StorageEntity (org.finra.herd.model.jpa.StorageEntity)6 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)5 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)5 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 NotificationRegistrationKey (org.finra.herd.model.api.xml.NotificationRegistrationKey)4 StorageFile (org.finra.herd.model.api.xml.StorageFile)4 TagKey (org.finra.herd.model.api.xml.TagKey)4 NamespacePermissions (org.finra.herd.model.annotation.NamespacePermissions)3 AttributeValueListKey (org.finra.herd.model.api.xml.AttributeValueListKey)3 BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)3 RelationalTableRegistrationCreateRequest (org.finra.herd.model.api.xml.RelationalTableRegistrationCreateRequest)3 TagTypeKey (org.finra.herd.model.api.xml.TagTypeKey)3