1 package org.onap.sdc.workflow.services.impl.mappers;
4 import static org.junit.Assert.assertEquals;
5 import static org.onap.sdc.workflow.TestUtil.createItem;
6 import static org.onap.sdc.workflow.TestUtil.createWorkflow;
9 import org.junit.runner.RunWith;
10 import org.onap.sdc.workflow.services.types.Workflow;
11 import org.onap.sdc.workflow.services.types.ArchivingStatus;
12 import org.openecomp.sdc.versioning.types.Item;
13 import org.openecomp.sdc.versioning.types.ItemStatus;
14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.context.annotation.ComponentScan;
16 import org.springframework.context.annotation.Configuration;
17 import org.springframework.test.context.ContextConfiguration;
18 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20 @ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
21 @RunWith(SpringJUnit4ClassRunner.class)
22 public class WorkflowMapperTest {
25 @ComponentScan(basePackageClasses = {WorkflowMapper.class})
26 public static class WorkflowMapperSpringTestConfig { }
29 WorkflowMapper workflowMapper;
32 public void shouldMapItemToWorkflow() {
34 Item item = createItem(1, false, true, ItemStatus.ACTIVE);
35 Workflow mappedWorkflow = workflowMapper.itemToWorkflow(item);
36 assertEquals(mappedWorkflow.getId(), item.getId());
37 assertEquals(mappedWorkflow.getDescription(), item.getDescription());
38 assertEquals(mappedWorkflow.getName(), item.getName());
39 assertEquals(mappedWorkflow.getArchiving().name(), item.getStatus().name());
43 public void shouldMapWorkflowToItem() {
45 Workflow workflow = createWorkflow(1, true, ArchivingStatus.ARCHIVED);
46 Item mappedItem = workflowMapper.workflowToItem(workflow);
47 assertEquals(mappedItem.getId(), workflow.getId());
48 assertEquals(mappedItem.getDescription(), workflow.getDescription());
49 assertEquals(mappedItem.getName(), workflow.getName());
50 assertEquals(mappedItem.getStatus().name(), workflow.getArchiving().name());