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.LicenseAgreementEntity;
22 import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
23 import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto;
24 import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto;
25 import org.testng.annotations.Test;
28 public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntityTest {
31 public void testName() {
32 LicenseAgreementDescriptorDto source = new LicenseAgreementDescriptorDto();
33 LicenseAgreementEntity target = new LicenseAgreementEntity();
34 MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity mapper =
35 new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity();
36 String param = "62d9b3aa-1d06-453f-a412-62d8cba7164d";
37 source.setName(param);
38 mapper.doMapping(source, target);
39 assertEquals(target.getName(), param);
43 public void testDescription() {
44 LicenseAgreementDescriptorDto source = new LicenseAgreementDescriptorDto();
45 LicenseAgreementEntity target = new LicenseAgreementEntity();
46 MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity mapper =
47 new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity();
48 String param = "3888dc1f-516b-4790-a5fe-73efadb2ba38";
49 source.setDescription(param);
50 mapper.doMapping(source, target);
51 assertEquals(target.getDescription(), param);
55 public void testRequirementsAndConstrains() {
56 LicenseAgreementDescriptorDto source = new LicenseAgreementDescriptorDto();
57 LicenseAgreementEntity target = new LicenseAgreementEntity();
58 MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity mapper =
59 new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity();
60 String param = "be6df4d3-b534-4c62-b611-4ed5b67e72ab";
61 source.setRequirementsAndConstrains(param);
62 mapper.doMapping(source, target);
63 assertEquals(target.getRequirementsAndConstrains(), param);
67 public void testLicenseTerm() {
68 LicenseAgreementDescriptorDto source = new LicenseAgreementDescriptorDto();
69 LicenseAgreementEntity target = new LicenseAgreementEntity();
70 MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity mapper =
71 new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity();
72 ChoiceOrOtherDto<LicenseTerm> licenseTermChoiceOrOtherDto = new ChoiceOrOtherDto<>();
73 source.setLicenseTerm(licenseTermChoiceOrOtherDto);
74 mapper.doMapping(source, target);
75 assertEquals(target.getLicenseTerm().getChoice(), licenseTermChoiceOrOtherDto.getChoice());