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 / MapVersionToDtoTest.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.Date;
24 import java.util.Map;
25 import org.junit.Test;
26 import org.openecomp.sdc.versioning.dao.types.Version;
27 import org.openecomp.sdc.versioning.dao.types.VersionState;
28 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
29 import org.openecomp.sdcrests.item.types.VersionDto;
30
31 /**
32  * This class was generated.
33  */
34 public class MapVersionToDtoTest {
35
36     @Test()
37     public void testConversion() {
38
39         final Version source = new Version();
40
41         final String id = "2cb11529-5b9c-4561-a6d6-9188d3df84d6";
42         source.setId(id);
43
44         final String name = "c9798995-750d-4759-99ac-7942b24e356a";
45         source.setName(name);
46
47         final String description = "269d595d-e818-41d0-a991-bf6dccab8125";
48         source.setDescription(description);
49
50         final String baseId = "d8efa2d7-8def-4646-8b9d-363ae102cde0";
51         source.setBaseId(baseId);
52
53         final Date creationTime = new Date();
54         source.setCreationTime(creationTime);
55
56         final Date modificationTime = new Date();
57         source.setModificationTime(modificationTime);
58
59         final VersionStatus status = VersionStatus.Deleted;
60         source.setStatus(status);
61
62         final VersionState state = new VersionState();
63         source.setState(state);
64
65         final Map<String, Object> additionalInfo = Collections.emptyMap();
66         source.setAdditionalInfo(additionalInfo);
67
68         final VersionDto target = new VersionDto();
69         final MapVersionToDto mapper = new MapVersionToDto();
70         mapper.doMapping(source, target);
71
72         assertEquals(id, target.getId());
73         assertEquals(name, target.getName());
74         assertEquals(description, target.getDescription());
75         assertEquals(baseId, target.getBaseId());
76         assertSame(status, target.getStatus());
77         assertSame(state, target.getState());
78         assertEquals(creationTime, target.getCreationTime());
79         assertEquals(modificationTime, target.getModificationTime());
80         assertSame(additionalInfo, target.getAdditionalInfo());
81     }
82 }