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.testng.Assert.assertEquals;
21 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
22 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
23 import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
24 import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
25 import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto;
26 import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto;
27 import org.testng.annotations.Test;
30 public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntityTest {
34 public void testExpiryDate() {
35 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
36 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
37 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
38 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
39 String param = "77d85090-e40d-49d0-ae18-b6aff51728e3";
40 source.setExpiryDate(param);
41 mapper.doMapping(source, target);
42 assertEquals(target.getExpiryDate(), param);
46 public void testThresholdUnits() {
47 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
48 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
49 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
50 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
51 ThresholdUnit thresholdUnit = ThresholdUnit.Absolute;
52 source.setThresholdUnits(thresholdUnit);
53 mapper.doMapping(source, target);
54 assertEquals(target.getThresholdUnits(), thresholdUnit);
58 public void testName() {
59 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
60 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
61 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
62 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
63 String param = "74ee9b26-9a6c-48a4-b3ec-f9a0fe174bc9";
64 source.setName(param);
65 mapper.doMapping(source, target);
66 assertEquals(target.getName(), param);
70 public void testDescription() {
71 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
72 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
73 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
74 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
75 String param = "a7aaa0f0-bd68-41b0-a27e-d4e62b1bd6e5";
76 source.setDescription(param);
77 mapper.doMapping(source, target);
78 assertEquals(target.getDescription(), param);
82 public void testThresholdValue() {
83 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
84 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
85 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
86 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
87 Integer param = -2136417915;
88 source.setThresholdValue(param);
89 mapper.doMapping(source, target);
90 assertEquals(target.getThresholdValue(), param);
94 public void testType() {
95 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
96 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
97 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
98 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
99 LicenseKeyType licenseKeyType = LicenseKeyType.Unique;
100 source.setType(licenseKeyType);
101 mapper.doMapping(source, target);
102 assertEquals(target.getType(), licenseKeyType);
106 public void testIncrements() {
107 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
108 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
109 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
110 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
111 String param = "97f20c3a-6f3a-42cf-aa1a-870ba436bde6";
112 source.setIncrements(param);
113 mapper.doMapping(source, target);
114 assertEquals(target.getIncrements(), param);
118 public void testOperationalScope() {
119 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
120 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
121 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
122 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
123 MultiChoiceOrOtherDto<OperationalScope> operationalScopeMultiChoiceOrOtherDto = new MultiChoiceOrOtherDto<>();
124 source.setOperationalScope(operationalScopeMultiChoiceOrOtherDto);
125 mapper.doMapping(source, target);
126 assertEquals(target.getOperationalScope().getChoices(), operationalScopeMultiChoiceOrOtherDto.getChoices());
130 public void testStartDate() {
131 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
132 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
133 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper =
134 new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
135 String param = "9aa18de7-ca80-4690-b604-2e0994424f2d";
136 source.setStartDate(param);
137 mapper.doMapping(source, target);
138 assertEquals(target.getStartDate(), param);
142 public void testManufacturerReferenceNumber() {
143 LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
144 LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
145 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper = new
146 MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
147 String param = "02402e1e-7092-485a-9574-46e2d49cca97";
148 source.setManufacturerReferenceNumber(param);
149 mapper.doMapping(source, target);
150 assertEquals(target.getManufacturerReferenceNumber(), param);