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