723a2eff7ff566007c7f1a8de8a2d165e3c81d56
[sdc/sdc-workflow-designer.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.sdc.workflow.services.impl.mappers;
18
19
20 import static org.junit.Assert.assertEquals;
21 import static org.onap.sdc.workflow.TestUtil.createItem;
22 import static org.onap.sdc.workflow.TestUtil.createWorkflow;
23
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.onap.sdc.workflow.services.types.Workflow;
27 import org.onap.sdc.workflow.services.types.ArchivingStatus;
28 import org.openecomp.sdc.versioning.types.Item;
29 import org.openecomp.sdc.versioning.types.ItemStatus;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.context.annotation.ComponentScan;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.test.context.ContextConfiguration;
34 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
35
36 @ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
37 @RunWith(SpringJUnit4ClassRunner.class)
38 public class WorkflowMapperTest {
39
40     @Configuration
41     @ComponentScan(basePackageClasses = {WorkflowMapper.class})
42     public static class WorkflowMapperSpringTestConfig { }
43
44     @Autowired
45     WorkflowMapper workflowMapper;
46
47     @Test
48     public void shouldMapItemToWorkflow() {
49
50         Item item = createItem(1, false, true, ItemStatus.ACTIVE);
51         Workflow mappedWorkflow = workflowMapper.itemToWorkflow(item);
52         assertEquals(mappedWorkflow.getId(), item.getId());
53         assertEquals(mappedWorkflow.getDescription(), item.getDescription());
54         assertEquals(mappedWorkflow.getName(), item.getName());
55         assertEquals(mappedWorkflow.getArchiving().name(), item.getStatus().name());
56     }
57
58     @Test
59     public void shouldMapWorkflowToItem() {
60
61         Workflow workflow = createWorkflow(1, true, ArchivingStatus.ARCHIVED);
62         Item mappedItem = workflowMapper.workflowToItem(workflow);
63         assertEquals(mappedItem.getId(), workflow.getId());
64         assertEquals(mappedItem.getDescription(), workflow.getDescription());
65         assertEquals(mappedItem.getName(), workflow.getName());
66         assertEquals(mappedItem.getStatus().name(), workflow.getArchiving().name());
67     }
68
69 }