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 org.junit.Test;
20 import org.openecomp.sdc.vendorlicense.dao.types.*;
21 import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
23 import java.util.Collections;
24 import java.util.HashSet;
27 import static org.testng.Assert.assertEquals;
30 public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest {
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);
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);
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);
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);
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);
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";
100 mapper.doMapping(source, target);
101 assertEquals(target.getId(), param);
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);
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);
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);
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());
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);
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);