da1a492eee3deb3f7ee5dc8dcaedf0eecf5554ec
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-license-lib / openecomp-sdc-vendor-license-core / src / main / test / java / org / openecomp / sdc / vendorlicense / dao / impl / zusammen / convertor / ElementToLicenseKeyGroupConvertorTest.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.sdc.vendorlicense.dao.impl.zusammen.convertor;
18
19 import static org.junit.Assert.assertEquals;
20
21 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
22 import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
23 import com.amdocs.zusammen.datatypes.Id;
24 import com.amdocs.zusammen.datatypes.item.Info;
25 import org.junit.Test;
26 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
27
28 public class ElementToLicenseKeyGroupConvertorTest {
29
30     private static final String ENTITY_ID = "entityId1";
31     private static final String ENTITY_NAME = "entityTestName";
32     private static final String ENTITY_DESCRIPTION = "entityTestDesc";
33     private static final String LICENSE_KEY_TYPE = "Unique";
34
35     private ElementToLicenseKeyGroupConvertor converter = new ElementToLicenseKeyGroupConvertor();
36
37     @Test
38     public void shouldConvertElementToLicenseKeyGroupEntity() {
39         ZusammenElement elementToConvert = new ZusammenElement();
40         elementToConvert.setElementId(new Id(ENTITY_ID));
41         Info info = createInfo();
42         elementToConvert.setInfo(info);
43         LicenseKeyGroupEntity result = converter.convert(elementToConvert);
44         assertEquals(ENTITY_ID,result.getId());
45         assertEquals(ENTITY_NAME, result.getName());
46         assertEquals(ENTITY_DESCRIPTION, result.getDescription());
47         assertEquals(LICENSE_KEY_TYPE, result.getType().name());
48
49     }
50
51
52     @Test
53     public void shouldConvertElementInfoToLicenseKeyGroupEntity() {
54         ElementInfo elementToConvert = new ElementInfo();
55         elementToConvert.setId(new Id(ENTITY_ID));
56         Info info = createInfo();
57         elementToConvert.setInfo(info);
58         LicenseKeyGroupEntity result = converter.convert(elementToConvert);
59         assertEquals(ENTITY_ID,result.getId());
60         assertEquals(ENTITY_NAME, result.getName());
61         assertEquals(ENTITY_DESCRIPTION, result.getDescription());
62         assertEquals(LICENSE_KEY_TYPE, result.getType().name());
63
64     }
65
66     private Info createInfo() {
67         Info info = new Info();
68         info.setName(ENTITY_NAME);
69         info.setDescription(ENTITY_DESCRIPTION);
70         info.addProperty("LicenseKeyType",LICENSE_KEY_TYPE);
71         return info;
72     }
73
74 }