diff options
author | 2018-06-27 12:41:14 +0300 | |
---|---|---|
committer | 2018-06-27 14:37:16 +0300 | |
commit | 2dc593aabe936a21783d7d4e6b7475cab59be6a9 (patch) | |
tree | e4cea88a5b3a1b55ee5af52122f9b669589b326d | |
parent | e9d97234f17d8ecdbfc0481d6a2ba2698d52ddd0 (diff) |
Service layer unit tests
Change-Id: Ia1c87e81feab7b918a7af52ee1f52914e253dc09
Issue-ID: SDC-1445
Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
13 files changed, 264 insertions, 167 deletions
diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java index 76a6591c..8c66d820 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/persistence/types/Workflow.java @@ -9,5 +9,4 @@ public class Workflow { private String id; private String name; private String description; - private String category; } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java index d98a15d7..3bf86ad1 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/exceptions/VersionNotFoundException.java @@ -4,4 +4,5 @@ public class VersionNotFoundException extends RuntimeException { public VersionNotFoundException(String workflowId, String versioId) { super(String.format("version with id '%s' does not exist for workflow with id %s",versioId,workflowId)); - } } + } +} diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java index aa4bb6f6..8bb5f709 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowManagerImpl.java @@ -1,6 +1,7 @@ package org.onap.sdc.workflow.services.impl; import java.util.Collection; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.onap.sdc.workflow.services.mappers.WorkflowMapper; import org.onap.sdc.workflow.persistence.types.Workflow; @@ -18,6 +19,7 @@ import org.springframework.stereotype.Service; public class WorkflowManagerImpl implements WorkflowManager { private static final String WORKFLOW_TYPE = "WORKFLOW"; + protected static final Predicate<Item> ITEM_PREDICATE = item -> WORKFLOW_TYPE.equals(item.getType()); private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME"; private final ItemManager itemManager; private final UniqueValueService uniqueValueService; @@ -33,7 +35,7 @@ public class WorkflowManagerImpl implements WorkflowManager { @Override public Collection<Workflow> list() { - return itemManager.list(item -> WORKFLOW_TYPE.equals(item.getType())).stream() + return itemManager.list(ITEM_PREDICATE).stream() .map(item -> workflowMapper.itemToWorkflow(item)).collect(Collectors.toList()); } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java index cda17914..b0a14fd6 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerImpl.java @@ -3,7 +3,6 @@ package org.onap.sdc.workflow.services.impl; import java.util.Collection; import java.util.List; import java.util.Objects; -import java.util.Optional; import org.onap.sdc.workflow.services.WorkflowVersionManager; import org.onap.sdc.workflow.services.exceptions.VersionNotFoundException; import org.openecomp.sdc.versioning.VersioningManager; @@ -50,11 +49,9 @@ public class WorkflowVersionManagerImpl implements WorkflowVersionManager { versioningManager.updateVersion(id,version); } - private Version getLatestVersion(String itemId) { + protected Version getLatestVersion(String itemId) { List<Version> list = versioningManager.list(itemId); - Optional<Version> max = list.stream().max(Version::compareTo); - - return max.orElse(null); + return list.stream().max(Version::compareTo).orElse(null); } } diff --git a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java index c603908b..5615b861 100644 --- a/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java +++ b/workflow-designer-be/src/main/java/org/onap/sdc/workflow/services/mappers/WorkflowMapper.java @@ -1,32 +1,17 @@ package org.onap.sdc.workflow.services.mappers; -import java.util.Collections; -import java.util.Map; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; import org.onap.sdc.workflow.persistence.types.Workflow; -import org.onap.sdc.workflow.persistence.types.WorkflowProperty; import org.openecomp.sdc.versioning.types.Item; @Mapper(componentModel = "spring") public interface WorkflowMapper { - @Mapping(source = "properties", target = "category", qualifiedByName = "propertiesToCategoryMapper") Workflow itemToWorkflow(Item item); - @Mapping(source = "category", target = "properties", qualifiedByName = "categoryToPropertiesMapper") + @InheritInverseConfiguration Item workflowToItem(Workflow workflow); - @Named("propertiesToCategoryMapper") - default String customPropertiesToCategoryMapper(Map<String, Object> properties) { - return String.class.cast(properties.get(WorkflowProperty.CATEGORY)); - } - - @Named("categoryToPropertiesMapper") - default Map<String, Object> customCategoryToPropertiesMapper(String category) { - return Collections.singletonMap(WorkflowProperty.CATEGORY, category); - } } diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java new file mode 100644 index 00000000..47ce060b --- /dev/null +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/TestUtil.java @@ -0,0 +1,38 @@ +package org.onap.sdc.workflow; + +import org.onap.sdc.workflow.persistence.types.Workflow; +import org.openecomp.sdc.versioning.types.Item; + +public class TestUtil { + + private static final String WORKFLOW_TYPE = "WORKFLOW"; + + public static Workflow createWorkflow(int workflowPropertySuffix, boolean createId) { + Workflow workflow = new Workflow(); + if (createId) { + workflow.setId("workflowId" + workflowPropertySuffix); + } + workflow.setName("workflowName" + workflowPropertySuffix); + workflow.setDescription("workflowDesc" + workflowPropertySuffix); + + return workflow; + } + + public static Item createItem(int itemNum,boolean setType, boolean setId){ + Item item = new Item(); + if(setId) { + item.setId("workflowId" + itemNum); + } + item.addProperty("category","category_" + itemNum); + item.setName("Workflow_" + itemNum); + item.setDescription("Description_" + itemNum); + if(setType) { + item.setType(WORKFLOW_TYPE); + } + + return item; + } + + + +} diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java index 0885d476..eb579148 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java @@ -23,6 +23,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import static org.onap.sdc.workflow.TestUtil.createWorkflow; import org.onap.sdc.workflow.api.impl.WorkflowControllerImpl; import org.onap.sdc.workflow.persistence.types.Workflow; import org.onap.sdc.workflow.services.WorkflowManager; @@ -117,14 +118,5 @@ public class WorkflowControllerTest { return workflowList; } - private Workflow createWorkflow(int workflowPropertySuffix, boolean createId) { - Workflow workflow = new Workflow(); - if (createId) { - workflow.setId("workflowId" + workflowPropertySuffix); - } - workflow.setName("workflowName" + workflowPropertySuffix); - workflow.setDescription("workflowDesc" + workflowPropertySuffix); - return workflow; - } }
\ No newline at end of file diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java index 96c31c82..b47d2f37 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowVersionControllerTest.java @@ -16,9 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import com.google.gson.Gson; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.Before; import org.junit.Test; diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/WorkflowMapperTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/WorkflowMapperTest.java index 5371fd70..53f63091 100644 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/WorkflowMapperTest.java +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/mapping/WorkflowMapperTest.java @@ -3,6 +3,8 @@ package org.onap.sdc.workflow.api.mapping; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.onap.sdc.workflow.TestUtil.createItem; +import static org.onap.sdc.workflow.TestUtil.createWorkflow; import java.util.HashMap; import org.junit.Test; @@ -29,36 +31,23 @@ public class WorkflowMapperTest { WorkflowMapper workflowMapper; @Test - public void shouldMapItemPropertyToWorkflowCategory() { - - Item item = createMockItem(); - HashMap<String, Object> properties = new HashMap<>(); - properties.put(WorkflowProperty.CATEGORY, "category"); - item.setProperties(properties); + public void shouldMapItemToWorkflow() { + Item item = createItem(1,false,true); Workflow mappedWorkflow = workflowMapper.itemToWorkflow(item); assertEquals(mappedWorkflow.getId(), item.getId()); assertEquals(mappedWorkflow.getDescription(), item.getDescription()); assertEquals(mappedWorkflow.getName(), item.getName()); - assertEquals(mappedWorkflow.getCategory(), properties.get(WorkflowProperty.CATEGORY)); } @Test - public void shouldAddWorkflowCategoryToItemProperties(){ - Workflow workflow = new Workflow(); - workflow.setId("id"); - workflow.setCategory("cat"); - - Item item = workflowMapper.workflowToItem(workflow); - assertNotNull(item.getProperties().get(WorkflowProperty.CATEGORY)); - } + public void shouldMapWorkflowToItem(){ - private Item createMockItem() { - Item item = new Item(); - item.setId("id"); - item.setDescription("item description"); - item.setName("item name"); - return item; + Workflow workflow = createWorkflow(1,true); + Item mappedItem = workflowMapper.workflowToItem(workflow); + assertEquals(mappedItem.getId(), workflow.getId()); + assertEquals(mappedItem.getDescription(), workflow.getDescription()); + assertEquals(mappedItem.getName(), workflow.getName()); } }
\ No newline at end of file diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowManagerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowManagerTest.java deleted file mode 100644 index 02035a12..00000000 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowManagerTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.onap.sdc.workflow.services; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdc.workflow.services.impl.WorkflowManagerImpl; -import org.openecomp.sdc.versioning.ItemManager; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -@RunWith(MockitoJUnitRunner.class) -public class WorkflowManagerTest { - - private MockMvc mockMvc; - - @Mock - private ItemManager itemManager; - - @Mock - private UniqueValueService uniqueValueService; - - @InjectMocks - private WorkflowManagerImpl workflowManager; - - - @Before - public void setUp(){ - mockMvc = MockMvcBuilders.standaloneSetup(workflowManager).build(); - } - - - @Test - public void testCreate(){ - - } - -} diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowVersionManagerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowVersionManagerTest.java deleted file mode 100644 index d9031265..00000000 --- a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/WorkflowVersionManagerTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.onap.sdc.workflow.services; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Arrays; -import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.sdc.workflow.api.RestConstants; -import org.onap.sdc.workflow.services.impl.WorkflowVersionManagerImpl; -import org.openecomp.sdc.versioning.VersioningManager; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; - -@RunWith(MockitoJUnitRunner.class) -public class WorkflowVersionManagerTest { - - private static final String USER_ID = "cs0008"; - private static final String ITEM1_ID = "item_id_1"; - private static final String VERSION1_ID = "version_id_1"; - private static final String VERSION2_ID = "version_id_2"; - private List<Version> versionList; - - @Mock - private static VersioningManager versioningManagerMock; - - @TestConfiguration - static class WorkflowVersionManagerTestContextConfiguration { - - @Bean - public WorkflowVersionManager WorkflowVersionManagerImpl() { - return new WorkflowVersionManagerImpl(versioningManagerMock); - } - } - - @Autowired - private WorkflowVersionManager workflowVersionManager; - - - - @Before - public void setUp(){ - versionList = Arrays.asList( new Version(VERSION1_ID),new Version(VERSION2_ID)); - - } - - - @Test - public void shouldReturnWorkflowVersionList(){ - - - } - -} diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerTest.java new file mode 100644 index 00000000..31da825a --- /dev/null +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowManagerTest.java @@ -0,0 +1,122 @@ +package org.onap.sdc.workflow.services.impl; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.onap.sdc.workflow.TestUtil.createItem; +import static org.onap.sdc.workflow.TestUtil.createWorkflow; + +import java.util.Arrays; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.onap.sdc.workflow.persistence.types.Workflow; +import org.onap.sdc.workflow.services.UniqueValueService; +import org.onap.sdc.workflow.services.exceptions.WorkflowNotFoundException; +import org.onap.sdc.workflow.services.mappers.WorkflowMapper; +import org.openecomp.sdc.versioning.ItemManager; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdc.versioning.types.ItemStatus; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +public class WorkflowManagerTest { + + private static final String ITEM1_ID = "workflowId1"; + private static final String ITEM2_ID = "workflowId2"; + private static final String WORKFLOW_TYPE = "WORKFLOW"; + private static final String WORKFLOW_NAME_UNIQUE_TYPE = "WORKFLOW_NAME"; + private List<Item> itemList; + + @Mock + WorkflowMapper workflowMapperMock; + + @Mock + private ItemManager itemManagerMock; + + @Mock + private UniqueValueService uniqueValueServiceMock; + + @InjectMocks + private WorkflowManagerImpl workflowManager; + + + + @Before + public void setUp(){ + itemList = Arrays.asList(createItem(1,true,true), + createItem(2,true,true),createItem(3,true,true)); + + } + + + @Test + public void shouldReturnWorkflowVersionList(){ + + doReturn(itemList).when(itemManagerMock).list(workflowManager.ITEM_PREDICATE); + workflowManager.list(); + verify(itemManagerMock).list(workflowManager.ITEM_PREDICATE); + } + + @Test(expected = WorkflowNotFoundException.class) + public void shouldThrowExceptionWhenWorkflowDontExist(){ + Workflow nonExistingWorkflow = new Workflow(); + nonExistingWorkflow.setId(ITEM1_ID); + doReturn(null).when(itemManagerMock).get(ITEM1_ID); + workflowManager.get(nonExistingWorkflow); + verify(workflowMapperMock,times(3)).itemToWorkflow(any(Item.class)); + } + + @Test + public void shouldReturnWorkflow(){ + Item retrievedItem = createItem(1,true,true); + doReturn(retrievedItem).when(itemManagerMock).get(ITEM1_ID); + Workflow workflow = createWorkflow(1,true); + workflowManager.get(workflow); + verify(itemManagerMock).get(ITEM1_ID); + verify(workflowMapperMock).itemToWorkflow(retrievedItem); + + + } + + @Test + public void shouldCreateWorkflow() { + Workflow workflowToBeCreated = createWorkflow(1, false); + Item createdWorkflowItem = createItem(1, false, true); + doReturn(createdWorkflowItem).when(workflowMapperMock).workflowToItem(workflowToBeCreated); + doReturn(createdWorkflowItem).when(itemManagerMock).create(createdWorkflowItem); + workflowManager.create(workflowToBeCreated); + verify(uniqueValueServiceMock) + .validateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflowToBeCreated.getName()}); + + createdWorkflowItem.setStatus(ItemStatus.ACTIVE); + createdWorkflowItem.setType(WORKFLOW_TYPE); + verify(itemManagerMock).create(createdWorkflowItem); + verify(uniqueValueServiceMock) + .createUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE, new String[] {workflowToBeCreated.getName()}); + } + + @Test + public void shouldUpdateWorkflow(){ + Item workflowItem = createItem(1, true, true); + doReturn(workflowItem).when(itemManagerMock).get(ITEM1_ID); + Workflow workflowToBeUpdated = createWorkflow(1, true); + doReturn(workflowItem).when(workflowMapperMock).workflowToItem(workflowToBeUpdated); + workflowManager.update(workflowToBeUpdated); + verify(itemManagerMock).update(workflowItem); + verify(uniqueValueServiceMock) + .updateUniqueValue(WORKFLOW_NAME_UNIQUE_TYPE,workflowItem.getName(),workflowToBeUpdated.getName()); + + } + + @Test(expected = WorkflowNotFoundException.class) + public void shouldThrowExceptionWhenWorkflowToUpdateNotFound(){ + doReturn(null).when(itemManagerMock).get(ITEM1_ID); + workflowManager.update(createWorkflow(1, true)); + } + +} diff --git a/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java new file mode 100644 index 00000000..d805a2b2 --- /dev/null +++ b/workflow-designer-be/src/test/java/org/onap/sdc/workflow/services/impl/WorkflowVersionManagerTest.java @@ -0,0 +1,85 @@ +package org.onap.sdc.workflow.services.impl; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.verify; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdc.workflow.services.exceptions.VersionNotFoundException; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionCreationMethod; + +@RunWith(MockitoJUnitRunner.class) +public class WorkflowVersionManagerTest { + + + private static final String ITEM1_ID = "item_id_1"; + private static final String VERSION1_ID = "version_id_1"; + private static final String VERSION2_ID = "version_id_2"; + private List<Version> versionList; + + @Mock + private VersioningManager versioningManagerMock; + + @Spy + @InjectMocks + private WorkflowVersionManagerImpl workflowVersionManager; + + @Before + public void setUp(){ + versionList = Arrays.asList( new Version(VERSION1_ID),new Version(VERSION2_ID)); + } + + + @Test(expected = VersionNotFoundException.class) + public void shouldThrowExceptionWhenVersionDontExist(){ + Version nonExistingVersion = new Version(VERSION1_ID); + doThrow(new RuntimeException()).when(versioningManagerMock).get(ITEM1_ID, nonExistingVersion); + workflowVersionManager.get(ITEM1_ID, nonExistingVersion); + } + + @Test + public void shouldReturnWorkflowVersion(){ + Version version = new Version(VERSION1_ID); + doReturn(version).when(versioningManagerMock).get(ITEM1_ID,version); + workflowVersionManager.get(ITEM1_ID,version); + verify(versioningManagerMock).get(ITEM1_ID,version); + } + + @Test + public void shouldReturnWorkflowVersionList(){ + doReturn(versionList).when(versioningManagerMock).list(ITEM1_ID); + Collection<Version> result = workflowVersionManager.list(ITEM1_ID); + verify(versioningManagerMock).list(ITEM1_ID); + assertEquals(versionList,result); + } + + @Test + public void shouldUpdateWorkflowVersion(){ + Version version = new Version(VERSION1_ID); + workflowVersionManager.update(ITEM1_ID,version); + verify(versioningManagerMock).updateVersion(ITEM1_ID,version); + } + + @Test + public void shouldCreateWorkflowVersion(){ + Version version = new Version(); + workflowVersionManager.create(ITEM1_ID,version); + verify(versioningManagerMock).create(ITEM1_ID,version, VersionCreationMethod.major); + verify(workflowVersionManager).getLatestVersion(ITEM1_ID); + } + + + +} |