summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-10-14 20:56:11 +0100
committerS�bastien Determe <sebastien.determe@intl.att.com>2020-12-07 14:51:59 +0000
commit95ad93091d5fa6e377e76f312d495151bddc9da8 (patch)
tree9923a98bd90b99cb960cf1f7ead2a57402aca1a8 /catalog-be/src/test
parenta9467feb90c33ad5b6b2ed80581c4adf75114046 (diff)
Support interface input during import VFC
Change-Id: I097ce258a7dadbedf1aff6ce53dd1286da074552 Issue-ID: SDC-3372 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java64
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java174
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java (renamed from catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java)240
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java72
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml12
-rw-r--r--catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml24
-rw-r--r--catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml25
8 files changed, 443 insertions, 176 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index b497253118..336b8ec940 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -22,7 +22,20 @@
package org.openecomp.sdc.be.components;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -32,6 +45,7 @@ import org.mockito.stubbing.Answer;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.impl.ImportUtils;
import org.openecomp.sdc.be.components.impl.ImportUtilsTest;
+import org.openecomp.sdc.be.components.impl.InterfaceDefinitionHandler;
import org.openecomp.sdc.be.components.impl.InterfaceOperationBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
@@ -63,27 +77,15 @@ import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.PolicyException;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
public class ResourceImportManagerTest {
- private static ConfigurationManager configurationManager;
static ResourceImportManager importManager;
static AuditingManager auditingManager = Mockito.mock(AuditingManager.class);
static ResponseFormatManager responseFormatManager = Mockito.mock(ResponseFormatManager.class);
static ResourceBusinessLogic resourceBusinessLogic = Mockito.mock(ResourceBusinessLogic.class);
static InterfaceOperationBusinessLogic interfaceOperationBusinessLogic = Mockito.mock(InterfaceOperationBusinessLogic.class);
+ static InterfaceDefinitionHandler interfaceDefinitionHandler =
+ new InterfaceDefinitionHandler(interfaceOperationBusinessLogic);
static UserBusinessLogic userAdmin = Mockito.mock(UserBusinessLogic.class);
static ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
@@ -93,17 +95,16 @@ public class ResourceImportManagerTest {
@BeforeClass
public static void beforeClass() {
- importManager = new ResourceImportManager(componentsUtils, capabilityTypeOperation);
+ importManager = new ResourceImportManager(componentsUtils, capabilityTypeOperation, interfaceDefinitionHandler);
importManager.setAuditingManager(auditingManager);
when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString())).thenReturn(Either.left(null));
importManager.setResponseFormatManager(responseFormatManager);
importManager.setResourceBusinessLogic(resourceBusinessLogic);
- importManager.setInterfaceOperationBusinessLogic(interfaceOperationBusinessLogic);
importManager.setToscaOperationFacade(toscaOperationFacade);
String appConfigDir = "src/test/resources/config/catalog-be";
ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
- configurationManager = new ConfigurationManager(configurationSource);
+ final ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
Configuration configuration = new Configuration();
configuration.setJanusGraphInMemoryGraph(true);
@@ -223,8 +224,9 @@ public class ResourceImportManagerTest {
interfaceTypes.put("tosca.interfaces.node.lifecycle.standard", interfaceDefinition);
when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes));
- ImmutablePair<Resource, ActionStatus> createResource = importManager.importNormativeResource(jsonContent, resourceMD, user, true, true);
- testSetInterfaceImplementation(createResource.left);
+ final ImmutablePair<Resource, ActionStatus> createResource = importManager
+ .importNormativeResource(jsonContent, resourceMD, user, true, true);
+ assertSetInterfaceImplementation(createResource.left);
}
@Test
@@ -342,12 +344,12 @@ public class ResourceImportManagerTest {
assertTrue(properties.containsKey("volume_id"));
propertyDefinition = properties.get("volume_id");
assertEquals("string", propertyDefinition.getType());
- assertTrue(!propertyDefinition.isRequired());
+ assertFalse(propertyDefinition.isRequired());
assertTrue(properties.containsKey("snapshot_id"));
propertyDefinition = properties.get("snapshot_id");
assertEquals("string", propertyDefinition.getType());
- assertTrue(!propertyDefinition.isRequired());
+ assertFalse(propertyDefinition.isRequired());
}
@@ -398,20 +400,19 @@ public class ResourceImportManagerTest {
}
- private void testSetInterfaceImplementation(Resource resource) {
- Map<String, InterfaceDefinition> interfaces = resource.getInterfaces();
+ private void assertSetInterfaceImplementation(final Resource resource) {
+ final Map<String, InterfaceDefinition> interfaces = resource.getInterfaces();
assertEquals(1, interfaces.size());
assertTrue(interfaces.containsKey("Standard"));
-
- InterfaceDefinition interfaceDefinition = interfaces.get("Standard");
+
+ final InterfaceDefinition interfaceDefinition = interfaces.get("Standard");
assertEquals("tosca.interfaces.node.lifecycle.Standard", interfaceDefinition.getType());
assertEquals("tosca.interfaces.node.lifecycle.standard", interfaceDefinition.getUniqueId());
- Map<String, OperationDataDefinition> operations = interfaceDefinition.getOperations();
+ final Map<String, OperationDataDefinition> operations = interfaceDefinition.getOperations();
assertEquals(1, operations.size());
- OperationDataDefinition operation = operations.get("configure");
+ final OperationDataDefinition operation = operations.get("configure");
assertEquals("'camunda/vnfConfigure'", operation.getImplementation().getArtifactName());
-
}
private void testSetDerivedFrom(Resource resource) {
@@ -421,19 +422,12 @@ public class ResourceImportManagerTest {
}
private void testSetMetaDataFromJson(Resource resource, UploadResourceInfo resourceMD) {
-
- // assertTrue( resource.getCategory().equals(resourceMD.getCategory())
- // );
assertEquals(resource.getDescription(), resourceMD.getDescription());
assertEquals(resource.getIcon(), resourceMD.getResourceIconPath());
assertEquals(resource.getName(), resourceMD.getName());
assertEquals(resource.getResourceVendorModelNumber(), resourceMD.getResourceVendorModelNumber());
assertEquals(resource.getContactId(), resourceMD.getContactId());
assertEquals(resource.getCreatorUserId(), resourceMD.getContactId());
-
- // assertTrue( resource.isAbstract() ==
- // Constants.ABSTRACT_CATEGORY.equals(resourceMD.getCategory()));
-
assertEquals(resourceMD.getTags().size(), resource.getTags().size());
for (String tag : resource.getTags()) {
assertTrue(resourceMD.getTags().contains(tag));
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index 87875d8f20..9cd095b5b5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -324,7 +324,7 @@ public class ImportUtilsTest {
PropertyDefinition property = properties.get("service_type");
assertTrue(property.getConstraints()!= null && property.getConstraints().size() == 1);
assertTrue(property.getConstraints().get(0) instanceof ValidValuesConstraint);
- assertTrue(((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues() != null);
+ assertNotNull(((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues());
List<String> validValues = ((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues();
assertTrue(validValues.containsAll(Lists.newArrayList("firewall", "analyzer", "source-nat", "loadbalancer")));
@@ -334,7 +334,7 @@ public class ImportUtilsTest {
PropertyDefinition innerProperty = new PropertyDefinition(property.getSchema().getProperty());
List<PropertyConstraint> innerConstraints = innerProperty.getConstraints();
assertTrue(innerConstraints.get(0) instanceof ValidValuesConstraint);
- assertTrue(((ValidValuesConstraint) innerConstraints.get(0)).getValidValues() != null);
+ assertNotNull(((ValidValuesConstraint) innerConstraints.get(0)).getValidValues());
validValues = ((ValidValuesConstraint) innerConstraints.get(0)).getValidValues();
assertTrue(validValues.containsAll(Lists.newArrayList("management", "left", "right", "other")));
}
@@ -352,6 +352,10 @@ public class ImportUtilsTest {
Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS);
compareProperties(expectedProperties, actualInputs.left().value());
+ actualInputs = ImportUtils.getInputs(toscaJson);
+ assertTrue(actualInputs.isLeft());
+ expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS);
+ compareProperties(expectedProperties, actualInputs.left().value());
}
private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, AttributeDataDefinition> actual) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java
new file mode 100644
index 0000000000..f819eceb43
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandlerTest.java
@@ -0,0 +1,174 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.when;
+
+import fj.data.Either;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.commons.collections.MapUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.yaml.snakeyaml.Yaml;
+
+@ExtendWith(MockitoExtension.class)
+class InterfaceDefinitionHandlerTest {
+
+ @Mock
+ private InterfaceOperationBusinessLogic interfaceOperationBusinessLogic;
+ private InterfaceDefinitionHandler interfaceDefinitionHandler;
+ private InterfaceDefinition interfaceLifecyleStandard;
+ private static final Path TEST_RESOURCE_PATH = Paths.get("src/test/resources/interfaceDefinition");
+ private static final String CREATE_OPERATION = "create";
+ private static final String DELETE_OPERATION = "delete";
+ private static final String START_OPERATION = "start";
+ private static final String STOP_OPERATION = "stop";
+ private static final String INTERFACE_TYPE = "tosca.interfaces.node.lifecycle.Standard";
+
+ @BeforeEach
+ void setUp() {
+ interfaceDefinitionHandler = new InterfaceDefinitionHandler(interfaceOperationBusinessLogic);
+ mockAllInterfacesLifecycle();
+ }
+
+ private void mockAllInterfacesLifecycle() {
+ final Map<String, InterfaceDefinition> interfaceTypes = new HashMap<>();
+ interfaceLifecyleStandard = new InterfaceDefinition();
+ interfaceLifecyleStandard.setType(INTERFACE_TYPE);
+ final Map<String, OperationDataDefinition> operations = new HashMap<>();
+ operations.put(CREATE_OPERATION, new OperationDataDefinition());
+ operations.put(START_OPERATION, new OperationDataDefinition());
+ operations.put(STOP_OPERATION, new OperationDataDefinition());
+ operations.put(DELETE_OPERATION, new OperationDataDefinition());
+ interfaceLifecyleStandard.setOperations(operations);
+ interfaceTypes.put(INTERFACE_TYPE, interfaceLifecyleStandard);
+ when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceTypes));
+ }
+
+ @Test
+ void testCreateWithLegacyOperationDeclarationSuccess() throws FileNotFoundException {
+ final Map<String, Object> load = loadYaml(Paths.get("interfaceDefinition-legacy.yaml"));
+ final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load);
+ assertInterfaceDefinition(actualInterfaceDefinition);
+ }
+
+ @Test
+ void testCreateWithOperationSuccess() throws FileNotFoundException {
+ final Map<String, Object> load = loadYaml(Paths.get("interfaceDefinition-tosca1.3.yaml"));
+ final InterfaceDefinition actualInterfaceDefinition = interfaceDefinitionHandler.create(load);
+ assertInterfaceDefinition(actualInterfaceDefinition);
+ }
+
+ private void assertInterfaceDefinition(final InterfaceDefinition actualInterfaceDefinition) {
+ interfaceLifecyleStandard.getOperations().keySet().forEach(operation ->
+ assertTrue(actualInterfaceDefinition.hasOperation(operation)));
+ assertThat("Interface type should be as expected", actualInterfaceDefinition.getType(),
+ equalTo(actualInterfaceDefinition.getType()));
+ assertThat("Interface should contain 2 inputs", actualInterfaceDefinition.getInputs(), aMapWithSize(2));
+ assertThat("Interface inputs should be as expected", actualInterfaceDefinition.getInputs().keySet(),
+ containsInAnyOrder("stringInput", "actionInput"));
+
+ final InputDataDefinition stringInput = actualInterfaceDefinition.getInputs().get("stringInput");
+ assertInput("string", "stringInput description", true, "defaultValue", "aStatus", stringInput);
+ final InputDataDefinition actionInput = actualInterfaceDefinition.getInputs().get("actionInput");
+ assertInput("org.openecomp.resource.datatypes.Action", null, false, null, null, actionInput);
+
+ final OperationDataDefinition createOperation = actualInterfaceDefinition.getOperations().get(CREATE_OPERATION);
+ assertOperation("'camunda/serviceSelect'", createOperation);
+
+ final OperationDataDefinition deleteOperation = actualInterfaceDefinition.getOperations().get(DELETE_OPERATION);
+ assertOperation("'camunda/serviceDeselect'", deleteOperation);
+
+ final Map<String, String> expectedInputMap = new HashMap<>();
+ expectedInputMap.put("action", "org.openecomp.resource.datatypes.Action");
+ final OperationDataDefinition startOperation = actualInterfaceDefinition.getOperations().get(START_OPERATION);
+ assertOperation("'camunda/executeAction'", expectedInputMap, startOperation);
+ final OperationDataDefinition stopOperation = actualInterfaceDefinition.getOperations().get(STOP_OPERATION);
+ assertOperation("'camunda/executeAction'", expectedInputMap, stopOperation);
+ }
+
+ private void assertOperation(final String implementation, final OperationDataDefinition actualOperation) {
+ assertOperation(implementation, Collections.emptyMap(), actualOperation);
+ }
+
+ private void assertOperation(final String implementation, final Map<String, String> inputNameTypeMap,
+ final OperationDataDefinition actualOperation) {
+ final ArtifactDataDefinition artifactDefinition = actualOperation.getImplementation();
+ assertThat("Implementation should be as expected", artifactDefinition.getArtifactName(), equalTo(implementation));
+ final ListDataDefinition<OperationInputDefinition> inputListDataDef = actualOperation.getInputs();
+ if (inputListDataDef == null) {
+ if (MapUtils.isNotEmpty(inputNameTypeMap)) {
+ final String expectedInputNames = String.join(",", inputNameTypeMap.keySet());
+ fail(String.format("No inputs were found, but some inputs are expected: %s", expectedInputNames));
+ }
+ return;
+ }
+
+ final String msgFormat = "Operation should have %s";
+ final List<OperationInputDefinition> inputList = inputListDataDef.getListToscaDataDefinition();
+ assertThat(String.format(msgFormat, "the expected quantity of inputs"), inputList, hasSize(inputNameTypeMap.size()));
+
+ final List<String> inputNames = inputList.stream()
+ .map(OperationInputDefinition::getName).collect(Collectors.toList());
+
+ assertThat(String.format(msgFormat, "the expected inputs"), inputNames,
+ hasItems(inputNameTypeMap.keySet().toArray(new String[0])));
+ }
+
+ private void assertInput(final String type, final String description, final Boolean required,
+ final String defaultValue, final String status, final InputDataDefinition actualInput) {
+ assertThat("Input type should be as expected", type, equalTo(actualInput.getType()));
+ assertThat("Input description should be as expected", description, equalTo(actualInput.getDescription()));
+ assertThat("Input required should be as expected", required, equalTo(required != null && required));
+ assertThat("Input default should be as expected", defaultValue, equalTo(actualInput.getDefaultValue()));
+ assertThat("Input status should be as expected", status, equalTo(actualInput.getStatus()));
+ }
+
+ private Map<String, Object> loadYaml(final Path filePathFromResource) throws FileNotFoundException {
+ final Path filePath = Paths.get(TEST_RESOURCE_PATH.toString(), filePathFromResource.toString());
+ final FileInputStream fileInputStream = new FileInputStream(filePath.toString());
+ return (Map<String, Object>) new Yaml().load(fileInputStream);
+ }
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
index 93a45ad20f..0281317b89 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsConverterTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverterTest.java
@@ -1,24 +1,42 @@
/*
- * Copyright © 2016-2018 European Support Limited
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.be.tosca.utils;
-
-import static org.mockito.Mockito.mock;
+package org.openecomp.sdc.be.tosca;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.SELF;
import static org.openecomp.sdc.be.tosca.InterfacesOperationsConverter.addInterfaceTypeElement;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DEFAULT;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.DESCRIPTION;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INPUTS;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.INTERFACES;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.NODE_TYPES;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.REQUIRED;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.TYPE;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -28,23 +46,23 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.function.Function;
+import java.util.stream.Collectors;
import org.apache.commons.collections4.MapUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.be.DummyConfigurationManager;
-import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
@@ -52,44 +70,40 @@ import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.ServiceMetadataDefinition;
-import org.openecomp.sdc.be.tosca.InterfacesOperationsConverter;
-import org.openecomp.sdc.be.tosca.PropertyConvertor;
-import org.openecomp.sdc.be.tosca.ToscaExportHandler;
-import org.openecomp.sdc.be.tosca.ToscaRepresentation;
import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
+import org.yaml.snakeyaml.Yaml;
-@RunWith(MockitoJUnitRunner.class)
-public class InterfacesOperationsConverterTest {
+class InterfacesOperationsConverterTest {
private static final String MAPPED_PROPERTY_NAME = "mapped_property";
private static final String INPUT_NAME_PREFIX = "input_";
private static final String OUTPUT_NAME_PREFIX = "output_";
private static final String NODE_TYPE_NAME = "test";
- private String[] inputTypes = {"string", "integer", "float", "boolean"};
+ private final String[] inputTypes = {"string", "integer", "float", "boolean"};
private static ObjectMapper mapper;
- private Configuration.EnvironmentContext environmentContext = mock(Configuration.EnvironmentContext.class);
- DummyConfigurationManager dummyConfigurationManager = new DummyConfigurationManager();
private static final Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
private InterfacesOperationsConverter interfacesOperationsConverter;
- @BeforeClass
+ @BeforeAll
public static void setUp() {
+ //initialize the static configuration manager
+ new DummyConfigurationManager();
mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
- @Before
+ @BeforeEach
public void setUpBeforeTest() {
interfacesOperationsConverter =
new InterfacesOperationsConverter(new PropertyConvertor());
}
@Test
- public void addInterfaceTypeElementToResource() {
+ void addInterfaceTypeElementToResource() {
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
component.setComponentMetadataDefinition(new ServiceMetadataDefinition());
@@ -110,14 +124,14 @@ public class InterfacesOperationsConverterTest {
template.setInterface_types(interfaceTypeElement);
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("NodeTypeName"),
containsNone("operations")
).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
- public void addInterfaceTypeElementToService() {
+ void addInterfaceTypeElementToService() {
Component component = new Service();
component.setNormalizedName("normalizedServiceComponentName");
component.setComponentMetadataDefinition(new ServiceMetadataDefinition());
@@ -138,14 +152,14 @@ public class InterfacesOperationsConverterTest {
template.setInterface_types(interfaceTypeElement);
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("NodeTypeName"),
containsNone("operations")
).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
- public void addInterfaceDefinitionElementToResource() {
+ void addInterfaceDefinitionElementToResource() {
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
@@ -167,7 +181,7 @@ public class InterfacesOperationsConverterTest {
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
String mainYaml = new String(toscaRepresentation.getMainYaml());
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
containsNone("operations", "defaultp")
).apply(mainYaml));
@@ -176,7 +190,7 @@ public class InterfacesOperationsConverterTest {
}
@Test
- public void addInterfaceDefinitionElementToService() {
+ void addInterfaceDefinitionElementToService() {
Component component = new Service();
component.setNormalizedName("normalizedServiceComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
@@ -196,7 +210,7 @@ public class InterfacesOperationsConverterTest {
template.setNode_types(nodeTypes);
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
String mainYaml = new String(toscaRepresentation.getMainYaml());
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("serviceName", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.service.or.other.serviceName"),
containsNone("operations", "defaultp")
).apply(mainYaml));
@@ -205,7 +219,7 @@ public class InterfacesOperationsConverterTest {
@Test
- public void testGetInterfaceAsMapServiceProxy() {
+ void testGetInterfaceAsMapServiceProxy() {
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
@@ -227,7 +241,7 @@ public class InterfacesOperationsConverterTest {
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
String mainYaml = new String(toscaRepresentation.getMainYaml());
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("resourceName:", "inputs:", "has description", MAPPED_PROPERTY_NAME, "com.some.resource.or.other.resourceName"),
containsNone("operations", "defaultp")
).apply(mainYaml));
@@ -235,7 +249,7 @@ public class InterfacesOperationsConverterTest {
}
@Test
- public void addInterfaceDefinitionElement_noInputs() {
+ void addInterfaceDefinitionElement_noInputs() {
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
InterfaceDefinition addedInterface = new InterfaceDefinition();
@@ -255,14 +269,14 @@ public class InterfacesOperationsConverterTest {
template.setNode_types(nodeTypes);
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("resourceNameNoInputs", "has description", "com.some.resource.or.other.resourceName"),
containsNone("operations", INPUT_NAME_PREFIX, "defaultp")
).apply(new String(toscaRepresentation.getMainYaml())));
}
@Test
- public void addInterfaceDefinitionElementInputMappedToOtherOperationOutput() {
+ void addInterfaceDefinitionElementInputMappedToOtherOperationOutput() {
String addedInterfaceType = "com.some.resource.or.other.resourceNameInputMappedToOutput";
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
@@ -289,7 +303,7 @@ public class InterfacesOperationsConverterTest {
template.setNode_types(nodeTypes);
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
String mainYaml = new String(toscaRepresentation.getMainYaml());
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("resourceNameInputMappedToOutput:", "inputs:"),
containsNone("operations")
).apply(mainYaml));
@@ -297,7 +311,7 @@ public class InterfacesOperationsConverterTest {
}
@Test
- public void addInterfaceDefinitionElementInputMappedToOtherOperationOutputFromOtherInterface() {
+ void addInterfaceDefinitionElementInputMappedToOtherOperationOutputFromOtherInterface() {
String addedInterfaceType = "com.some.resource.or.other.resourceNameInputMappedToOutput";
Component component = new Resource();
component.setNormalizedName("normalizedComponentName");
@@ -339,13 +353,83 @@ public class InterfacesOperationsConverterTest {
final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
String mainYaml = new String(toscaRepresentation.getMainYaml());
- Assert.assertTrue(all(
+ assertTrue(all(
containsAll("resourceNameInputMappedToOutput:", "inputs:"),
containsNone("operations")
).apply(mainYaml));
validateOperationInputs(mainYaml, 2, "name_for_op_1");
}
+ @Test
+ void interfaceWithInputsToscaExportTest() {
+ final Component component = new Service();
+ final InterfaceDefinition aInterfaceWithInput = new InterfaceDefinition();
+ final String interfaceName = "myInterfaceName";
+ final String interfaceType = "my.type." + interfaceName;
+ aInterfaceWithInput.setType(interfaceType);
+ final String input1Name = "input1";
+ final InputDataDefinition input1 = createInput("string", "input1 description", false, "input1 value");
+ final String input2Name = "input2";
+ final InputDataDefinition input2 = createInput("string", "input2 description", true, "input2 value");
+ final Map<String, InputDataDefinition> inputMap = new HashMap<>();
+ inputMap.put(input1Name, input1);
+ inputMap.put(input2Name, input2);
+ aInterfaceWithInput.setInputs(inputMap);
+ component.setInterfaces(new HashMap<>());
+ component.getInterfaces().put(interfaceName, aInterfaceWithInput);
+ final ToscaNodeType nodeType = new ToscaNodeType();
+ interfacesOperationsConverter.addInterfaceDefinitionElement(component, nodeType, dataTypes, false);
+ final ToscaExportHandler handler = new ToscaExportHandler(null, null, null, null, null, null, null, null,
+ interfacesOperationsConverter);
+ final ToscaTemplate template = new ToscaTemplate("testService");
+ final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
+ nodeTypes.put(NODE_TYPE_NAME, nodeType);
+ template.setNode_types(nodeTypes);
+ final ToscaRepresentation toscaRepresentation = handler.createToscaRepresentation(template);
+ final String toscaTemplateYaml = new String(toscaRepresentation.getMainYaml());
+ assertThat(toscaTemplateYaml, allOf(containsString(INPUTS.getElementName() + ":"), containsString(input1Name), containsString(interfaceName)));
+ validateInterfaceInputs(toscaTemplateYaml, interfaceName, inputMap);
+ }
+
+ private void validateInterfaceInputs(final String yaml, final String interfaceName, final Map<String, InputDataDefinition> expectedInputMap) {
+ String fixedMainYaml = yaml;
+ final String nullString = "null";
+ if (fixedMainYaml.startsWith(nullString)) {
+ fixedMainYaml = yaml.substring(nullString.length());
+ }
+ if (fixedMainYaml.endsWith(nullString)) {
+ fixedMainYaml = fixedMainYaml.substring(0, fixedMainYaml.length() - nullString.length());
+ }
+ final Map<String, Object> yamlMap = (Map<String, Object>) new Yaml().load(fixedMainYaml);
+ final Map<String, Object> nodeTypesMap = (Map<String, Object>) yamlMap.get(NODE_TYPES.getElementName());
+ final Map<String, Object> node = (Map<String, Object>) nodeTypesMap.get(NODE_TYPE_NAME);
+ final Map<String, Object> interfacesMap = (Map<String, Object>) node.get(INTERFACES.getElementName());
+ final Map<String, Object> interface1 = (Map<String, Object>) interfacesMap.get(interfaceName);
+ final Map<String, Object> actualInputsMap = (Map<String, Object>) interface1.get(INPUTS.getElementName());
+ assertThat(actualInputsMap.keySet(), containsInAnyOrder(expectedInputMap.keySet().toArray()));
+ expectedInputMap.forEach((inputName, inputDataDefinition) -> {
+ final Map<String, Object> actualInput = (Map<String, Object>) actualInputsMap.get(inputName);
+ compareInputYaml(inputName, actualInput, inputDataDefinition);
+ });
+ }
+
+ private void compareInputYaml(final String inputName, final Map<String, Object> actualInput,
+ final InputDataDefinition expectedInput) {
+ final String msgFormat = "%s should be equal in input %s";
+ String field = TYPE.getElementName();
+ assertThat(String.format(msgFormat, field, inputName),
+ actualInput.get(field), equalTo(expectedInput.getType()));
+ field = DESCRIPTION.getElementName();
+ assertThat(String.format(msgFormat, field, inputName),
+ actualInput.get(field), equalTo(expectedInput.getDescription()));
+ field = REQUIRED.getElementName();
+ assertThat(String.format(msgFormat, field, inputName),
+ actualInput.get(field), equalTo(expectedInput.getRequired()));
+ field = DEFAULT.getElementName();
+ assertThat(String.format(msgFormat, field, inputName),
+ actualInput.get(field), equalTo(expectedInput.getDefaultValue()));
+ }
+
@FunctionalInterface
interface MainYamlAssertion extends Function<String, Boolean> {}
@@ -383,6 +467,24 @@ public class InterfacesOperationsConverterTest {
}
}
+ private InputDataDefinition createInput(final String type, final String description, final Boolean isRequired,
+ final String defaultValue) {
+ final PropertyDataDefinition propertyDataDefinition = new PropertyDataDefinition();
+ if (type != null) {
+ propertyDataDefinition.setType(type);
+ }
+ if (description != null) {
+ propertyDataDefinition.setDescription(description);
+ }
+ if (defaultValue != null) {
+ propertyDataDefinition.setDefaultValue(defaultValue);
+ }
+ if (isRequired != null) {
+ propertyDataDefinition.setRequired(isRequired);
+ }
+ return new InputDataDefinition(propertyDataDefinition);
+ }
+
private ListDataDefinition<OperationInputDefinition> createInputs(Component component, int numOfInputs) {
ListDataDefinition<OperationInputDefinition> operationInputDefinitionList = new ListDataDefinition<>();
for (int i = 0; i < numOfInputs; i++) {
@@ -458,7 +560,11 @@ public class InterfacesOperationsConverterTest {
Map<String, Object> interfaces = toscaNodeType.getInterfaces();
for (Map.Entry<String, Object> interfaceEntry : interfaces.entrySet()) {
Map<String, Object> interfaceDefinition = mapper.convertValue(interfaceEntry.getValue(), Map.class);
- for (Map.Entry<String, Object> operationEntry : interfaceDefinition.entrySet()) {
+ final Map<String, Object> operationsMap = interfaceDefinition.entrySet().stream()
+ .filter(entry -> !INPUTS.getElementName().equals(entry.getKey()) &&
+ !TYPE.getElementName().equals(entry.getKey()))
+ .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+ for (Map.Entry<String, Object> operationEntry : operationsMap.entrySet()) {
Object operationVal = operationEntry.getValue();
if (operationVal instanceof Map) {
//Since the inputs are mapped to output operations from only first interface so using that name
@@ -475,9 +581,9 @@ public class InterfacesOperationsConverterTest {
for (Map.Entry<String, Object> inputEntry : inputs.entrySet()) {
String[] inputNameSplit = inputEntry.getKey().split("_");
Map<String, Object> inputValueObject = (Map<String, Object>) inputEntry.getValue();
- Assert.assertEquals(inputNameSplit[1], inputValueObject.get("type"));
+ assertEquals(inputNameSplit[1], inputValueObject.get("type"));
Boolean expectedIsRequired = Integer.parseInt(inputNameSplit[2]) % 2 == 0;
- Assert.assertEquals(expectedIsRequired, inputValueObject.get("required"));
+ assertEquals(expectedIsRequired, inputValueObject.get("required"));
validateOperationInputDefinitionDefaultValue(interfaceType, operationName, inputNameSplit[1],
Integer.parseInt(inputNameSplit[2]), inputValueObject);
}
@@ -491,19 +597,19 @@ public class InterfacesOperationsConverterTest {
if(mappedInputValue.containsKey(ToscaFunctions.GET_PROPERTY.getFunctionName())) {
String mappedPropertyValue = MAPPED_PROPERTY_NAME + index;
List<String> mappedPropertyDefaultValue = (List<String>) mappedInputValue.get(ToscaFunctions.GET_PROPERTY.getFunctionName());
- Assert.assertEquals(2, mappedPropertyDefaultValue.size());
- Assert.assertTrue(mappedPropertyDefaultValue.contains(SELF));
- Assert.assertTrue(mappedPropertyDefaultValue.contains(mappedPropertyValue));
+ assertEquals(2, mappedPropertyDefaultValue.size());
+ assertTrue(mappedPropertyDefaultValue.contains(SELF));
+ assertTrue(mappedPropertyDefaultValue.contains(mappedPropertyValue));
} else if(mappedInputValue.containsKey(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName())) {
List<String> mappedPropertyDefaultValue = (List<String>) mappedInputValue.get(ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName());
- Assert.assertEquals(4, mappedPropertyDefaultValue.size());
+ assertEquals(4, mappedPropertyDefaultValue.size());
String mappedPropertyValue = OUTPUT_NAME_PREFIX + inputType + "_" + index;
- Assert.assertTrue(mappedPropertyDefaultValue.contains(SELF));
- Assert.assertTrue(mappedPropertyDefaultValue.contains(interfaceType));
- Assert.assertTrue(mappedPropertyDefaultValue.contains(operationName));
- Assert.assertTrue(mappedPropertyDefaultValue.contains(mappedPropertyValue));
+ assertTrue(mappedPropertyDefaultValue.contains(SELF));
+ assertTrue(mappedPropertyDefaultValue.contains(interfaceType));
+ assertTrue(mappedPropertyDefaultValue.contains(operationName));
+ assertTrue(mappedPropertyDefaultValue.contains(mappedPropertyValue));
} else {
- Assert.fail("Invalid Tosca function in default value. Allowed values: "+ ToscaFunctions.GET_PROPERTY.getFunctionName() +
+ fail("Invalid Tosca function in default value. Allowed values: "+ ToscaFunctions.GET_PROPERTY.getFunctionName() +
"/"+ ToscaFunctions.GET_OPERATION_OUTPUT.getFunctionName());
}
}
@@ -522,9 +628,9 @@ public class InterfacesOperationsConverterTest {
Map<String, Object> operationInputs = (Map<String, Object>) operation.get("inputs");
for (Object inputValue : operationInputs.values()) {
Map<String, Object> inputValueAsMap = (Map<String, Object>) inputValue;
- Assert.assertFalse(inputValueAsMap.keySet().contains("type"));
- Assert.assertFalse(inputValueAsMap.keySet().contains("required"));
- Assert.assertFalse(inputValueAsMap.keySet().contains("default"));
+ assertFalse(inputValueAsMap.keySet().contains("type"));
+ assertFalse(inputValueAsMap.keySet().contains("required"));
+ assertFalse(inputValueAsMap.keySet().contains("default"));
}
}
}
@@ -532,7 +638,7 @@ public class InterfacesOperationsConverterTest {
}
@Test
- public void testAddInterfaceTypeElementGetCorrectLocalInterfaceName() {
+ void testAddInterfaceTypeElementGetCorrectLocalInterfaceName() {
Service service = new Service();
service.setComponentMetadataDefinition(new ServiceMetadataDefinition());
service.getComponentMetadataDefinition().getMetadataDataDefinition().setName("LocalInterface");
@@ -542,12 +648,12 @@ public class InterfacesOperationsConverterTest {
Map<String, Object> resultMap = InterfacesOperationsConverter.addInterfaceTypeElement(service,
Collections.singletonList("org.openecomp.interfaces.node.lifecycle.Standard"));
- Assert.assertTrue(MapUtils.isNotEmpty(resultMap)
+ assertTrue(MapUtils.isNotEmpty(resultMap)
&& resultMap.containsKey("org.openecomp.interfaces.node.lifecycle.LocalInterface"));
}
@Test
- public void testAddInterfaceTypeElementNoTypeChangeIfNotLocal() {
+ void testAddInterfaceTypeElementNoTypeChangeIfNotLocal() {
Service service = new Service();
service.setComponentMetadataDefinition(new ServiceMetadataDefinition());
service.getComponentMetadataDefinition().getMetadataDataDefinition().setName("LocalInterface");
@@ -557,7 +663,7 @@ public class InterfacesOperationsConverterTest {
Map<String, Object> resultMap = interfacesOperationsConverter.getInterfacesMap(service, null,
service.getInterfaces(), null, false, false);
- Assert.assertTrue(MapUtils.isNotEmpty(resultMap)
+ assertTrue(MapUtils.isNotEmpty(resultMap)
&& resultMap.containsKey("NotLocal"));
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java
deleted file mode 100644
index b922d0d60d..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/model/ToscaInterfaceDefinitionTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.tosca.model;
-
-import org.junit.Test;
-
-import java.util.Map;
-
-public class ToscaInterfaceDefinitionTest {
-
- private ToscaInterfaceDefinition createTestSubject() {
- return new ToscaInterfaceDefinition();
- }
-
- @Test
- public void testGetType() throws Exception {
- ToscaInterfaceDefinition testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getType();
- }
-
- @Test
- public void testSetType() throws Exception {
- ToscaInterfaceDefinition testSubject;
- String type = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setType(type);
- }
-
- @Test
- public void testGetOperations() throws Exception {
- ToscaInterfaceDefinition testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOperations();
- }
-
- @Test
- public void testSetOperations() throws Exception {
- ToscaInterfaceDefinition testSubject;
- Map<String, Object> toscaOperations = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setOperations(toscaOperations);
- }
-}
diff --git a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
index a28f31b1b0..50906d2624 100644
--- a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
@@ -2038,6 +2038,18 @@ errors:
message: "Error: Failed to delete interface operation.",
messageId: "SVC4702"
}
+ #SVC4732
+ INTERFACE_UNKNOWN: {
+ code: 400,
+ message: "Error: The interface '%1' does not exists in the database.",
+ messageId: "SVC4732"
+ }
+ #SVC4733
+ INTERFACE_OPERATION_NOT_DEFINED: {
+ code: 400,
+ message: "Error: The operation '%1' does not exists in the interface '%2'.",
+ messageId: "SVC4733"
+ }
#-----------SVC4692---------------------------
RESOURCE_LIFECYCLE_STATE_NOT_VALID: {
code: 400,
diff --git a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml
new file mode 100644
index 0000000000..d12664be9d
--- /dev/null
+++ b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-legacy.yaml
@@ -0,0 +1,24 @@
+inputs:
+ stringInput:
+ type: string
+ description: stringInput description
+ required: true
+ default: defaultValue
+ status: aStatus
+ actionInput:
+ type: org.openecomp.resource.datatypes.Action
+type: tosca.interfaces.node.lifecycle.Standard
+create:
+ implementation: "camunda/serviceSelect"
+start:
+ implementation: "camunda/executeAction"
+ inputs:
+ action:
+ type: org.openecomp.resource.datatypes.Action
+stop:
+ implementation: "camunda/executeAction"
+ inputs:
+ action:
+ type: org.openecomp.resource.datatypes.Action
+delete:
+ implementation: "camunda/serviceDeselect" \ No newline at end of file
diff --git a/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml
new file mode 100644
index 0000000000..13dfb9a1fb
--- /dev/null
+++ b/catalog-be/src/test/resources/interfaceDefinition/interfaceDefinition-tosca1.3.yaml
@@ -0,0 +1,25 @@
+inputs:
+ stringInput:
+ type: string
+ description: stringInput description
+ required: true
+ default: defaultValue
+ status: aStatus
+ actionInput:
+ type: org.openecomp.resource.datatypes.Action
+type: tosca.interfaces.node.lifecycle.Standard
+operations:
+ create:
+ implementation: "camunda/serviceSelect"
+ start:
+ implementation: "camunda/executeAction"
+ inputs:
+ action:
+ type: org.openecomp.resource.datatypes.Action
+ stop:
+ implementation: "camunda/executeAction"
+ inputs:
+ action:
+ type: org.openecomp.resource.datatypes.Action
+ delete:
+ implementation: "camunda/serviceDeselect" \ No newline at end of file