use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceTest method testDeleteGlobalAttributeDefinition.
@Test
public void testDeleteGlobalAttributeDefinition() {
// 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(globalAttributeDefinitionDaoHelper.getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinitionEntity);
// Call the method under test.
GlobalAttributeDefinition response = globalAttributeDefinitionService.deleteGlobalAttributeDefinition(globalAttributeDefinitionKey);
// Verify the external calls.
verify(globalAttributeDefinitionHelper).validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
verify(globalAttributeDefinitionDaoHelper).getGlobalAttributeDefinitionEntity(globalAttributeDefinitionKey);
verify(globalAttributeDefinitionDao).delete(globalAttributeDefinitionEntity);
verifyNoMoreInteractionsHelper();
// Validate.
assertEquals(new GlobalAttributeDefinition(response.getId(), globalAttributeDefinitionKey, attributeValueListNull), response);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceTest method testGetGlobalAttributeDefinitions.
@Test
public void testGetGlobalAttributeDefinitions() {
// Create a list of global attribute definitions keys.
List<GlobalAttributeDefinitionKey> globalAttributeDefinitionKeys = Arrays.asList(new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME), new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME_2));
// Mock calls to external methods.
when(globalAttributeDefinitionDao.getAllGlobalAttributeDefinitionKeys()).thenReturn(globalAttributeDefinitionKeys);
// Call the method under test.
GlobalAttributeDefinitionKeys response = globalAttributeDefinitionService.getGlobalAttributeDefinitionKeys();
// Verify the external calls.
verify(globalAttributeDefinitionDao).getAllGlobalAttributeDefinitionKeys();
verifyNoMoreInteractionsHelper();
// Validate the response.
assertEquals(new GlobalAttributeDefinitionKeys(globalAttributeDefinitionKeys), response);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceTest method testCreateGlobalAttributeDefinition.
@Test
public void testCreateGlobalAttributeDefinition() {
// Create a global attribute definition key.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Create a global attribute definition create request.
GlobalAttributeDefinitionCreateRequest request = new GlobalAttributeDefinitionCreateRequest(globalAttributeDefinitionKey, attributeValueListKeyNull);
// Create a global attribute definition level entity.
GlobalAttributeDefinitionLevelEntity globalAttributeDefinitionLevelEntity = new GlobalAttributeDefinitionLevelEntity();
globalAttributeDefinitionLevelEntity.setGlobalAttributeDefinitionLevel(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL);
// Create a global attribute definition entity.
GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = new GlobalAttributeDefinitionEntity();
globalAttributeDefinitionEntity.setId(GLOBAL_ATTRIBUTE_DEFINITON_ID);
globalAttributeDefinitionEntity.setGlobalAttributeDefinitionLevel(globalAttributeDefinitionLevelEntity);
globalAttributeDefinitionEntity.setGlobalAttributeDefinitionName(GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Mock calls to external methods.
when(globalAttributeDefinitionLevelDao.getGlobalAttributeDefinitionLevel(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL)).thenReturn(globalAttributeDefinitionLevelEntity);
when(globalAttributeDefinitionDao.saveAndRefresh(any(GlobalAttributeDefinitionEntity.class))).thenReturn(globalAttributeDefinitionEntity);
// Call the method under test.
GlobalAttributeDefinition response = globalAttributeDefinitionService.createGlobalAttributeDefinition(request);
// Verify the external calls.
verify(globalAttributeDefinitionHelper).validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
verify(globalAttributeDefinitionDaoHelper).validateGlobalAttributeDefinitionNoExists(globalAttributeDefinitionKey);
verify(globalAttributeDefinitionLevelDao).getGlobalAttributeDefinitionLevel(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL);
verify(globalAttributeDefinitionDao).saveAndRefresh(any(GlobalAttributeDefinitionEntity.class));
verifyNoMoreInteractionsHelper();
// Validate the response.
assertEquals(new GlobalAttributeDefinition(GLOBAL_ATTRIBUTE_DEFINITON_ID, globalAttributeDefinitionKey, attributeValueListNull), response);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.
the class GlobalAttributeDefinitionDaoHelperTest method testValidateGlobalAttributeDefinitionNoExists.
@Test
public void testValidateGlobalAttributeDefinitionNoExists() {
// 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);
// Call the method under test.
globalAttributeDefinitionDaoHelper.validateGlobalAttributeDefinitionNoExists(globalAttributeDefinitionKey);
// 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 testValidateGlobalAttributeDefinitionNoExistsEntityExists.
@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);
}
Aggregations