Interfaces support in SDC Parser
[sdc/sdc-tosca.git] / src / test / java / org / onap / sdc / impl / ToscaParserInterfaceTest.java
1 package org.onap.sdc.impl;
2
3 import static org.testng.Assert.assertEquals;
4 import static org.testng.Assert.assertNotNull;
5
6 import java.util.List;
7 import java.util.Map;
8 import org.mockito.internal.util.collections.Sets;
9 import org.onap.sdc.toscaparser.api.NodeTemplate;
10 import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
11 import org.testng.annotations.BeforeClass;
12 import org.testng.annotations.Test;
13
14 public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest {
15
16     List<NodeTemplate> vfs;
17
18     @BeforeClass
19     public void setup(){
20         vfs = csarHelperVfInterfaces.getServiceVfList();
21     }
22
23     @Test
24     public void testGetInterfaceOf() {
25         Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0));
26         assertNotNull(interfaceDetails);
27         assertEquals(interfaceDetails.size(), 2);
28     }
29
30     @Test
31     public void testGetInterfaces() {
32         List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0));
33         assertNotNull(interfaceNames);
34         assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard"));
35     }
36
37     @Test
38     public void testGetInterfaceDetails() {
39         List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
40         assertNotNull(interfaceDetails);
41         assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate");
42         assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade");
43     }
44
45     @Test
46     public void testGetAllInterfaceOperations() {
47         List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
48         assertNotNull(operations);
49         assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete"));
50     }
51
52     @Test
53     public void testGetInterfaceOperationDetails() {
54         InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate");
55         assertNotNull(interfaceDef);
56         assertEquals(interfaceDef.getOperationName(), "instantiate");
57     }
58
59 }