From 2afdc20f9478050c41abd67cd2b484688f8047b9 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Tue, 21 Jul 2020 16:31:22 -0400 Subject: always use consumer in output method always use consumer in output method Issue-ID: SO-3084 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I03a36b1b7db702dc95b381f25853efcc073d0900 --- .../client/graphinventory/entities/DSLQueryBuilder.java | 2 +- .../onap/aaiclient/client/aai/DSLQueryBuilderTest.java | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java index 59e3895ce2..c56ce0bfee 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/DSLQueryBuilder.java @@ -63,7 +63,7 @@ public class DSLQueryBuilder { Object obj = steps.get(steps.size() - 1); if (obj instanceof DSLNodeBase) { - ((DSLNodeBase) steps.get(steps.size() - 1)).output(); + consumer.accept((DSLNodeBase) steps.get(steps.size() - 1)); } else if (obj.getClass().getName().contains("$$Lambda$")) { // process lambda expressions for (Field f : obj.getClass().getDeclaredFields()) { diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java index 9cae761399..b0b0c6aca9 100644 --- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java +++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/DSLQueryBuilderTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import org.onap.aaiclient.client.graphinventory.entities.DSLNodeKey; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; +import org.onap.aaiclient.client.graphinventory.entities.Node; import org.onap.aaiclient.client.graphinventory.entities.Output; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; @@ -149,12 +150,20 @@ public class DSLQueryBuilderTest { @Test public void selectOutputFilterTest() { - DSLQueryBuilder builder = - TraversalBuilder.traversal(new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "att-nc")) + DSLQueryBuilder builder = TraversalBuilder + .traversal(new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")) .output("cloud-region-id", "a", "b")); builder.to(__.node(AAIObjectType.PSERVER)).output("x", "y", "z"); - assertEquals("cloud-region{'cloud-region-id', 'a', 'b'}('cloud-owner', 'att-nc') > pserver{'x', 'y', 'z'}", + assertEquals("cloud-region{'cloud-region-id', 'a', 'b'}('cloud-owner', 'CloudOwner') > pserver{'x', 'y', 'z'}", builder.build().toString()); } + + @Test + public void selectOutputFilterOnNodeTest() { + DSLStartNode node = new DSLStartNode(AAIObjectType.CLOUD_REGION, __.key("cloud-owner", "CloudOwner")); + DSLQueryBuilder builder = TraversalBuilder.fragment(node).output("cloud-region-id"); + + assertEquals("cloud-region{'cloud-region-id'}('cloud-owner', 'CloudOwner')", builder.build().toString()); + } } -- cgit 1.2.3-korg