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.AggregationFunction;
22 import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
23 import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
24 import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
25 import org.testng.annotations.Test;
28 public class MapLimitEntityToLimitDtoTest {
31 public void testDescription() {
32 LimitEntity source = new LimitEntity();
33 LimitEntityDto target = new LimitEntityDto();
34 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
35 String param = "7315b1fa-f797-438a-b0d1-8b652899ecec";
36 source.setDescription(param);
37 mapper.doMapping(source, target);
38 assertEquals(target.getDescription(), param);
42 public void testAggregationFunction() {
43 LimitEntity source = new LimitEntity();
44 LimitEntityDto target = new LimitEntityDto();
45 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
46 AggregationFunction aggregationFunction = AggregationFunction.Average;
47 source.setAggregationFunction(aggregationFunction);
48 mapper.doMapping(source, target);
49 assertEquals(target.getAggregationFunction(), aggregationFunction.toString());
53 public void testType() {
54 LimitEntity source = new LimitEntity();
55 LimitEntityDto target = new LimitEntityDto();
56 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
57 LimitType limitType = LimitType.Vendor;
58 source.setType(limitType);
59 mapper.doMapping(source, target);
60 assertEquals(target.getType(), limitType.toString());
64 public void testUnit() {
65 LimitEntity source = new LimitEntity();
66 LimitEntityDto target = new LimitEntityDto();
67 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
68 String param = "94ab5e65-f777-49b7-9328-14af712a3767";
69 source.setUnit(param);
70 mapper.doMapping(source, target);
71 assertEquals(target.getUnit(), param);
75 public void testMetric() {
76 LimitEntity source = new LimitEntity();
77 LimitEntityDto target = new LimitEntityDto();
78 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
79 String param = "1fb615b9-8108-485d-83c9-5dbfb14cf953";
80 source.setMetric(param);
81 mapper.doMapping(source, target);
82 assertEquals(target.getMetric(), param);
86 public void testName() {
87 LimitEntity source = new LimitEntity();
88 LimitEntityDto target = new LimitEntityDto();
89 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
90 String param = "ab5d6967-0020-4cd2-aeba-ff3e39e52385";
91 source.setName(param);
92 mapper.doMapping(source, target);
93 assertEquals(target.getName(), param);
97 public void testId() {
98 LimitEntity source = new LimitEntity();
99 LimitEntityDto target = new LimitEntityDto();
100 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
101 String param = "52d4d919-015a-4a46-af04-4d0dec17e88d";
103 mapper.doMapping(source, target);
104 assertEquals(target.getId(), param);
108 public void testTime() {
109 LimitEntity source = new LimitEntity();
110 LimitEntityDto target = new LimitEntityDto();
111 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
112 String param = "4e19d619-5004-423c-abf2-0d6e69a47a5c";
113 source.setTime(param);
114 mapper.doMapping(source, target);
115 assertEquals(target.getTime(), param);
119 public void testValue() {
120 LimitEntity source = new LimitEntity();
121 LimitEntityDto target = new LimitEntityDto();
122 MapLimitEntityToLimitDto mapper = new MapLimitEntityToLimitDto();
123 String param = "13d67707-b02f-40b2-8b19-60fd6405a7af";
124 source.setValue(param);
125 mapper.doMapping(source, target);
126 assertEquals(target.getValue(), param);