From 0ed125f98ae8ea9e80c855a640c328654660d081 Mon Sep 17 00:00:00 2001 From: davsad Date: Sat, 24 Jul 2021 19:40:56 +0100 Subject: Consider component model when retrieving interface types Issue-ID: SDC-3414 Signed-off-by: davsad Change-Id: Ie16a2604cfdff042e32bfa4f9a3a509b5da22226 --- .../model/operations/api/IInterfaceLifecycleOperation.java | 7 +++++-- .../model/operations/impl/InterfaceLifecycleOperation.java | 4 ++-- .../operations/impl/InterfaceLifecycleOperationTest.java | 13 +++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java index 6783fcda13..a30405527f 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java @@ -19,12 +19,14 @@ */ package org.openecomp.sdc.be.model.operations.api; -import fj.data.Either; import java.util.Map; + import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Operation; +import fj.data.Either; + public interface IInterfaceLifecycleOperation { public Either createInterfaceOnResource(InterfaceDefinition interf, String resourceId, @@ -56,5 +58,6 @@ public interface IInterfaceLifecycleOperation { public String getShortInterfaceName(InterfaceDataDefinition interfaceDefinition); - Either, StorageOperationStatus> getAllInterfaceLifecycleTypes(); + Either, StorageOperationStatus> getAllInterfaceLifecycleTypes(final String model); + } 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 3fa1f8933d..9299aec7e0 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 @@ -850,9 +850,9 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } @Override - public Either, StorageOperationStatus> getAllInterfaceLifecycleTypes() { + public Either, StorageOperationStatus> getAllInterfaceLifecycleTypes(final String model) { Either, JanusGraphOperationStatus> allInterfaceLifecycleTypes = janusGraphGenericDao - .getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class); + .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), model, InterfaceData.class); if (allInterfaceLifecycleTypes.isRight()) { return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(allInterfaceLifecycleTypes.right().value())); } 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 0b5a7fae81..4e0d68f7e2 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 @@ -31,6 +31,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Assert; import org.junit.Before; @@ -156,9 +157,9 @@ public class InterfaceLifecycleOperationTest { @Test public void testGetAllInterfaceLifecycleTypes_TypesNotFound() { - when(janusGraphGenericDao.getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), + when(janusGraphGenericDao.getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), StringUtils.EMPTY, InterfaceData.class)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); - Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(); + Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(StringUtils.EMPTY); Assert.assertEquals(types.isRight(), Boolean.TRUE); } @@ -173,14 +174,14 @@ public class InterfaceLifecycleOperationTest { interfaceDataList.add(interfaceData); Either, JanusGraphOperationStatus> allInterfaceTypes = Either.left(interfaceDataList); when(janusGraphGenericDao - .getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class)).thenReturn(allInterfaceTypes); + .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), StringUtils.EMPTY, InterfaceData.class)).thenReturn(allInterfaceTypes); List> list = new ArrayList<>(); Either>, JanusGraphOperationStatus> childrenNodes = Either.left(list); when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(childrenNodes); when(janusGraphGenericDao.getParentNode(any(), any(), any(), any(), any())) .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); - Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(); + Either, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(StringUtils.EMPTY); Assert.assertEquals(types.left().value().size(),1); } @@ -200,10 +201,10 @@ public class InterfaceLifecycleOperationTest { when(janusGraphGenericDao.getParentNode(any(), any(), any(), any(), any())) .thenReturn(Either.left(modelNode)); when(janusGraphGenericDao - .getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class)).thenReturn(Either.left(interfaceTypes)); + .getByCriteriaForModel(NodeTypeEnum.Interface, Collections.emptyMap(), MODEL_NAME, InterfaceData.class)).thenReturn(Either.left(interfaceTypes)); when(janusGraphGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(Either.left(Collections.emptyList())); - Assert.assertEquals(1, interfaceLifecycleOperation.getAllInterfaceLifecycleTypes().left().value().size()); + Assert.assertEquals(1, interfaceLifecycleOperation.getAllInterfaceLifecycleTypes(MODEL_NAME).left().value().size()); } } -- cgit 1.2.3-korg