use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest in project herd by FINRAOS.
the class GlobalAttributeDefinitionRestControllerTest 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.
GlobalAttributeDefinition globalAttributeDefinition = new GlobalAttributeDefinition();
// Mock calls to external methods.
when(globalAttributeDefinitionService.createGlobalAttributeDefinition(request)).thenReturn(globalAttributeDefinition);
// Call the method under test.
GlobalAttributeDefinition response = globalAttributeDefinitionRestController.createGlobalAttributeDefinition(request);
// Verify the external calls.
verify(globalAttributeDefinitionService).createGlobalAttributeDefinition(request);
verifyNoMoreInteractions(globalAttributeDefinitionService);
// Validate the response.
assertEquals(globalAttributeDefinition, response);
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest in project herd by FINRAOS.
the class GlobalAttributeDefinitionServiceTest method testCreateGlobalAttributeDefinitionInvalidGlobalAttributeDefinitionLevel.
@Test
public void testCreateGlobalAttributeDefinitionInvalidGlobalAttributeDefinitionLevel() {
// Create a global attribute definition key with an unsupported global attribute definition level.
GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_INVALID_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
// Create a global attribute definition create request.
GlobalAttributeDefinitionCreateRequest request = new GlobalAttributeDefinitionCreateRequest(globalAttributeDefinitionKey, attributeValueListKeyNull);
// Try to call the method under test.
try {
globalAttributeDefinitionService.createGlobalAttributeDefinition(request);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("Global attribute definition with level \"%s\" is not supported.", GLOBAL_ATTRIBUTE_DEFINITON_INVALID_LEVEL), e.getMessage());
}
// Verify the external calls.
verify(globalAttributeDefinitionHelper).validateGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest 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);
}
Aggregations