b7c74e0bc172380a98170f59601798ed2bd5b452
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-license-rest / vendor-license-rest-services / src / test / java / org / openecomp / sdcrests / vendorlicense / rest / mapping / MapLicenseAgreementEntityToLicenseAgreementDescriptorDtoTest.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdcrests.vendorlicense.rest.mapping;
18
19 import static org.testng.Assert.assertEquals;
20
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.testng.annotations.Test;
26
27
28 public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDtoTest {
29
30     @Test
31     public 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());
41     }
42
43     @Test
44     public void testName() {
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);
53     }
54
55     @Test
56     public 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);
65     }
66
67     @Test
68     public 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);
77     }
78 }