Search in sources :

Example 16 with TagTypeKey

use of org.finra.herd.model.api.xml.TagTypeKey in project herd by FINRAOS.

the class TagTypeServiceTest method testDeleteTagType.

@Test
public void testDeleteTagType() {
    // Create and persist a tag type entity.
    tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
    // Delete the tag type.
    TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(TAG_TYPE));
    // Validate the returned object.
    assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType);
    // Ensure that this tag type is no longer there.
    assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey()));
}
Also used : TagType(org.finra.herd.model.api.xml.TagType) TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) Test(org.junit.Test)

Example 17 with TagTypeKey

use of org.finra.herd.model.api.xml.TagTypeKey in project herd by FINRAOS.

the class TagTypeServiceTest method testDeleteTagTypeTrimParameters.

@Test
public void testDeleteTagTypeTrimParameters() {
    // Create and persist a tag type entity.
    tagTypeDaoTestHelper.createTagTypeEntity(TAG_TYPE, TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION);
    // Delete the tag type using input parameters with leading and trailing empty spaces.
    TagType resultTagType = tagTypeService.deleteTagType(new TagTypeKey(addWhitespace(TAG_TYPE)));
    // Validate the returned object.
    assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, TAG_TYPE_DESCRIPTION), resultTagType);
    // Ensure that this tag type is no longer there.
    assertNull(tagTypeDao.getTagTypeByKey(resultTagType.getTagTypeKey()));
}
Also used : TagType(org.finra.herd.model.api.xml.TagType) TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) Test(org.junit.Test)

Example 18 with TagTypeKey

use of org.finra.herd.model.api.xml.TagTypeKey in project herd by FINRAOS.

the class TagTypeServiceTest method testCreateTagTypeTrimParameters.

@Test
public void testCreateTagTypeTrimParameters() throws Exception {
    // Create a tag type using input parameters with leading and trailing empty spaces.
    TagType resultTagType = tagTypeService.createTagType(new TagTypeCreateRequest(new TagTypeKey(addWhitespace(TAG_TYPE)), addWhitespace(TAG_TYPE_DISPLAY_NAME), TAG_TYPE_ORDER, addWhitespace(TAG_TYPE_DESCRIPTION)));
    // Validate the returned object.
    assertEquals(new TagType(new TagTypeKey(TAG_TYPE), TAG_TYPE_DISPLAY_NAME, TAG_TYPE_ORDER, addWhitespace(TAG_TYPE_DESCRIPTION)), resultTagType);
}
Also used : TagType(org.finra.herd.model.api.xml.TagType) TagTypeCreateRequest(org.finra.herd.model.api.xml.TagTypeCreateRequest) TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) Test(org.junit.Test)

Example 19 with TagTypeKey

use of org.finra.herd.model.api.xml.TagTypeKey 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 20 with TagTypeKey

use of org.finra.herd.model.api.xml.TagTypeKey in project herd by FINRAOS.

the class TagTypeServiceTest method testGetTagTypeTagTypeNotExists.

@Test
public void testGetTagTypeTagTypeNotExists() {
    // Try to retrieve a tag type instance when tag type code is not registered.
    try {
        tagTypeService.getTagType(new TagTypeKey(TAG_TYPE));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Tag type with code \"%s\" doesn't exist.", TAG_TYPE), e.getMessage());
    }
}
Also used : TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Aggregations

TagTypeKey (org.finra.herd.model.api.xml.TagTypeKey)44 Test (org.junit.Test)40 TagType (org.finra.herd.model.api.xml.TagType)27 TagTypeUpdateRequest (org.finra.herd.model.api.xml.TagTypeUpdateRequest)10 TagTypeCreateRequest (org.finra.herd.model.api.xml.TagTypeCreateRequest)7 TagTypeSearchRequest (org.finra.herd.model.api.xml.TagTypeSearchRequest)6 TagTypeSearchResponse (org.finra.herd.model.api.xml.TagTypeSearchResponse)6 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)3 ArrayList (java.util.ArrayList)2 Tag (org.finra.herd.model.api.xml.Tag)2 TagTypeKeys (org.finra.herd.model.api.xml.TagTypeKeys)2 TagEntity (org.finra.herd.model.jpa.TagEntity)2 TagChild (org.finra.herd.model.api.xml.TagChild)1 TagKey (org.finra.herd.model.api.xml.TagKey)1 TagListResponse (org.finra.herd.model.api.xml.TagListResponse)1 TagSearchKey (org.finra.herd.model.api.xml.TagSearchKey)1 TagSearchResponse (org.finra.herd.model.api.xml.TagSearchResponse)1