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.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertNotNull;
26 import java.util.Arrays;
27 import java.util.List;
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;
34 @ExtendWith({SdcToscaParserBasicTest.class})
35 class ToscaParserInterfaceTest extends SdcToscaParserBasicTest {
37 private static List<NodeTemplate> vfs = csarHelperVfInterfaces.getServiceVfList();
40 public void testGetInterfaceOf() {
41 Map<String, List<InterfacesDef>> interfaceDetails = csarHelperVfInterfaces.getInterfacesOf(vfs.get(0));
42 assertNotNull(interfaceDetails);
43 assertEquals(interfaceDetails.size(), 2);
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"));
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");
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"));
70 public void testGetInterfaceOperationDetails() {
71 InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1",
73 assertNotNull(interfaceDef);
74 assertEquals(interfaceDef.getOperationName(), "instantiate");
78 public void testGetInterfaceOperationImplementationDetails() {
79 InterfacesDef interfaceDef = csarHelperVfInterfaces.getInterfaceOperationDetails(vfs.get(0), "org.openecomp.interfaces.node.lifecycle.CxVnf1",
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");