diff options
Diffstat (limited to 'common')
3 files changed, 20 insertions, 6 deletions
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java index f7f5d78604..e301edb0fd 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java @@ -32,9 +32,9 @@ public class DSLNodeKey implements QueryStep { private boolean not = false; private final StringBuilder query = new StringBuilder(); private final String keyName; - private final List<String> values; + private final List<Object> values; - public DSLNodeKey(String keyName, String... value) { + public DSLNodeKey(String keyName, Object... value) { this.keyName = keyName; this.values = Arrays.asList(value); @@ -54,14 +54,18 @@ public class DSLNodeKey implements QueryStep { result.append(" !"); } result.append("('").append(keyName).append("', "); - List<String> temp = new ArrayList<>(); - for (String item : values) { + List<Object> temp = new ArrayList<>(); + for (Object item : values) { if ("null".equals(item)) { temp.add(String.format("' %s '", item)); } else if ("".equals(item)) { temp.add("' '"); } else { - temp.add(String.format("'%s'", item)); + if (item instanceof String) { + temp.add(String.format("'%s'", item)); + } else { + temp.add(item); + } } } result.append(Joiner.on(", ").join(temp)).append(")"); diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java index 2fdd6574e5..87d4d84cac 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java @@ -45,7 +45,7 @@ public class __ { return __.<DSLNode>start(new DSLNode(name, key)); } - public static DSLNodeKey key(String keyName, String... value) { + public static DSLNodeKey key(String keyName, Object... value) { return new DSLNodeKey(keyName, value); } diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java index 6e55fe17fa..590e83827b 100644 --- a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java +++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java @@ -108,4 +108,14 @@ public class DSLQueryBuilderTest { builder.equals("pserver*('hostname', 'my-hostname') > p-interface > sriov-pf('pf-pci-id', 'my-id')")); assertTrue(builder.equals(builder)); } + + + @Test + public void mixedTypeTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION, + __.key("cloud-owner", "owner"), __.key("cloud-region-id", "id"))); + builder.to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", 167), __.key("my-boolean", true)).output()); + assertTrue(builder.equals( + "cloud-region('cloud-owner', 'owner')('cloud-region-id', 'id') > vlan-tag*('vlan-id-outer', 167)('my-boolean', true)")); + } } |