@Test
public void testValidateGlobalAttributeDefinitionNoExistsEntityExists()
{

    // Create a global attribute definition key.
    GlobalAttributeDefinitionKey globalAttributeDefinitionKey =
        new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    // Create a global attribute definition entity.
    GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = new GlobalAttributeDefinitionEntity();
    // Mock calls to external methods.
    when(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinitionEntity);
    // Try to call the method under test.
    try
    {
        globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(globalAttributeDefinitionKey);
        fail();
    }
    catch (AlreadyExistsException e)
    {
        assertEquals(String.format("Unable to create global attribute definition with global attribute definition level \"%s\" " +
            "and global attribute definition name \"%s\" because it already exists.", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(),
            globalAttributeDefinitionKey.getGlobalAttributeDefinitionName()), e.getMessage());
    }
    // Verify the external calls.
    verify(globalAttributeDefinitionDao).getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey);
    verifyNoMoreInteractions(globalAttributeDefinitionDao);
}