2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.sdc.impl;
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.Assert.assertNotNull;
26 import java.util.List;
28 import org.mockito.internal.util.collections.Sets;
29 import org.onap.sdc.toscaparser.api.NodeTemplate;
30 import org.onap.sdc.toscaparser.api.elements.InterfacesDef;
31 import org.testng.annotations.BeforeClass;
32 import org.testng.annotations.Test;
34 public class ToscaParserInterfaceTest extends SdcToscaParserBasicTest {
36 List<NodeTemplate> vfs;
40 vfs = csarHelperVfInterfaces.getServiceVfList();
44 public void testGetInterfaceOf() {
45 Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0));
46 assertNotNull(interfaceDetails);
47 assertEquals(interfaceDetails.size(), 2);
51 public void testGetInterfaces() {
52 List<String> interfaceNames = csarHelperVfInterfaces.getInterfaces(vfs.get(0));
53 assertNotNull(interfaceNames);
54 assertEquals(interfaceNames, Sets.newSet("org.openecomp.interfaces.node.lifecycle.CxVnf1", "tosca.interfaces.node.lifecycle.Standard"));
58 public void testGetInterfaceDetails() {
59 List<InterfacesDef> interfaceDetails = csarHelperVfInterfaces.getInterfaceDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
60 assertNotNull(interfaceDetails);
61 assertEquals(interfaceDetails.get(0).getOperationName(), "instantiate");
62 assertEquals(interfaceDetails.get(1).getOperationName(), "upgrade");
66 public void testGetAllInterfaceOperations() {
67 List<String> operations = csarHelperVfInterfaces.getAllInterfaceOperations(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1");
68 assertNotNull(operations);
69 assertEquals(operations, Sets.newSet("instantiate", "upgrade", "create", "configure", "start", "stop", "delete"));
73 public void testGetInterfaceOperationDetails() {
74 InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "instantiate");
75 assertNotNull(interfaceDef);
76 assertEquals(interfaceDef.getOperationName(), "instantiate");
80 public void testGetInterfaceOperationImplementationDetails() {
81 InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1", "upgrade");
82 assertNotNull(interfaceDef);
83 assertNotNull(interfaceDef.getImplementation());
84 assertEquals(((Map)interfaceDef.getImplementation()).get("primary"), "Artifacts/Deployment/WORKFLOW/CreateWorkFlow.json");
85 assertEquals(((Map)interfaceDef.getImplementation()).get("dependencies"), "TestDependency1");