Migrate TestNG to Junit5
[sdc/sdc-tosca.git] / sdc-tosca / src / test / java / org / onap / sdc / impl / ToscaParserInterfaceTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * sdc-tosca
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.sdc.impl;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNotNull;
25
26 import java.util.Arrays;
27 import java.util.List;
28 import java.util.Map;
29 import org.junit.jupiter.api.Test;
30 import org.junit.jupiter.api.extension.ExtendWith;
31 import org.onap.sdc.toscaparser.api.NodeTemplate;
32 import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
33
34 @ExtendWith({SdcToscaParserBasicTest.class})
35 class ToscaParserInterfaceTest extends SdcToscaParserBasicTest {
36
37     private static List<NodeTemplate> vfs = csarHelperVfInterfaces.getServiceVfList();
38
39     @Test
40     public void testGetInterfaceOf() {
41         Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0));
42         assertNotNull(interfaceDetails);
43         assertEquals(interfaceDetails.size(), 2);
44     }
45
46     @Test
47     public void testGetInterfaces() {
48         List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0));
49         assertNotNull(interfaceNames);
50         assertEquals(interfaceNames, Arrays.asList("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard"));
51     }
52
53     @Test
54     public void testGetInterfaceDetails() {
55         List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0),
56             "org.openecomp.interfaces.node.lifecycle.CxVnf1");
57         assertNotNull(interfaceDetails);
58         assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate");
59         assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade");
60     }
61
62     @Test
63     public void testGetAllInterfaceOperations() {
64         List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
65         assertNotNull(operations);
66         assertEquals(operations, Arrays.asList("instantiate", "upgrade", "create", "configure", "start", "stop", "delete"));
67     }
68
69     @Test
70     public void testGetInterfaceOperationDetails() {
71         InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1",
72             "instantiate");
73         assertNotNull(interfaceDef);
74         assertEquals(interfaceDef.getOperationName(), "instantiate");
75     }
76
77     @Test
78     public void testGetInterfaceOperationImplementationDetails() {
79         InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1",
80             "upgrade");
81         assertNotNull(interfaceDef);
82         assertNotNull(interfaceDef.getImplementation());
83         assertEquals(((Map) interfaceDef.getImplementation()).get("primary"), "Artifacts/Deployment/WORKFLOW/CreateWorkFlow.json");
84         assertEquals(((Map) interfaceDef.getImplementation()).get("dependencies"), "TestDependency1");
85     }
86
87 }