Fix 'Optional license in onboarding'-bug
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-core / src / test / java / org / openecomp / sdc / vendorlicense / dao / impl / zusammen / convertor / ElementToVLMGeneralConvertorTest.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 package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
17
18 import static org.junit.jupiter.api.Assertions.assertEquals;
19
20 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
21 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
22 import com.amdocs.zusammen.datatypes.item.Info;
23 import org.junit.jupiter.api.Test;
24 import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
25 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
26
27 class ElementToVLMGeneralConvertorTest {
28
29     private static final String ENTITY_NAME = "entityTestName";
30     private static final String ENTITY_DESCRIPTION = "entityTestDesc";
31
32     private ElementToVLMGeneralConvertor converter = new ElementToVLMGeneralConvertor();
33
34     @Test
35     void shouldConvertElementToVendorLicenseModelEntity() {
36         ZusammenElement elementToConvert = new ZusammenElement();
37         Info info = new Info();
38         info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.NAME.name(), ENTITY_NAME);
39         info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.DESCRIPTION.name(), ENTITY_DESCRIPTION);
40         elementToConvert.setInfo(info);
41         VendorLicenseModelEntity result = converter.convert(elementToConvert);
42         assertEquals(ENTITY_NAME, result.getVendorName());
43         assertEquals(ENTITY_DESCRIPTION, result.getDescription());
44     }
45
46     @Test
47     void shouldConvertElementInfoToVendorLicenseModelEntity() {
48         ElementInfo elementInfo = new ElementInfo();
49         Info info = new Info();
50         info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.NAME.name(), ENTITY_NAME);
51         info.addProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.DESCRIPTION.name(), ENTITY_DESCRIPTION);
52         elementInfo.setInfo(info);
53         VendorLicenseModelEntity result = converter.convert(elementInfo);
54         assertEquals(ENTITY_NAME, result.getVendorName());
55         assertEquals(ENTITY_DESCRIPTION, result.getDescription());
56     }
57
58 }