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.Collections;
22 import java.util.HashSet;
23 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
24 import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
25 import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto;
26 import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto;
27 import org.testng.annotations.Test;
30 public class MapEntitlementPoolRequestDtoToEntitlementPoolEntityTest {
33 public void testExpiryDate() {
34 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
35 EntitlementPoolEntity target = new EntitlementPoolEntity();
36 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
37 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
38 String param = "2d9bd40d-9b86-4621-a0b3-015cc65ed29f";
39 source.setExpiryDate(param);
40 mapper.doMapping(source, target);
41 assertEquals(target.getExpiryDate(), param);
45 public void testName() {
46 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
47 EntitlementPoolEntity target = new EntitlementPoolEntity();
48 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
49 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
50 String param = "08c72f48-2cb6-4509-9983-5564c74c1bc8";
51 source.setName(param);
52 mapper.doMapping(source, target);
53 assertEquals(target.getName(), param);
57 public void testDescription() {
58 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
59 EntitlementPoolEntity target = new EntitlementPoolEntity();
60 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
61 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
62 String param = "b5161f7b-b5bc-4e98-b242-a8dc99aeab01";
63 source.setDescription(param);
64 mapper.doMapping(source, target);
65 assertEquals(target.getDescription(), param);
69 public void testThresholdValue() {
70 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
71 EntitlementPoolEntity target = new EntitlementPoolEntity();
72 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
73 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
74 Integer param = -767970235;
75 source.setThresholdValue(param);
76 mapper.doMapping(source, target);
77 assertEquals(target.getThresholdValue(), param);
81 public void testIncrements() {
82 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
83 EntitlementPoolEntity target = new EntitlementPoolEntity();
84 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
85 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
86 String param = "3b760eff-6407-44b7-a1f2-2a87b432f094";
87 source.setIncrements(param);
88 mapper.doMapping(source, target);
89 assertEquals(target.getIncrements(), param);
93 public void testOperationalScope() {
94 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
95 EntitlementPoolEntity target = new EntitlementPoolEntity();
96 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
97 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
98 MultiChoiceOrOtherDto<OperationalScope> param = new MultiChoiceOrOtherDto<>();
99 param.setChoices(new HashSet(Collections.singletonList(TestEnum.Yes)));
100 source.setOperationalScope(param);
101 mapper.doMapping(source, target);
102 assertEquals(target.getOperationalScope().getChoices(), param.getChoices());
106 public void testStartDate() {
107 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
108 EntitlementPoolEntity target = new EntitlementPoolEntity();
109 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper =
110 new MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
111 String param = "654f3536-9346-45fb-97f5-6dc24e517e31";
112 source.setStartDate(param);
113 mapper.doMapping(source, target);
114 assertEquals(target.getStartDate(), param);
118 public void testManufacturerReferenceNumber() {
119 EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
120 EntitlementPoolEntity target = new EntitlementPoolEntity();
121 MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper = new
122 MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
123 String param = "02402e1e-7092-485a-9574-46e2d49cca97";
124 source.setManufacturerReferenceNumber(param);
125 mapper.doMapping(source, target);
126 assertEquals(target.getManufacturerReferenceNumber(), param);