aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java37
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InterfaceTypeServlet.java90
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java4
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java2
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java15
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java8
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java21
9 files changed, 188 insertions, 36 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
index b371a8c18d..49b1b741cd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManager.java
@@ -17,8 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.components.impl;
+import fj.data.Either;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -30,9 +32,7 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-
import javax.annotation.Resource;
-
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@@ -50,8 +50,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.stereotype.Component;
-import fj.data.Either;
-
@Component("interfaceLifecycleTypeImportManager")
public class InterfaceLifecycleTypeImportManager {
@@ -67,7 +65,8 @@ public class InterfaceLifecycleTypeImportManager {
public Either<List<InterfaceDefinition>, ResponseFormat> createLifecycleTypes(String interfaceLifecycleTypesYml, final String modelName,
final boolean includeToModelDefaultImports) {
- Either<List<InterfaceDefinition>, ActionStatus> interfaces = createInterfaceTypeFromYml(interfaceLifecycleTypesYml, modelName);
+ Either<List<InterfaceDefinition>, ActionStatus> interfaces =
+ createInterfaceTypeFromYml(interfaceLifecycleTypesYml, modelName, !includeToModelDefaultImports);
if (interfaces.isRight()) {
ActionStatus status = interfaces.right().value();
ResponseFormat responseFormat = componentsUtils.getResponseFormatByGroupType(status, null);
@@ -80,17 +79,28 @@ public class InterfaceLifecycleTypeImportManager {
return elementTypes;
}
- private Either<List<InterfaceDefinition>, ActionStatus> createInterfaceTypeFromYml(final String interfaceTypesYml, final String modelName) {
- final Either<List<InterfaceDefinition>, ActionStatus> interfaceTypes = commonImportManager.createElementTypesFromYml(interfaceTypesYml, this::createInterfaceDefinition);
- if (interfaceTypes.isLeft() && StringUtils.isNotEmpty(modelName)){
+ private Either<List<InterfaceDefinition>, ActionStatus> createInterfaceTypeFromYml(final String interfaceTypesYml, final String modelName,
+ final boolean normative) {
+ final Either<List<InterfaceDefinition>, ActionStatus> interfaceTypesEither =
+ commonImportManager.createElementTypesFromYml(interfaceTypesYml, this::createInterfaceDefinition);
+ if (interfaceTypesEither.isRight()) {
+ return interfaceTypesEither;
+ }
+ final List<InterfaceDefinition> interfaceTypes = interfaceTypesEither.left().value();
+ if (StringUtils.isNotEmpty(modelName)) {
final Optional<Model> modelOptional = modelOperation.findModelByName(modelName);
if (modelOptional.isPresent()) {
- interfaceTypes.left().value().forEach(interfaceType -> interfaceType.setModel(modelName));
- return interfaceTypes;
+ interfaceTypes.forEach(interfaceType -> {
+ interfaceType.setModel(modelName);
+ interfaceType.setUserCreated(!normative);
+ });
+ return Either.left(interfaceTypes);
}
return Either.right(ActionStatus.INVALID_MODEL);
+ } else {
+ interfaceTypes.forEach(interfaceType -> interfaceType.setUserCreated(!normative));
}
- return interfaceTypes;
+ return Either.left(interfaceTypes);
}
private Either<List<InterfaceDefinition>, ResponseFormat> createInterfacesByDao(List<InterfaceDefinition> interfacesToCreate) {
@@ -148,8 +158,9 @@ public class InterfaceLifecycleTypeImportManager {
.asList(ToscaTagNamesEnum.DERIVED_FROM.getElementName(), ToscaTagNamesEnum.DESCRIPTION.getElementName(),
ToscaTagNamesEnum.VERSION.getElementName(), ToscaTagNamesEnum.METADATA.getElementName(),
ToscaTagNamesEnum.INPUTS.getElementName(), ToscaTagNamesEnum.NOTIFICATIONS.getElementName());
-
- Stream<Entry<String, Object>> oldFormatOperations = toscaJson.entrySet().stream().filter(interfaceEntry -> !entitySchemaEntryList.contains(interfaceEntry.getKey()));
+
+ Stream<Entry<String, Object>> oldFormatOperations =
+ toscaJson.entrySet().stream().filter(interfaceEntry -> !entitySchemaEntryList.contains(interfaceEntry.getKey()));
operationsMap = new HashMap<>();
oldFormatOperations.forEach(entry -> operationsMap.put(entry.getKey(), entry.getValue()));
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InterfaceTypeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InterfaceTypeServlet.java
new file mode 100644
index 0000000000..fb46336bca
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/InterfaceTypeServlet.java
@@ -0,0 +1,90 @@
+/*
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2023 Nordix Foundation. 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.servlets;
+
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.enums.ParameterIn;
+import io.swagger.v3.oas.annotations.servers.Server;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.exception.OperationException;
+import org.openecomp.sdc.be.model.normatives.ElementTypeEnum;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.stereotype.Controller;
+
+@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
+@Path("/v1/catalog/interface-types")
+@Tag(name = "SDCE-2 APIs")
+@Server(url = "/sdc2/rest")
+@Controller
+public class InterfaceTypeServlet extends BeGenericServlet {
+
+ private static final Logger log = Logger.getLogger(InterfaceTypeServlet.class);
+ private final InterfaceLifecycleOperation interfaceLifecycleOperation;
+
+ public InterfaceTypeServlet(final ComponentsUtils componentsUtils,
+ InterfaceLifecycleOperation interfaceLifecycleOperation) {
+ super(componentsUtils);
+ this.interfaceLifecycleOperation = interfaceLifecycleOperation;
+ }
+
+ @DELETE
+ @Path("{interfaceTypeId}")
+ public Response deleteInterfaceType(@Parameter(in = ParameterIn.PATH, required = true, description = "The interface type id")
+ @PathParam("interfaceTypeId") final String interfaceTypeId) {
+ final Either<InterfaceDefinition, StorageOperationStatus> interfaceTypeEither = interfaceLifecycleOperation.getInterface(interfaceTypeId);
+ if (interfaceTypeEither.isRight()) {
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INTERFACE_LIFECYCLE_TYPES_NOT_FOUND,
+ String.format("Failed to find interface type '%s'", interfaceTypeId)));
+ }
+ final InterfaceDefinition interfaceDefinition = interfaceTypeEither.left().value();
+ if (!interfaceDefinition.isUserCreated()) {
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES,
+ ElementTypeEnum.INTERFACE_LIFECYCLE_TYPE.getToscaEntryName(),
+ interfaceTypeId));
+ }
+ if (StringUtils.isEmpty(interfaceDefinition.getModel())) {
+ interfaceDefinition.setModel(Constants.DEFAULT_MODEL_NAME);
+ }
+ try {
+ interfaceLifecycleOperation.deleteInterfaceTypeById(interfaceTypeId);
+ interfaceLifecycleOperation.removeInterfaceTypeFromAdditionalType(interfaceDefinition);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete Interface Type");
+ log.debug("delete interface type failed with exception ", e);
+ throw e;
+ }
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.NO_CONTENT), null);
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
index 4f3c4c0e63..062a9fd56f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.resources.data;
import java.util.HashMap;
@@ -52,6 +53,8 @@ public class InterfaceData extends GraphNode {
interfaceDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
interfaceDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
interfaceDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ final Object normativeProperty = properties.get(GraphPropertiesDictionary.NORMATIVE.getProperty());
+ interfaceDataDefinition.setUserCreated(!(normativeProperty instanceof Boolean && (Boolean) normativeProperty));
}
public InterfaceDataDefinition getInterfaceDataDefinition() {
@@ -75,6 +78,7 @@ public class InterfaceData extends GraphNode {
addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.NORMATIVE, !interfaceDataDefinition.isUserCreated());
return map;
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
index b8ddff9907..d8a2d44967 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
@@ -325,7 +325,7 @@ public class DataTypeOperation extends AbstractOperation {
}
public void removeDataTypeFromAdditionalType(final DataTypeDataDefinition dataTypeDataDefinition) {
- modelOperation.removeDataTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, dataTypeDataDefinition.getModel(),
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, dataTypeDataDefinition.getModel(),
dataTypeDataDefinition.getName());
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
index 9299aec7e0..7fc97ccabc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
@@ -17,8 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.model.operations.impl;
+import fj.data.Either;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -27,8 +29,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
-
+import javax.annotation.Resource;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
@@ -42,6 +45,7 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.normatives.ElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.ArtifactData;
@@ -53,8 +57,6 @@ import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
-import fj.data.Either;
-
@Component("interface-operation")
public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation {
@@ -65,6 +67,9 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
private ArtifactOperation artifactOperation;
@javax.annotation.Resource
private JanusGraphGenericDao janusGraphGenericDao;
+ @Resource
+ private ModelOperation modelOperation;
+
public InterfaceLifecycleOperation() {
super();
}
@@ -816,7 +821,8 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
final GraphNode from = new UniqueIdData(NodeTypeEnum.Model, UniqueIdBuilder.buildModelUid(model));
final GraphNode to = new UniqueIdData(NodeTypeEnum.Interface, interfaceDefinition.getUniqueId());
log.info("Connecting model {} to type {}", from, to);
- return janusGraphGenericDao.createRelation(from , to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap()).right().map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
+ return janusGraphGenericDao.createRelation(from, to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap()).right()
+ .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
}
@Override
@@ -860,7 +866,7 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
List<InterfaceData> interfaceDataList = allInterfaceLifecycleTypes.left().value();
List<InterfaceDefinition> interfaceDefinitions = interfaceDataList.stream().map(this::convertInterfaceDataToInterfaceDefinition)
.filter(interfaceDefinition -> interfaceDefinition.getUniqueId()
- .equalsIgnoreCase(UniqueIdBuilder.buildInterfaceTypeUid(interfaceDefinition.getModel(), interfaceDefinition.getType()))
+ .equalsIgnoreCase(UniqueIdBuilder.buildInterfaceTypeUid(interfaceDefinition.getModel(), interfaceDefinition.getType()))
).collect(Collectors.toList());
for (InterfaceDefinition interfaceDefinition : interfaceDefinitions) {
Either<List<ImmutablePair<OperationData, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = janusGraphGenericDao
@@ -881,11 +887,36 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
private String getModelAssociatedToInterface(String uid) {
final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> model = janusGraphGenericDao.getParentNode(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), uid, GraphEdgeLabels.MODEL_ELEMENT,
- NodeTypeEnum.Model, ModelData.class);
+ UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), uid, GraphEdgeLabels.MODEL_ELEMENT,
+ NodeTypeEnum.Model, ModelData.class);
if (model.isLeft()) {
return model.left().value().getLeft().getName();
}
return null;
}
+
+ public void deleteInterfaceTypeById(String interfaceTypeId) {
+ try (final GraphTraversalSource traversal = janusGraphGenericDao.getJanusGraph().traversal()) {
+ traversal.V()
+ .has(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), interfaceTypeId)
+ .out(GraphEdgeLabels.INTERFACE_OPERATION.getProperty())
+ .toList()
+ .forEach(interfaceOperationVertex -> {
+ traversal.V(interfaceOperationVertex).out(GraphEdgeLabels.PROPERTY.getProperty()).drop().iterate();
+ interfaceOperationVertex.remove();
+ });
+ traversal.V().has(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), interfaceTypeId).toList()
+ .forEach(interfaceTypeVertex -> {
+ traversal.V(interfaceTypeVertex).out(GraphEdgeLabels.PROPERTY.getProperty()).drop().iterate();
+ interfaceTypeVertex.remove();
+ });
+ } catch (Exception e) {
+ log.error("Failed to delete interface type {} and interface operations in graph. {}", interfaceTypeId, e);
+ }
+ }
+
+ public void removeInterfaceTypeFromAdditionalType(InterfaceDefinition interfaceDefinition) {
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.INTERFACE_LIFECYCLE_TYPE, interfaceDefinition.getModel(),
+ interfaceDefinition.getType());
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
index b57c57a9cc..785ca41033 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
@@ -457,7 +457,7 @@ public class ModelOperation {
toscaModelImportCassandraDao.saveAll(modelName, rebuiltModelImportList);
}
- public void removeDataTypeFromAdditionalType(final ElementTypeEnum elementTypeEnum, final String modelName, final String name) {
+ public void removeTypeFromAdditionalType(final ElementTypeEnum elementTypeEnum, final String modelName, final String name) {
final List<ToscaImportByModel> modelImportList = toscaModelImportCassandraDao.findAllByModel(modelName);
final Optional<ToscaImportByModel> additionalTypeDefinitionsImportOptional = modelImportList.stream()
.filter(t -> ADDITIONAL_TYPE_DEFINITIONS_PATH.equals(Path.of(t.getFullPath()))).findAny();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
index b8230ff87a..d73e7092cc 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import fj.data.Either;
@@ -51,6 +52,7 @@ import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.ModelTestBase;
+import org.openecomp.sdc.be.model.normatives.ElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
import org.openecomp.sdc.be.resources.data.InterfaceData;
@@ -70,6 +72,7 @@ public class InterfaceLifecycleOperationTest {
private static String INTERFACE_TYPE = "tosca.interfaces.standard";
JanusGraphGenericDao janusGraphGenericDao = Mockito.mock(JanusGraphGenericDao.class);
+ ModelOperation modelOperation = Mockito.mock(ModelOperation.class);
@InjectMocks
private InterfaceLifecycleOperation interfaceLifecycleOperation = new InterfaceLifecycleOperation();
@@ -217,4 +220,16 @@ public class InterfaceLifecycleOperationTest {
Assert.assertEquals(1, interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(MODEL_NAME).left().value().size());
}
+
+ @Test
+ void removeInterfaceTypeFromAdditionalType() {
+ String modelName = "model";
+ String interfaceType = "tosca.artifact.interface.PreviouslyExistingType1";
+ InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ interfaceDefinition.setModel(modelName);
+ interfaceDefinition.setType(interfaceType);
+
+ interfaceLifecycleOperation.removeInterfaceTypeFromAdditionalType(interfaceDefinition);
+ verify(modelOperation).removeTypeFromAdditionalType(ElementTypeEnum.INTERFACE_LIFECYCLE_TYPE, modelName, interfaceType);
+ }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
index c68ed71a07..5e9fc199f0 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
@@ -646,7 +646,7 @@ class ModelOperationTest extends ModelTestBase {
when(toscaModelImportCassandraDao.findAllByModel(modelName)).thenReturn(modelImports);
String dataTypeName = "tosca.datatypes.nfv.PreviouslyExistingType1";
- modelOperation.removeDataTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, modelName, dataTypeName);
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, modelName, dataTypeName);
ArgumentCaptor<List<ToscaImportByModel>> importListArgumentCaptor = ArgumentCaptor.forClass(List.class);
verify(toscaModelImportCassandraDao).saveAll(eq(modelName), importListArgumentCaptor.capture());
@@ -658,7 +658,7 @@ class ModelOperationTest extends ModelTestBase {
expectedAdditionalTypesImport.setFullPath(ADDITIONAL_TYPE_DEFINITIONS_PATH.toString());
expectedAdditionalTypesImport.setContent(Files.readString(testResourcePath.resolve(Path.of("expected-additional_types-5.yaml"))));
final ToscaImportByModel actualAdditionalTypesImport =
- actualImportList.stream().filter(expectedAdditionalTypesImport::equals).findFirst().orElse(null);
+ actualImportList.stream().filter(expectedAdditionalTypesImport::equals).findFirst().orElse(null);
assertNotNull(actualAdditionalTypesImport);
assertEquals(expectedAdditionalTypesImport.getContent(), actualAdditionalTypesImport.getContent());
}
@@ -679,7 +679,7 @@ class ModelOperationTest extends ModelTestBase {
when(toscaModelImportCassandraDao.findAllByModel(modelName)).thenReturn(modelImports);
String dataTypeName = "tosca.datatypes.nfv.PreviouslyExistingType1";
- modelOperation.removeDataTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, modelName, dataTypeName);
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, modelName, dataTypeName);
ArgumentCaptor<List<ToscaImportByModel>> importListArgumentCaptor = ArgumentCaptor.forClass(List.class);
verify(toscaModelImportCassandraDao).saveAll(eq(modelName), importListArgumentCaptor.capture());
@@ -691,7 +691,7 @@ class ModelOperationTest extends ModelTestBase {
expectedAdditionalTypesImport.setFullPath(ADDITIONAL_TYPE_DEFINITIONS_PATH.toString());
expectedAdditionalTypesImport.setContent(Files.readString(testResourcePath.resolve(Path.of("expected-additional_types-6.yaml"))));
final ToscaImportByModel actualAdditionalTypesImport =
- actualImportList.stream().filter(expectedAdditionalTypesImport::equals).findFirst().orElse(null);
+ actualImportList.stream().filter(expectedAdditionalTypesImport::equals).findFirst().orElse(null);
assertNotNull(actualAdditionalTypesImport);
assertEquals(expectedAdditionalTypesImport.getContent(), actualAdditionalTypesImport.getContent());
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java
index 97730fbc4b..a76e442ba9 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/elements/InterfaceDataDefinition.java
@@ -17,24 +17,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.datatypes.elements;
+import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.TOSCA_RESOURCE_NAME;
+
import com.fasterxml.jackson.annotation.JsonCreator;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields.TOSCA_RESOURCE_NAME;
-
public class InterfaceDataDefinition extends ToscaDataDefinition implements Serializable {
@Getter
@Setter
private boolean userCreated;
+
public InterfaceDataDefinition(String type, String description) {
this();
setType(type);
@@ -93,6 +94,10 @@ public class InterfaceDataDefinition extends ToscaDataDefinition implements Seri
return (String) getToscaPresentationValue(TOSCA_RESOURCE_NAME);
}
+ public void setToscaResourceName(String toscaResourceName) {
+ setToscaPresentationValue(TOSCA_RESOURCE_NAME, toscaResourceName);
+ }
+
public Map<String, OperationDataDefinition> getOperations() {
return (Map<String, OperationDataDefinition>) getToscaPresentationValue(JsonPresentationFields.OPERATIONS);
}
@@ -101,10 +106,6 @@ public class InterfaceDataDefinition extends ToscaDataDefinition implements Seri
setToscaPresentationValue(JsonPresentationFields.OPERATIONS, operations);
}
- public void setToscaResourceName(String toscaResourceName) {
- setToscaPresentationValue(TOSCA_RESOURCE_NAME, toscaResourceName);
- }
-
public Long getCreationDate() {
return (Long) getToscaPresentationValue(JsonPresentationFields.CREATION_DATE);
}