From b7015a8154af46dc6be7643256d95d961ab6c040 Mon Sep 17 00:00:00 2001 From: Julien Bertozzi Date: Thu, 7 Jan 2021 12:19:52 +0100 Subject: Improve test coverage Issue-ID: SDC-3428 Signed-off-by: JulienBe Change-Id: I48b6991fbbea31279246d92692760fc6375c7eb5 Signed-off-by: JulienBe --- .../impl/InterfaceLifecycleOperation.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'catalog-model/src/main/java') 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 5c5bf8939a..87f01cd97e 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 @@ -123,21 +123,16 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } private Either addInterfaceToGraph(InterfaceDefinition interfaceInfo, String interfaceName, String resourceId) { - InterfaceData interfaceData = new InterfaceData(interfaceInfo); - ResourceMetadataData resourceData = new ResourceMetadataData(); resourceData.getMetadataDataDefinition().setUniqueId(resourceId); String interfaceNameSplitted = getShortInterfaceName(interfaceInfo); - interfaceInfo.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(resourceId, interfaceNameSplitted)); Either existInterface = janusGraphGenericDao .getNode(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), InterfaceData.class); - if (existInterface.isRight()) { - return createInterfaceNodeAndRelation(interfaceNameSplitted, resourceId, interfaceData, resourceData); } else { log.debug("Interface {} already exist", interfaceData.getUniqueId()); @@ -205,7 +200,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation @Override public Either, StorageOperationStatus> getAllInterfacesOfResource(String resourceId, boolean recursively, boolean inTransaction) { - Either, StorageOperationStatus> result = null; Map interfaces = new HashMap<>(); try { @@ -242,7 +236,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } private JanusGraphOperationStatus findAllInterfacesNotRecursively(String resourceId, Map interfaces) { - Either>, JanusGraphOperationStatus> interfaceNodes = janusGraphGenericDao .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), resourceId, GraphEdgeLabels.INTERFACE, NodeTypeEnum.Interface, InterfaceData.class); @@ -286,7 +279,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } public JanusGraphOperationStatus findAllInterfacesRecursively(String resourceId, Map interfaces) { - JanusGraphOperationStatus findAllInterfacesNotRecursively = findAllInterfacesNotRecursively(resourceId, interfaces); if (!findAllInterfacesNotRecursively.equals(JanusGraphOperationStatus.OK)) { @@ -307,10 +299,9 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation return parentNodesStatus; } } - ImmutablePair parnetNodePair = parentNodes.left().value(); - String parentUniqueId = parnetNodePair.getKey().getMetadataDataDefinition().getUniqueId(); - JanusGraphOperationStatus - addParentIntStatus = findAllInterfacesRecursively(parentUniqueId, interfaces); + ImmutablePair parentNodePair = parentNodes.left().value(); + String parentUniqueId = parentNodePair.getKey().getMetadataDataDefinition().getUniqueId(); + JanusGraphOperationStatus addParentIntStatus = findAllInterfacesRecursively(parentUniqueId, interfaces); if (addParentIntStatus != JanusGraphOperationStatus.OK) { log.error("Failed to fetch all interfaces of resource {}", parentUniqueId); @@ -642,9 +633,7 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation @Override public Either createInterfaceOnResource(InterfaceDefinition interf, String resourceId, String interfaceName, boolean failIfExist, boolean inTransaction) { - Either status = addInterfaceToGraph(interf, interfaceName, resourceId); - if (status.isRight()) { janusGraphGenericDao.rollback(); log.error("Failed to add interface {} to resource {}", interfaceName, resourceId); @@ -711,7 +700,7 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation janusGraphGenericDao.commit(); } - Operation opDefResult = status.left().value();// convertOperationDataToOperation(operationData); + Operation opDefResult = status.left().value(); log.debug("The returned Operation is {}", opDefResult); return Either.left(opDefResult); } @@ -916,9 +905,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation return interfaceName.toLowerCase(); } - /** - * - */ public Either createInterfaceType(InterfaceDefinition interf) { return createInterfaceType(interf, false); } -- cgit 1.2.3-korg