From 035ad742f60bdb375ee4e2da4345d404949a19b4 Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 11 Jan 2023 19:19:05 +0000 Subject: Improve test coverage - extract duplicated code - remove redundant and unused code Signed-off-by: Vasyl Razinkov Change-Id: I7ae3592951f53bbebf10a80f7cce22d54b2940b6 Issue-ID: SDC-4317 --- .../jsonjanusgraph/operations/ToscaElementOperation.java | 11 ++++------- .../operations/NodeTemplateOperationGraphTest.java | 2 +- .../operations/ToscaElementOperationCatalogTest.java | 5 ++--- .../sdc/be/model/jsonjanusgraph/utils/GraphTestUtils.java | 2 +- .../operations/impl/ToscaElementLifecycleOperationTest.java | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java index 65c109c3f6..910d7ae1b6 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java @@ -1021,8 +1021,7 @@ public abstract class ToscaElementOperation extends BaseOperation { protected JanusGraphOperationStatus setResourceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) { List categories = new ArrayList<>(); SubCategoryDefinition subcategory; - Either childVertex = janusGraphDao - .getChildVertex(vertex, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.NoParse); + Either childVertex = janusGraphDao.getChildVertex(vertex, EdgeLabelEnum.CATEGORY); if (childVertex.isRight()) { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, EdgeLabelEnum.CATEGORY, catalogComponent.getUniqueId(), childVertex.right().value()); @@ -1041,8 +1040,7 @@ public abstract class ToscaElementOperation extends BaseOperation { .fromJson((String) subCategoryV.property(GraphPropertyEnum.METADATA_KEYS.getProperty()).value(), listTypeSubcat) : Collections.emptyList(); subcategory.setMetadataKeys(metadataKeys); - Either parentVertex = janusGraphDao - .getParentVertex(subCategoryV, EdgeLabelEnum.SUB_CATEGORY, JsonParseFlagEnum.NoParse); + Either parentVertex = janusGraphDao.getParentVertex(subCategoryV, EdgeLabelEnum.SUB_CATEGORY); Vertex categoryV = parentVertex.left().value(); String categoryNormalizedName = (String) categoryV.property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()).value(); catalogComponent.setCategoryNormalizedName(categoryNormalizedName); @@ -1058,8 +1056,7 @@ public abstract class ToscaElementOperation extends BaseOperation { protected JanusGraphOperationStatus setServiceCategoryFromGraphV(Vertex vertex, CatalogComponent catalogComponent) { List categories = new ArrayList<>(); - Either childVertex = janusGraphDao - .getChildVertex(vertex, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.NoParse); + Either childVertex = janusGraphDao.getChildVertex(vertex, EdgeLabelEnum.CATEGORY); if (childVertex.isRight()) { log.debug(FAILED_TO_FETCH_FOR_TOSCA_ELEMENT_WITH_ID_ERROR, EdgeLabelEnum.CATEGORY, catalogComponent.getUniqueId(), childVertex.right().value()); @@ -1338,7 +1335,7 @@ public abstract class ToscaElementOperation extends BaseOperation { StopWatch stopWatch = new StopWatch(); stopWatch.start(); Map existInCatalog = new HashMap<>(); - Either, JanusGraphOperationStatus> verticesEither = janusGraphDao.getCatalogOrArchiveVerticies(isCatalog); + Either, JanusGraphOperationStatus> verticesEither = janusGraphDao.getCatalogOrArchiveVertices(isCatalog); if (verticesEither.isRight()) { return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(verticesEither.right().value())); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java index b2db75933a..45cb5efb62 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTemplateOperationGraphTest.java @@ -81,7 +81,7 @@ public class NodeTemplateOperationGraphTest extends ModelTestBase { @BeforeEach public void before() { - Either graph = janusGraphDao.getGraph(); + Either graph = janusGraphDao.getJanusGraphClient().getGraph(); graphT = graph.left().value(); containerVertex = new GraphVertex(VertexTypeEnum.TOPOLOGY_TEMPLATE); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java index 29fbd755f5..28f9fc8652 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java @@ -34,7 +34,6 @@ import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; -import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.model.catalog.CatalogComponent; @@ -73,8 +72,8 @@ public class ToscaElementOperationCatalogTest { @Before public void setUp() { vertexList.add(vertex); - when(janusGraphDao.getCatalogOrArchiveVerticies(true)).thenReturn(Either.left(vertexList.iterator())); - when(janusGraphDao.getChildVertex(vertex, EdgeLabelEnum.CATEGORY, JsonParseFlagEnum.NoParse)) + when(janusGraphDao.getCatalogOrArchiveVertices(true)).thenReturn(Either.left(vertexList.iterator())); + when(janusGraphDao.getChildVertex(vertex, EdgeLabelEnum.CATEGORY)) .thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND)); when(vertex.property(GraphPropertiesDictionary.METADATA.getProperty())).thenReturn(property); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/GraphTestUtils.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/GraphTestUtils.java index c5c01bba02..afe2dcc254 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/GraphTestUtils.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/GraphTestUtils.java @@ -97,7 +97,7 @@ public final class GraphTestUtils { } public static void clearGraph(JanusGraphDao janusGraphDao) { - Either graphResult = janusGraphDao.getGraph(); + Either graphResult = janusGraphDao.getJanusGraphClient().getGraph(); JanusGraph graph = graphResult.left().value(); Iterable vertices = graph.query().vertices(); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java index abb5a1888b..ce7d7d49df 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java @@ -616,7 +616,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { } private void clearGraph() { - Either graphResult = janusGraphDao.getGraph(); + Either graphResult = janusGraphDao.getJanusGraphClient().getGraph(); JanusGraph graph = graphResult.left().value(); Iterable vertices = graph.query().vertices(); -- cgit 1.2.3-korg