use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoHelperTest method testGetGlobalAttributeDefinitionEntityEntityNoExists.
@Test
public void testGetGlobalAttributeDefinitionEntityEntityNoExists() {
// Create a global attribute definition key.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Mock calls to external methods.
when(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey)).thenReturn(null);
// Try to call the method under test.
try {
globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Global attribute definition with level \"%s\" doesn't exist for global attribute definition name \"%s\".", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName()), e.getMessage());
}
// Verify the external calls.
verify(globalAttributeDefinitionDao).getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey);
verifyNoMoreInteractions(globalAttributeDefinitionDao);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoHelperTest method testGetGlobalAttributeDefinitionEntity.
@Test
public void testGetGlobalAttributeDefinitionEntity() {
// 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 = globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Mock calls to external methods.
when(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinitionEntity);
// Call the method under test.
GlobalAttributeDefinitionEntity response = globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
// Verify the external calls.
verify(globalAttributeDefinitionDao).getGlobalAttributeDefinitionByKey(globalAttributeDefinitionKey);
verifyNoMoreInteractions(globalAttributeDefinitionDao);
// Validate the response.
assertEquals(globalAttributeDefinitionEntity, response);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionHelperTest method testValidateGlobalAttributeDefinitionKey.
@Test
public void testValidateGlobalAttributeDefinitionKey() {
// Create a global attribute definition key.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Mock the external calls.
when(alternateKeyHelper.validateStringParameter("global attribute definition level", GLOBAL_ATTRIBUTE_DEFINITON_LEVEL)).thenReturn(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL);
when(alternateKeyHelper.validateStringParameter("global attribute definition name", GLOBAL_ATTRIBUTE_DEFINITON_NAME)).thenReturn(GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Call the method under test.
globalAttributeDefinitionHelper.validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
// Verify the external calls.
verify(alternateKeyHelper).validateStringParameter("global attribute definition level", GLOBAL_ATTRIBUTE_DEFINITON_LEVEL);
verify(alternateKeyHelper).validateStringParameter("global attribute definition name", GLOBAL_ATTRIBUTE_DEFINITON_NAME);
verifyNoMoreInteractions(alternateKeyHelper);
// Validate the results.
assertEquals(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME), globalAttributeDefinitionKey);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoTest method testGetGlobalAttributeDefinitionByKey.
@Test
public void testGetGlobalAttributeDefinitionByKey() {
// Create and persist a global attribute definition entity.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Retrieve a global attribute definition entity.
assertEquals(globalAttributeDefinitionEntity, globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME)));
// Test case insensitivity.
assertEquals(globalAttributeDefinitionEntity, globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL.toUpperCase(), GLOBAL_ATTRIBUTE_DEFINITON_NAME.toUpperCase())));
assertEquals(globalAttributeDefinitionEntity, globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL.toLowerCase(), GLOBAL_ATTRIBUTE_DEFINITON_NAME.toLowerCase())));
// Confirm negative results when using invalid values.
assertNull(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(new GlobalAttributeDefinitionKey(I_DO_NOT_EXIST, GLOBAL_ATTRIBUTE_DEFINITON_NAME)));
assertNull(globalAttributeDefinitionDao.getGlobalAttributeDefinitionByKey(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, I_DO_NOT_EXIST)));
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoTest method testGetGlobalAttributeDefinitionKeys.
@Test
public void testGetGlobalAttributeDefinitionKeys() {
// Get a list of global attribute definition keys.
List<GlobalAttributeDefinitionKey> globalAttributeDefinitionKeys = globalAttributeDefinitionDaoTestHelper.getTestGlobalAttributeDefinitionKeys();
// Create and persist global attribute definition entities.
for (GlobalAttributeDefinitionKey globalAttributeDefinitionKey : globalAttributeDefinitionKeys) {
globalAttributeDefinitionDaoTestHelper.createGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName());
}
// Retrieve a list of global attribute definition keys.
List<GlobalAttributeDefinitionKey> result = globalAttributeDefinitionDao.getAllGlobalAttributeDefinitionKeys();
// Validate the returned object.
assertEquals(globalAttributeDefinitionKeys, result);
}
Aggregations