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 java.util.Arrays;
22 import java.util.Collections;
23 import java.util.HashSet;
25 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
26 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolType;
27 import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
28 import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
29 import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto;
30 import org.testng.annotations.Test;
33 public class MapEntitlementPoolEntityToEntitlementPoolEntityDtoTest {
36 public void testReferencingFeatureGroups() {
37 EntitlementPoolEntity source = new EntitlementPoolEntity();
38 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
39 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
40 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
41 Set<String> param = new HashSet<>(Collections.singletonList("a3ad0c7a-9f4c-44d2-8c0c-b4b47cd6d264"));
42 source.setReferencingFeatureGroups(param);
43 mapper.doMapping(source, target);
44 assertEquals(target.getReferencingFeatureGroups(), param);
48 public void testDescription() {
49 EntitlementPoolEntity source = new EntitlementPoolEntity();
50 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
51 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
52 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
53 String param = "58191782-5de2-4d42-b8ca-119707d38150";
54 source.setDescription(param);
55 mapper.doMapping(source, target);
56 assertEquals(target.getDescription(), param);
60 public void testIncrements() {
61 EntitlementPoolEntity source = new EntitlementPoolEntity();
62 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
63 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
64 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
65 String param = "ea6b2eab-f959-41c2-9a09-2898eb5401be";
66 source.setIncrements(param);
67 mapper.doMapping(source, target);
68 assertEquals(target.getIncrements(), param);
72 public void testExpiryDate() {
73 EntitlementPoolEntity source = new EntitlementPoolEntity();
74 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
75 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
76 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
77 String param = "7e27d6a4-78be-44df-b099-dd41317586ba";
78 source.setExpiryDate(param);
79 mapper.doMapping(source, target);
80 assertEquals(target.getExpiryDate(), param);
84 public void testId() {
85 EntitlementPoolEntity source = new EntitlementPoolEntity();
86 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
87 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
88 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
89 String param = "e2163b3f-971e-4523-a5bc-0e6f7dd44e37";
91 mapper.doMapping(source, target);
92 assertEquals(target.getId(), param);
96 public void testThresholdValue() {
97 EntitlementPoolEntity source = new EntitlementPoolEntity();
98 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
99 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
100 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
101 Integer param = 2146099790;
102 source.setThresholdValue(param);
103 mapper.doMapping(source, target);
104 assertEquals(target.getThresholdValue(), param);
108 public void testName() {
109 EntitlementPoolEntity source = new EntitlementPoolEntity();
110 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
111 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
112 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
113 mapper.doMapping(source, target);
114 assertEquals(target.getName(), source.getName());
115 String param = "f8faa28a-435d-4cea-98ee-de7a46b52ec5";
116 source.setName(param);
117 mapper.doMapping(source, target);
118 assertEquals(target.getName(), param);
122 public void testOperationalScope() {
123 EntitlementPoolEntity source = new EntitlementPoolEntity();
124 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
125 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
126 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
127 MultiChoiceOrOther<OperationalScope> param = new MultiChoiceOrOther<>();
128 param.setChoices(new HashSet(Arrays.asList("a", "b")));
129 source.setOperationalScope(param);
130 mapper.doMapping(source, target);
131 assertEquals(target.getOperationalScope().getChoices(), param.getChoices());
135 public void testStartDate() {
136 EntitlementPoolEntity source = new EntitlementPoolEntity();
137 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
138 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
139 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
140 String param = "afeadea1-9fb7-4d2d-bcc3-3ef298ed1802";
141 source.setStartDate(param);
142 mapper.doMapping(source, target);
143 assertEquals(target.getStartDate(), param);
147 public void testManufacturerReferenceNumber() {
148 EntitlementPoolEntity source = new EntitlementPoolEntity();
149 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
150 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper = new
151 MapEntitlementPoolEntityToEntitlementPoolEntityDto();
153 String param = "02402e1e-7092-485a-9574-46e2d49cca97";
154 source.setManufacturerReferenceNumber(param);
155 mapper.doMapping(source, target);
156 assertEquals(target.getManufacturerReferenceNumber(), param);
160 public void testType() {
161 EntitlementPoolEntity source = new EntitlementPoolEntity();
162 EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
163 MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper =
164 new MapEntitlementPoolEntityToEntitlementPoolEntityDto();
165 EntitlementPoolType entitlementPoolType = EntitlementPoolType.One_Time;
166 source.setType(entitlementPoolType);
167 mapper.doMapping(source, target);
168 assertEquals(target.getType(), entitlementPoolType);