2 * Copyright © 2016-2018 European Support Limited
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org.openecomp.sdcrests.vendorlicense.rest.mapping;
19 import static org.junit.jupiter.api.Assertions.assertEquals;
21 import java.util.Collections;
22 import java.util.HashSet;
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.junit.jupiter.api.Test;
33 class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest {
36 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);
48 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);
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);
72 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);
84 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);
97 LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
98 LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
99 MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
100 new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
101 String param = "b2f35aa5-0240-46b7-bade-35890d46e9f9";
103 mapper.doMapping(source, target);
104 assertEquals(target.getId(), param);
108 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);
120 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);
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);
144 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());
159 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);
171 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);