blob: 5371fd70aff58f051cf4892f93009f7f2ac0e030 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package org.onap.sdc.workflow.api.mapping;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.sdc.workflow.persistence.types.Workflow;
import org.onap.sdc.workflow.persistence.types.WorkflowProperty;
import org.onap.sdc.workflow.services.mappers.WorkflowMapper;
import org.openecomp.sdc.versioning.types.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class WorkflowMapperTest {
@Configuration
@ComponentScan(basePackageClasses = {WorkflowMapper.class})
public static class WorkflowMapperSpringTestConfig { }
@Autowired
WorkflowMapper workflowMapper;
@Test
public void shouldMapItemPropertyToWorkflowCategory() {
Item item = createMockItem();
HashMap<String, Object> properties = new HashMap<>();
properties.put(WorkflowProperty.CATEGORY, "category");
item.setProperties(properties);
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));
}
private Item createMockItem() {
Item item = new Item();
item.setId("id");
item.setDescription("item description");
item.setName("item name");
return item;
}
}
|