@Test
public void testAssertDisplayNameDoesNotExistForTag()
{

    // Create a tag type entity
    TagTypeEntity tagTypeEntity = new TagTypeEntity();
    tagTypeEntity.setCode(TAG_TYPE_CODE);
    // Create a tag entity
    TagEntity tagEntity = new TagEntity();
    tagEntity.setTagType(tagTypeEntity);
    tagEntity.setTagCode(TAG_CODE);
    tagEntity.setDisplayName(TAG_DISPLAY_NAME);
    // Setup when clauses
    when(tagDao.getTagByTagTypeAndDisplayName(TAG_CODE, TAG_DISPLAY_NAME)).thenReturn(tagEntity);
    // Call method under test
    try
    {
        tagDaoHelper.assertDisplayNameDoesNotExistForTag(TAG_CODE, TAG_DISPLAY_NAME);
        fail("Expected to throw an exception.");
    }
    catch (AlreadyExistsException alreadyExistsException)
    {
        // Confirm the exception message is correct
        assertThat("Exception message is not correct.", alreadyExistsException.getMessage(), is(equalTo(String
            .format("Display name \"%s\" already exists for a tag with tag type \"%s\" and tag code \"%s\".", TAG_DISPLAY_NAME,
                tagEntity.getTagType().getCode(), tagEntity.getTagCode()))));
    }
    // Setup verify clauses
    verify(tagDao).getTagByTagTypeAndDisplayName(TAG_CODE, TAG_DISPLAY_NAME);
    verifyNoMoreInteractions(configurationHelper, tagDao);
}