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.junit.jupiter.api.Assertions.assertEquals;
21 import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
22 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
23 import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
24 import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto;
25 import org.junit.jupiter.api.Test;
28 class MapLicenseAgreementEntityToLicenseAgreementDescriptorDtoTest {
31 void testLicenseTerm() {
32 LicenseAgreementEntity source = new LicenseAgreementEntity();
33 LicenseAgreementDescriptorDto target = new LicenseAgreementDescriptorDto();
34 MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper =
35 new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto();
36 ChoiceOrOther<LicenseTerm> licenseTermChoiceOrOther = new ChoiceOrOther<>();
37 licenseTermChoiceOrOther.setChoice(LicenseTerm.Other);
38 source.setLicenseTerm(licenseTermChoiceOrOther);
39 mapper.doMapping(source, target);
40 assertEquals(target.getLicenseTerm().getChoice(), licenseTermChoiceOrOther.getChoice());
45 LicenseAgreementEntity source = new LicenseAgreementEntity();
46 LicenseAgreementDescriptorDto target = new LicenseAgreementDescriptorDto();
47 MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper =
48 new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto();
49 String param = "b76b2520-2573-4337-9bf8-fbd9b41aecc9";
50 source.setName(param);
51 mapper.doMapping(source, target);
52 assertEquals(target.getName(), param);
56 void testDescription() {
57 LicenseAgreementEntity source = new LicenseAgreementEntity();
58 LicenseAgreementDescriptorDto target = new LicenseAgreementDescriptorDto();
59 MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper =
60 new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto();
61 String param = "1a9f859d-0644-450d-9cda-0caced655b94";
62 source.setDescription(param);
63 mapper.doMapping(source, target);
64 assertEquals(target.getDescription(), param);
68 void testRequirementsAndConstrains() {
69 LicenseAgreementEntity source = new LicenseAgreementEntity();
70 LicenseAgreementDescriptorDto target = new LicenseAgreementDescriptorDto();
71 MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper =
72 new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto();
73 String param = "1efaca15-4d8a-422c-a33a-7b57f9aaa99c";
74 source.setRequirementsAndConstrains(param);
75 mapper.doMapping(source, target);
76 assertEquals(target.getRequirementsAndConstrains(), param);