2 * Copyright © 2016-2018 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.onap.sdc.workflow.services.impl.mappers;
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;
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;
36 @ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
37 @RunWith(SpringJUnit4ClassRunner.class)
38 public class WorkflowMapperTest {
41 @ComponentScan(basePackageClasses = {WorkflowMapper.class})
42 public static class WorkflowMapperSpringTestConfig { }
45 WorkflowMapper workflowMapper;
48 public void shouldMapItemToWorkflow() {
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());
59 public void shouldMapWorkflowToItem() {
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());