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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations