843e89e11f98e962055c7a2b9e17825b000912be
[sdc/sdc-workflow-designer.git] /
1 package org.onap.sdc.workflow.services.impl.mappers;
2
3
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;
7
8 import org.junit.Test;
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;
19
20 @ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
21 @RunWith(SpringJUnit4ClassRunner.class)
22 public class WorkflowMapperTest {
23
24     @Configuration
25     @ComponentScan(basePackageClasses = {WorkflowMapper.class})
26     public static class WorkflowMapperSpringTestConfig { }
27
28     @Autowired
29     WorkflowMapper workflowMapper;
30
31     @Test
32     public void shouldMapItemToWorkflow() {
33
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());
40     }
41
42     @Test
43     public void shouldMapWorkflowToItem() {
44
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());
51     }
52
53 }