diff options
author | Julien Bertozzi <julien.bertozzi@intl.att.com> | 2021-01-07 12:19:52 +0100 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2021-01-12 23:45:13 +0000 |
commit | b7015a8154af46dc6be7643256d95d961ab6c040 (patch) | |
tree | c933485f9b1b3d0b62c35b1c4c017ba3e987baae /catalog-model/src/main/java | |
parent | 69779180f8f4e020606634f9bd8cac728daed2a2 (diff) |
Improve test coverage
Issue-ID: SDC-3428
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Change-Id: I48b6991fbbea31279246d92692760fc6375c7eb5
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Diffstat (limited to 'catalog-model/src/main/java')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java | 22 |
1 files changed, 4 insertions, 18 deletions
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<InterfaceData, JanusGraphOperationStatus> 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<InterfaceData, JanusGraphOperationStatus> 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<Map<String, InterfaceDefinition>, StorageOperationStatus> getAllInterfacesOfResource(String resourceId, boolean recursively, boolean inTransaction) { - Either<Map<String, InterfaceDefinition>, StorageOperationStatus> result = null; Map<String, InterfaceDefinition> interfaces = new HashMap<>(); try { @@ -242,7 +236,6 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation } private JanusGraphOperationStatus findAllInterfacesNotRecursively(String resourceId, Map<String, InterfaceDefinition> interfaces) { - Either<List<ImmutablePair<InterfaceData, GraphEdge>>, 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<String, InterfaceDefinition> interfaces) { - JanusGraphOperationStatus findAllInterfacesNotRecursively = findAllInterfacesNotRecursively(resourceId, interfaces); if (!findAllInterfacesNotRecursively.equals(JanusGraphOperationStatus.OK)) { @@ -307,10 +299,9 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation return parentNodesStatus; } } - ImmutablePair<ResourceMetadataData, GraphEdge> parnetNodePair = parentNodes.left().value(); - String parentUniqueId = parnetNodePair.getKey().getMetadataDataDefinition().getUniqueId(); - JanusGraphOperationStatus - addParentIntStatus = findAllInterfacesRecursively(parentUniqueId, interfaces); + ImmutablePair<ResourceMetadataData, GraphEdge> 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<InterfaceDefinition, StorageOperationStatus> createInterfaceOnResource(InterfaceDefinition interf, String resourceId, String interfaceName, boolean failIfExist, boolean inTransaction) { - Either<InterfaceData, JanusGraphOperationStatus> 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<InterfaceDefinition, StorageOperationStatus> createInterfaceType(InterfaceDefinition interf) { return createInterfaceType(interf, false); } |