Search in sources :

Example 11 with GlobalAttributeDefinitionKey

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

Example 12 with GlobalAttributeDefinitionKey

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);
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 13 with GlobalAttributeDefinitionKey

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

Example 14 with 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)));
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) GlobalAttributeDefinitionKey(org.finra.herd.model.api.xml.GlobalAttributeDefinitionKey) Test(org.junit.Test)

Example 15 with GlobalAttributeDefinitionKey

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