6a6ae363f7fd52e5084f03871ce24269f38bc495
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-license-rest / vendor-license-rest-services / src / test / java / org / openecomp / sdcrests / vendorlicense / rest / mapping / MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest.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.vendorlicense.rest.mapping;
18
19 import static org.testng.Assert.assertEquals;
20
21 import java.util.Collections;
22 import java.util.HashSet;
23 import java.util.Set;
24 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
25 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
26 import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
27 import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
28 import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
29 import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
30 import org.testng.annotations.Test;
31
32
33 public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest {
34
35     @Test
36     public void testReferencingFeatureGroups() {
37         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
38         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
39         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
40                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
41         Set<String> param = new HashSet<>(Collections.singletonList("c7797917-7548-44c2-93b9-cf72f27bca3f"));
42         source.setReferencingFeatureGroups(param);
43         mapper.doMapping(source, target);
44         assertEquals(target.getReferencingFeatureGroups(), param);
45     }
46
47     @Test
48     public void testDescription() {
49         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
50         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
51         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
52                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
53         String param = "f026c265-d91f-4c47-8f3b-2600be5023dc";
54         source.setDescription(param);
55         mapper.doMapping(source, target);
56         assertEquals(target.getDescription(), param);
57     }
58
59     @Test
60     public void testType() {
61         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
62         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
63         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
64                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
65         LicenseKeyType licenseKeyType = LicenseKeyType.Universal;
66         source.setType(licenseKeyType);
67         mapper.doMapping(source, target);
68         assertEquals(target.getType(), licenseKeyType);
69     }
70
71     @Test
72     public void testIncrements() {
73         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
74         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
75         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
76                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
77         String param = "813639e7-45d6-4443-8a7c-a955d34a931a";
78         source.setIncrements(param);
79         mapper.doMapping(source, target);
80         assertEquals(target.getIncrements(), param);
81     }
82
83     @Test
84     public void testExpiryDate() {
85         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
86         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
87         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
88                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
89         String param = "d7925c8e-239f-44a3-9b24-67ddbd9467c2";
90         source.setExpiryDate(param);
91         mapper.doMapping(source, target);
92         assertEquals(target.getExpiryDate(), param);
93     }
94
95     @Test
96     public void testId() {
97         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
98         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
99         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
100                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
101         String param = "b2f35aa5-0240-46b7-bade-35890d46e9f9";
102         source.setId(param);
103         mapper.doMapping(source, target);
104         assertEquals(target.getId(), param);
105     }
106
107     @Test
108     public void testThresholdUnits() {
109         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
110         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
111         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
112                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
113         ThresholdUnit thresholdUnit = ThresholdUnit.Absolute;
114         source.setThresholdUnits(thresholdUnit);
115         mapper.doMapping(source, target);
116         assertEquals(target.getThresholdUnits(), thresholdUnit);
117     }
118
119     @Test
120     public void testThresholdValue() {
121         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
122         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
123         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
124                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
125         Integer param = 1144092791;
126         source.setThresholdValue(param);
127         mapper.doMapping(source, target);
128         assertEquals(target.getThresholdValue(), param);
129     }
130
131     @Test
132     public void testName() {
133         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
134         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
135         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
136                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
137         String param = "8fb07080-e7ea-4543-812c-1ecdbb9e82c9";
138         source.setName(param);
139         mapper.doMapping(source, target);
140         assertEquals(target.getName(), param);
141     }
142
143     @Test
144     public void testOperationalScope() {
145         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
146         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
147         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
148                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
149         MultiChoiceOrOther<OperationalScope> operationalScopeMultiChoiceOrOther = new MultiChoiceOrOther<>();
150         Set set = new HashSet<>();
151         set.add(TestEnum.Yes);
152         operationalScopeMultiChoiceOrOther.setChoices(set);
153         source.setOperationalScope(operationalScopeMultiChoiceOrOther);
154         mapper.doMapping(source, target);
155         assertEquals(target.getOperationalScope().getChoices(), operationalScopeMultiChoiceOrOther.getChoices());
156     }
157
158     @Test
159     public void testStartDate() {
160         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
161         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
162         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
163                 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
164         String param = "75f2ae76-b32f-4ac1-92f6-a9d92cb41160";
165         source.setStartDate(param);
166         mapper.doMapping(source, target);
167         assertEquals(target.getStartDate(), param);
168     }
169
170     @Test
171     public void testManufacturerReferenceNumber() {
172         LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
173         LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
174         MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper = new
175             MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
176         String param = "02402e1e-7092-485a-9574-46e2d49cca97";
177         source.setManufacturerReferenceNumber(param);
178         mapper.doMapping(source, target);
179         assertEquals(target.getManufacturerReferenceNumber(), param);
180     }
181
182     enum TestEnum {
183         Yes
184     }
185 }