Search in sources :

Example 1 with AttributeValueList

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

the class AttributeValueListDaoHelper method createAttributeValueListFromEntity.

/**
 * Creates the attribute value list from the persisted entity.
 *
 * @param attributeValueListEntity the attribute value list entity
 *
 * @return the attribute value list
 */
public AttributeValueList createAttributeValueListFromEntity(AttributeValueListEntity attributeValueListEntity) {
    // Create the attribute value list.
    AttributeValueList attributeValueList = new AttributeValueList();
    AttributeValueListKey attributeValueListKey = new AttributeValueListKey();
    attributeValueListKey.setNamespace(attributeValueListEntity.getNamespace().getCode());
    attributeValueListKey.setAttributeValueListName(attributeValueListEntity.getName());
    attributeValueList.setAttributeValueListKey(attributeValueListKey);
    attributeValueList.setId(attributeValueListEntity.getId());
    return attributeValueList;
}
Also used : AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey)

Example 2 with AttributeValueList

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

the class AttributeValueListServiceTest method testDeleteAttributeValueList.

@Test
public void testDeleteAttributeValueList() {
    // Create an attribute value list key.
    AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
    // Create a namespace entity.
    NamespaceEntity namespaceEntity = new NamespaceEntity();
    namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE);
    // Create an attribute value list entity.
    AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity();
    attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID);
    attributeValueListEntity.setNamespace(namespaceEntity);
    attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME);
    // Mock calls to external methods.
    when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity);
    when(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)).thenCallRealMethod();
    // Call the method under test.
    AttributeValueList result = attributeValueListService.deleteAttributeValueList(attributeValueListKey);
    // Verify the external calls.
    verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
    verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey);
    verify(attributeValueListDao).delete(attributeValueListEntity);
    verify(attributeValueListDaoHelper).createAttributeValueListFromEntity(attributeValueListEntity);
    verifyNoMoreInteractionsHelper();
    // Validate the result.
    assertEquals(new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey), result);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Example 3 with AttributeValueList

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

the class AttributeValueListServiceTest method testGetAttributeValueList.

@Test
public void testGetAttributeValueList() {
    // Create an attribute value list key.
    AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
    // Create a namespace entity.
    NamespaceEntity namespaceEntity = new NamespaceEntity();
    namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE);
    // Create an attribute value list entity.
    AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity();
    attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID);
    attributeValueListEntity.setNamespace(namespaceEntity);
    attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME);
    // Mock calls to external methods.
    when(attributeValueListDaoHelper.getAttributeValueListEntity(attributeValueListKey)).thenReturn(attributeValueListEntity);
    when(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)).thenCallRealMethod();
    // Call the method under test.
    AttributeValueList result = attributeValueListService.getAttributeValueList(attributeValueListKey);
    // Verify the external calls.
    verify(attributeValueListHelper).validateAttributeValueListKey(attributeValueListKey);
    verify(attributeValueListDaoHelper).getAttributeValueListEntity(attributeValueListKey);
    verify(attributeValueListDaoHelper).createAttributeValueListFromEntity(attributeValueListEntity);
    verifyNoMoreInteractionsHelper();
    // Validate the result.
    assertEquals(new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey), result);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Example 4 with AttributeValueList

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

the class AttributeValueListServiceTest method createAttributeValueList.

@Test
public void createAttributeValueList() {
    // Create an attribute value list key.
    AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
    // Create an attribute value list create request.
    AttributeValueListCreateRequest request = new AttributeValueListCreateRequest(attributeValueListKey);
    // Create a namespace entity.
    NamespaceEntity namespaceEntity = new NamespaceEntity();
    namespaceEntity.setCode(ATTRIBUTE_VALUE_LIST_NAMESPACE);
    // Create an attribute value list entity.
    AttributeValueListEntity attributeValueListEntity = new AttributeValueListEntity();
    attributeValueListEntity.setId(ATTRIBUTE_VALUE_LIST_ID);
    attributeValueListEntity.setNamespace(namespaceEntity);
    attributeValueListEntity.setName(ATTRIBUTE_VALUE_LIST_NAME);
    // Mock calls to external methods.
    when(namespaceDaoHelper.getNamespaceEntity(ATTRIBUTE_VALUE_LIST_NAMESPACE)).thenReturn(namespaceEntity);
    when(attributeValueListDao.getAttributeValueListByKey(attributeValueListKey)).thenReturn(null);
    when(attributeValueListDao.saveAndRefresh(any(AttributeValueListEntity.class))).thenReturn(attributeValueListEntity);
    when(attributeValueListDaoHelper.createAttributeValueListFromEntity(attributeValueListEntity)).thenCallRealMethod();
    // Call the method under test.
    AttributeValueList result = attributeValueListService.createAttributeValueList(request);
    // Verify the external calls.
    verify(attributeValueListHelper).validateAttributeValueListCreateRequest(request);
    verify(namespaceDaoHelper).getNamespaceEntity(ATTRIBUTE_VALUE_LIST_NAMESPACE);
    verify(attributeValueListDao).getAttributeValueListByKey(attributeValueListKey);
    verify(attributeValueListDao).saveAndRefresh(any(AttributeValueListEntity.class));
    verify(attributeValueListDaoHelper).createAttributeValueListFromEntity(attributeValueListEntity);
    verifyNoMoreInteractionsHelper();
    // Validate the result.
    assertEquals(new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey), result);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListCreateRequest(org.finra.herd.model.api.xml.AttributeValueListCreateRequest) AttributeValueListEntity(org.finra.herd.model.jpa.AttributeValueListEntity) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Example 5 with AttributeValueList

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

the class AttributeValueListRestControllerTest method testCreateAttributeValueList.

@Test
public void testCreateAttributeValueList() {
    // Create an attribute value list key.
    AttributeValueListKey attributeValueListKey = new AttributeValueListKey(ATTRIBUTE_VALUE_LIST_NAMESPACE, ATTRIBUTE_VALUE_LIST_NAME);
    // Create an attribute value list.
    AttributeValueList attributeValueList = new AttributeValueList(ATTRIBUTE_VALUE_LIST_ID, attributeValueListKey);
    // Create an attribute value list create request.
    AttributeValueListCreateRequest request = new AttributeValueListCreateRequest(attributeValueListKey);
    // Mock calls to external methods.
    when(attributeValueListService.createAttributeValueList(request)).thenReturn(attributeValueList);
    // Call the method under test.
    AttributeValueList result = attributeValueListRestController.createAttributeValueList(request);
    // Verify the external calls.
    verify(attributeValueListService).createAttributeValueList(request);
    verifyNoMoreInteractions(attributeValueListService);
    // Validate the result.
    assertEquals(attributeValueList, result);
}
Also used : AttributeValueList(org.finra.herd.model.api.xml.AttributeValueList) AttributeValueListCreateRequest(org.finra.herd.model.api.xml.AttributeValueListCreateRequest) AttributeValueListKey(org.finra.herd.model.api.xml.AttributeValueListKey) Test(org.junit.Test)

Aggregations

AttributeValueList (org.finra.herd.model.api.xml.AttributeValueList)7 AttributeValueListKey (org.finra.herd.model.api.xml.AttributeValueListKey)7 Test (org.junit.Test)6 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)3 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)3 AttributeValueListCreateRequest (org.finra.herd.model.api.xml.AttributeValueListCreateRequest)2