Search in sources :

Example 1 with GlobalAttributeDefinitionKey

use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.

the class GlobalAttributeDefinitionServiceImpl method createGlobalAttributeDefinitionFromEntity.

private GlobalAttributeDefinition createGlobalAttributeDefinitionFromEntity(GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity) {
    GlobalAttributeDefinition globalAttributeDefinition = new GlobalAttributeDefinition();
    globalAttributeDefinition.setId(globalAttributeDefinitionEntity.getId());
    GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey();
    globalAttributeDefinitionKey.setGlobalAttributeDefinitionLevel(globalAttributeDefinitionEntity.getGlobalAttributeDefinitionLevel().getGlobalAttributeDefinitionLevel());
    globalAttributeDefinitionKey.setGlobalAttributeDefinitionName(globalAttributeDefinitionEntity.getGlobalAttributeDefinitionName());
    globalAttributeDefinition.setGlobalAttributeDefinitionKey(globalAttributeDefinitionKey);
    AttributeValueListEntity attributeValueListEntity = globalAttributeDefinitionEntity.getAttributeValueList();
    if (attributeValueListEntity != null) {
        globalAttributeDefinition.setAttributeValueList(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity));
    }
    return globalAttributeDefinition;
}
Also used : GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) GlobalAttributeDefinition(org.finra.herd.model.api.xml.GlobalAttributeDefinition)

Example 2 with GlobalAttributeDefinitionKey

use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey 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);
}
Also used : GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) GlobalAttributeDefinitionCreateRequest(org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest) GlobalAttributeDefinition(org.finra.herd.model.api.xml.GlobalAttributeDefinition) Test(org.junit.Test)

Example 3 with GlobalAttributeDefinitionKey

use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.

the class GlobalAttributeDefinitionRestControllerTest 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.
    GlobalAttributeDefinition globalAttributeDefinition = new GlobalAttributeDefinition(INTEGER_VALUE, globalAttributeDefinitionKey, attributeValueListNull);
    // Mock calls to external methods.
    when(globalAttributeDefinitionService.deleteGlobalAttributeDefinition(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinition);
    // Call the method under test.
    GlobalAttributeDefinition response = globalAttributeDefinitionRestController.deleteGlobalAttributeDefinition(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    // Verify the external calls.
    verify(globalAttributeDefinitionService).deleteGlobalAttributeDefinition(globalAttributeDefinitionKey);
    verifyNoMoreInteractions(globalAttributeDefinitionService);
    // Validate the response.
    assertEquals(globalAttributeDefinition, response);
}
Also used : GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) GlobalAttributeDefinition(org.finra.herd.model.api.xml.GlobalAttributeDefinition) Test(org.junit.Test)

Example 4 with GlobalAttributeDefinitionKey

use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey in project herd by FINRAOS.

the class GlobalAttributeDefinitionRestControllerTest method testGetGlobalAttributeDefinition.

@Test
public void testGetGlobalAttributeDefinition() {
    // Create a global attribute definition key.
    GlobalAttributeDefinitionKey globalAttributeDefinitionKey = new GlobalAttributeDefinitionKey(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    // Create a global attribute definition.
    GlobalAttributeDefinition globalAttributeDefinition = new GlobalAttributeDefinition(INTEGER_VALUE, globalAttributeDefinitionKey, attributeValueListNull);
    // Mock calls to external methods.
    when(globalAttributeDefinitionService.getGlobalAttributeDefinition(globalAttributeDefinitionKey)).thenReturn(globalAttributeDefinition);
    // Call the method under test.
    GlobalAttributeDefinition response = globalAttributeDefinitionRestController.getGlobalAttributeDefinition(GLOBAL_ATTRIBUTE_DEFINITON_LEVEL, GLOBAL_ATTRIBUTE_DEFINITON_NAME);
    // Verify the external calls.
    verify(globalAttributeDefinitionService).getGlobalAttributeDefinition(globalAttributeDefinitionKey);
    verifyNoMoreInteractions(globalAttributeDefinitionService);
    // Validate the response.
    assertEquals(globalAttributeDefinition, response);
}
Also used : GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) GlobalAttributeDefinition(org.finra.herd.model.api.xml.GlobalAttributeDefinition) Test(org.junit.Test)

Example 5 with GlobalAttributeDefinitionKey

use of org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey 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();
}
Also used : GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) GlobalAttributeDefinitionCreateRequest(org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest) Test(org.junit.Test)

Aggregations

GlobalAttributeDefinitionKey (org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey)20 Test (org.junit.Test)16 GlobalAttributeDefinition (org.finra.herd.model.api.xml.GlobalAttributeDefinition)7 GlobalAttributeDefinitionEntity (org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity)7 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)5 GlobalAttributeDefinitionCreateRequest (org.finra.herd.model.api.xml.GlobalAttributeDefinitionCreateRequest)3 GlobalAttributeDefinitionKeys (org.finra.herd.model.api.xml.GlobalAttributeDefinitionKeys)3 ArrayList (java.util.ArrayList)2 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)2 GlobalAttributeDefinitionLevelEntity (org.finra.herd.model.jpa.GlobalAttributeDefinitionLevelEntity)2 Tuple (javax.persistence.Tuple)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1