Unit-tests for mappers in item services
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / item-rest / item-rest-services / src / test / java / org / openecomp / sdcrests / item / rest / mapping / MapItemToDtoTest.java
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.openecomp.sdcrests.item.rest.mapping;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertSame;
21
22 import java.util.Collections;
23 import java.util.Map;
24 import org.junit.Test;
25 import org.openecomp.sdc.versioning.types.Item;
26 import org.openecomp.sdc.versioning.types.ItemStatus;
27 import org.openecomp.sdcrests.item.types.ItemDto;
28
29 /**
30  * This class was generated.
31  */
32 public class MapItemToDtoTest {
33
34     @Test
35     public void testConversion() {
36
37         final Item source = new Item();
38
39         final String id = "8c3cf5c1-956d-4701-9805-41ee7496a4b0";
40         source.setId(id);
41
42         final String type = "0df6dc63-30a9-453c-9d20-ccd839b30e55";
43         source.setType(type);
44
45         final String name = "fa425317-c53a-4ad2-94f5-9a33f2b76e67";
46         source.setName(name);
47
48         final String owner = "db08f579-7f4c-4d1a-ae92-a1c1c27c8cc6";
49         source.setOwner(owner);
50
51         final ItemStatus status = ItemStatus.ARCHIVED;
52         source.setStatus(status);
53
54         final String description = "9b5e29e9-b47a-4ece-b8a0-b68f4b346e3b";
55         source.setDescription(description);
56
57         final Map<String, Object> properties = Collections.emptyMap();
58         source.setProperties(properties);
59
60         final ItemDto target = new ItemDto();
61         final MapItemToDto mapper = new MapItemToDto();
62         mapper.doMapping(source, target);
63
64         assertEquals(id, target.getId());
65         assertEquals(type, target.getType());
66         assertEquals(name, target.getName());
67         assertEquals(description, target.getDescription());
68         assertEquals(owner, target.getOwner());
69         assertEquals(status.name(), target.getStatus());
70         assertSame(properties, target.getProperties());
71     }
72 }