diff options
Diffstat (limited to 'aai-traversal/src/test/java')
9 files changed, 774 insertions, 129 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java index 7918eb3..311de49 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/DslConsumerTest.java @@ -20,13 +20,14 @@ package org.onap.aai.rest; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraphTransaction; +import org.junit.Assert; import org.junit.Test; -import org.junit.Ignore; -import org.onap.aai.HttpTestUtil; import org.onap.aai.PayloadUtil; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.util.AAIConfig; @@ -52,9 +53,116 @@ public class DslConsumerTest extends AbstractSpringRestTest { boolean success = true; try { GraphTraversalSource g = transaction.traversal(); - g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl") + Vertex p1 = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl") .property("in-maint", false).property("source-of-truth", "JUNIT") .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-dsl").next(); + Vertex p2 = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl-02") + .property("in-maint", false).property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-dsl-02").next(); + Vertex p3 = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl-03") + .property("in-maint", false).property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-dsl-03").next(); + Vertex p4 = g.addV().property("aai-node-type", "pserver").property("hostname", "test-pserver-dsl-04") + .property("in-maint", false).property("source-of-truth", "JUNIT") + .property("number-of-cpus", 364).property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/pservers/pserver/test-pserver-dsl-04").next(); + Vertex c1 = g.addV().property("aai-node-type", "complex").property("physical-location-id", "test-complex-dsl") + .property("state", "NJ") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/complexes/complex/test-complex-dsl").next(); + Vertex cr1 = g.addV().property("aai-node-type", "cloud-region") + .property("cloud-owner", "test-cloud-owner-01") + .property("cloud-region-id", "test-cloud-region-id-01") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/cloud-regions/cloud-region/test-cloud-owner-01/test-cloud-region-id-01").next(); + Vertex pnf01 = g.addV().property("aai-node-type", "pnf") + .property("pnf-name", "test-pnf-name-01") + .property("in-maint", false) + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/network/pnfs/pnf/test-pnf-name-01").next(); + Vertex vserver2 = g.addV().property("aai-node-type", "vserver") + .property("vserver-id", "test-vserver-id-2") + .property("vserver-name", "test-vserver-name-2") + .property("in-maint", "false") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/vservers/vserver/test-vserver-id-2").next(); + Vertex tenant2 = g.addV().property("aai-node-type", "tenant") + .property("tenant-id", "test-tenant-id-2") + .property("tenant-name", "test-tenant-name-2") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/tenants/tenant/test-tenant-id-2").next(); + Vertex linterface2 = g.addV().property("aai-node-type", "l-interface") + .property("interface-name", "test-interface-name-02") + .property("priority", "123") + .property("is-port-mirrored", "true") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/l-interfaces/l-interface/test-interface-name-02").next(); + Vertex oamNetwork2 = g.addV().property("aai-node-type", "oam-network") + .property("network-uuid", "test-network-uuid-02") + .property("network-name", "test-network-name-02") + .property("cvlan-tag", "456") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/oam-networks/oam-network/test-network-uuid-02").next(); + Vertex cr2 = g.addV().property("aai-node-type", "cloud-region") + .property("cloud-owner", "test-cloud-owner-02") + .property("cloud-region-id", "test-cloud-region-id-02") + .property("source-of-truth", "JUNIT") + .property("aai-uri", "/cloud-infrastructure/cloud-regions/cloud-region/test-cloud-owner-02/test-cloud-region-id-02").next(); + + // For adding edges, check the dbedgetules and the property from and to node + // along with the other properties to populate information + p1.addEdge("org.onap.relationships.inventory.LocatedIn", c1, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + p1.addEdge("org.onap.relationships.inventory.LocatedIn", cr1, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + p3.addEdge("org.onap.relationships.inventory.LocatedIn", c1, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + p4.addEdge("org.onap.relationships.inventory.LocatedIn", c1, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + tenant2.addEdge("org.onap.relationships.inventory.BelongsTo", cr2, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + vserver2.addEdge("org.onap.relationships.inventory.BelongsTo", tenant2, + "private", false, + "prevent-delete", "NONE", + "delete-other-v", "NONE", + "contains-other-v", "NONE", + "default", true); + linterface2.addEdge("tosca.relationships.network.BindsTo", vserver2, + "direction", "OUT", + "multiplicity", "MANY2ONE", + "contains-other-v", "!OUT", + "delete-other-v", "!OUT", + "prevent-delete", "NONE", + "default", true); + oamNetwork2.addEdge("org.onap.relationships.inventory.BelongsTo", cr2, + "direction", "OUT", + "multiplicity", "MANY2ONE", + "contains-other-v", "!OUT", + "delete-other-v", "NONE", + "prevent-delete", "!OUT", + "default", true); + + } catch (Exception ex) { success = false; } finally { @@ -209,7 +317,6 @@ public class DslConsumerTest extends AbstractSpringRestTest { responseEntity.getStatusCode()); } - @Test public void testDslQueryProcessingV2_WithSimpleFormat_WithAsTreeQueryParameter() throws Exception { Map<String, String> dslQueryMap = new HashMap<>(); @@ -286,7 +393,6 @@ public class DslConsumerTest extends AbstractSpringRestTest { headers.remove("X-DslApiVersion"); } - @Ignore @Test public void testDslQueryProcessingV2_WithResourceFormat_WithoutAsTreeQueryParameter() throws Exception { Map<String, String> dslQueryMap = new HashMap<>(); @@ -339,7 +445,6 @@ public class DslConsumerTest extends AbstractSpringRestTest { headers.remove("X-DslApiVersion"); } - @Ignore @Test public void testDslQueryProcessingV2_WithResourceAndUrlFormat_WithoutAsTreeQueryParameter() throws Exception { Map<String, String> dslQueryMap = new HashMap<>(); @@ -366,4 +471,438 @@ public class DslConsumerTest extends AbstractSpringRestTest { headers.remove("X-DslApiVersion"); } + @Test + public void testDslQueryTestAggregateFormatLastNodeNotSelectedAndNotReturned() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver{'hostname'}('hostname','test-pserver-dsl') > complex"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=aggregate"; + + // Add header with V2 to use the {} feature as a part of dsl query + headers.add("X-DslApiVersion","V2"); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); + assertNull(resultsValue.get("/aai/v16/cloud-infrastructure/complexes/complex/test-complex-dsl")); //assert complex is not returned since it is not selected + JsonObject properties = resultsValue.get("/aai/v16/cloud-infrastructure/pservers/pserver/test-pserver-dsl").getAsJsonObject().get("properties").getAsJsonObject(); + assertEquals(1, properties.size()); + assertThat(properties.get("hostname").toString(), is("\"test-pserver-dsl\"")); //assert only hostname is selected + assertNull(properties.get("in-maint")); //assert that in-maint is not returned in the properties list + headers.remove("X-DslApiVersion"); + } + + @Test + public void testDslQueryTestAggregateFormatLastNodeSelectedAndReturned() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver{'hostname'}('hostname','test-pserver-dsl') > complex*"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=aggregate"; + + // Add header with V2 to use the {} feature as a part of dsl query + headers.add("X-DslApiVersion","V2"); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + JsonArray resultsValue = resultsArray.get(0).getAsJsonArray(); + assertNotNull(resultsValue.get(1).getAsJsonObject().get("/aai/v16/cloud-infrastructure/complexes/complex/test-complex-dsl")); //assert complex is returned since it is selected + JsonObject properties = resultsValue.get(0).getAsJsonObject().get("/aai/v16/cloud-infrastructure/pservers/pserver/test-pserver-dsl").getAsJsonObject().get("properties").getAsJsonObject(); + assertEquals(1, properties.size()); + assertThat(properties.get("hostname").toString(), is("\"test-pserver-dsl\"")); //verify that only selected attribute (hostname) is displayed + assertNull(properties.get("in-maint")); //assert that in-maint is not returned in the properties list + JsonObject complexProperties = resultsValue.get(1).getAsJsonObject().get("/aai/v16/cloud-infrastructure/complexes/complex/test-complex-dsl").getAsJsonObject().get("properties").getAsJsonObject(); + assertEquals(2, complexProperties.size()); //internal properties like source-of-truth, node-type and aai-uri are not returned. + headers.remove("X-DslApiVersion"); + } + + @Test + public void testDslQueryTestAggregateFormatInternalPropsNotReturned() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=aggregate"; + + // Add header with V2 to use the {} feature as a part of dsl query + headers.add("X-DslApiVersion","V2"); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + JsonObject properties = resultsArray.get(0).getAsJsonObject().get("/aai/v16/cloud-infrastructure/pservers/pserver/test-pserver-dsl").getAsJsonObject().get("properties").getAsJsonObject(); + assertEquals(2, properties.size()); + assertThat(properties.get("hostname").toString(), is("\"test-pserver-dsl\"")); //verify that only hostname is displayed + assertNull(properties.get("source-of-truth")); //assert that source-of-truth is not returned in properties list + headers.remove("X-DslApiVersion"); + } + + @Test + public void testDslQueryTestWithMultipleWheres() throws Exception { + // Return pservers where pserver has edge to complex "AND" same pserver also has an edge to cloud-region + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver*('hostname','test-pserver-dsl')(> complex)(> cloud-region)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v18/dsl?format=aggregate"; + + // Add header with V2 to use the {} feature as a part of dsl query + headers.add("X-DslApiVersion","V2"); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + assertEquals(1, resultsArray.size()); // Returns only test-pserver-dsl, does not return test-pserver-dsl-03 since it does not have an edge to cloud-region + assertEquals(null, resultsArray.get(0).getAsJsonObject().get("/aai/v18/cloud-infrastructure/pservers/pserver/test-pserver-dsl-03")); //not returned + assertNotNull(resultsArray.get(0).getAsJsonObject().get("/aai/v18/cloud-infrastructure/pservers/pserver/test-pserver-dsl")); + headers.remove("X-DslApiVersion"); + } + + @Test + public void testDslQueryTestWithMultipleWhereNots() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver*('hostname')!(> complex)!(> cloud-region)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v18/dsl?format=aggregate"; + + // Add header with V2 to use the {} feature as a part of dsl query + headers.add("X-DslApiVersion","V2"); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + assertEquals(1, resultsArray.size()); // Returns only test-pserver-dsl-02 + assertEquals(null, resultsArray.get(0).getAsJsonObject().get("/aai/v18/cloud-infrastructure/pservers/pserver/test-pserver-dsl")); //not returned + assertNotNull(resultsArray.get(0).getAsJsonObject().get("/aai/v18/cloud-infrastructure/pservers/pserver/test-pserver-dsl-02")); + headers.remove("X-DslApiVersion"); + } + + @Test + public void testDslQueryProcessing_ExpectedError_WrongDataType() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "pserver*('number-of-cpus','test')"); + + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=simple"; + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + Assert.assertTrue(responseString.contains( + "Value ['test'] is not an instance of the expected data type for property key ['number-of-cpus'] and cannot be converted. " + + "Expected: class java.lang.Integer, found: class java.lang.String")); + } + + @Test + public void testDslQueryOnComplex_WithResourceFormatWithUnionAsStartNode_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "[complex*('source-of-truth', 'JUNIT'), complex*('aai-uri', '/cloud-infrastructure/complexes/complex/test-complex-dsl')]"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=resource"; + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + JsonObject resultValue = resultsArray.get(0).getAsJsonObject(); + JsonObject complex = resultValue.get("complex").getAsJsonObject(); + Assert.assertEquals("\"test-complex-dsl\"", complex.get("physical-location-id").toString()); + } + + @Test + public void testDslQueryOnPserver_WithResourceFormatWithUnionAsStartNode_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "[pserver*('hostname','test-pserver-dsl'), complex*('physical-location-id', 'test-complex-dsl')]"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=resource"; + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Extract the properties array from the response and compare in assert statements + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + for (JsonElement je : resultsArray) { + JsonObject jo = je.getAsJsonObject(); + if (jo.get("complex") != null) { + Assert.assertEquals("\"test-complex-dsl\"", jo.get("complex").getAsJsonObject().get("physical-location-id").toString()); + } + else if (jo.get("pserver") != null) { + Assert.assertEquals("\"test-pserver-dsl\"", jo.get("pserver").getAsJsonObject().get("hostname").toString()); + } else { + Assert.fail(); + } + } + } + + @Test + public void testDslQueryOnNodesWithEdges_WithResourceFormatWithUnionAsStartNode_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "[pserver*('hostname','test-pserver-dsl-02'), pserver*('hostname','test-pserver-dsl')>complex*, pnf('pnf-name','pnf-name-noResults')>lag-interface>l-interface] > complex*"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=resource"; + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); // pnf should have no results + + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + boolean hasPserver1 = false, hasPserver2 = false; + for (JsonElement je : resultsArray) { + JsonObject jo = je.getAsJsonObject(); + if (jo.get("complex") != null) { + Assert.assertEquals("\"test-complex-dsl\"", jo.get("complex").getAsJsonObject().get("physical-location-id").toString()); + } + else if (jo.get("pserver") != null) { + if (jo.get("pserver").getAsJsonObject().get("hostname").toString().equals("\"test-pserver-dsl\"")){ + hasPserver1 = true; + } + if (jo.get("pserver").getAsJsonObject().get("hostname").toString().equals("\"test-pserver-dsl-02\"")) { + hasPserver2 = true; + } + } else { + Assert.fail(); + } + } + Assert.assertTrue(hasPserver1 && hasPserver2); + } + + @Test + public void testDslQueryOnNodesWithEdges2_WithResourceFormatWithUnionAsStartNode_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + dslQueryMap.put("dsl-query", "[pnf*('pnf-name','test-pnf-name-01'),pserver(>cloud-region*('cloud-owner','test-cloud-owner-01'))]"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + String endpoint = "/aai/v16/dsl?format=resource"; + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + JsonParser jsonParser = new JsonParser(); + JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonArray resultsArray = results.get("results").getAsJsonArray(); + for (JsonElement je : resultsArray) { + JsonObject jo = je.getAsJsonObject(); + if (jo.get("pnf") != null) { + Assert.assertEquals("\"test-pnf-name-01\"", jo.get("pnf").getAsJsonObject().get("pnf-name").toString()); + } + else if (jo.get("cloud-region") != null) { + Assert.assertEquals("\"test-cloud-owner-01\"", jo.get("cloud-region").getAsJsonObject().get("cloud-owner").toString()); + } else { + Assert.fail(); + } + } + } + + @Test + public void testDslQuery_IsAgnosticWithBooleanPropertyAsString_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // With expected boolean value "false" as a boolean value (no quotes) + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 1)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Confirm that the vserver was returned in the response + Assert.assertTrue(responseString.contains("\"vserver-id\":\"test-vserver-id-2\"") ); + + dslQueryMap.remove("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 1)"); + + // With expected boolean value of in-maint, "false", in string form (with single quotes) + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 'false')"); + payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + responseString = responseEntity.getBody().toString(); + // Confirm that the vserver was returned in the response + Assert.assertTrue(responseString.contains("\"vserver-id\":\"test-vserver-id-2\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithWrongBooleanPropertyAsString_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // all string values not boolean related default to false + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 'bogusBoolean')>l-interface*('priority', 123)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Confirm that the l-interface was returned in the response + Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithBooleanPropertyAsInteger0_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // 0 is false, should return value + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 0)>l-interface*('priority', 123)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Confirm that the l-interface was returned in the response + Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithBooleanPropertyAsInteger1_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // 0 is false, should return value + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 1)>l-interface*('priority', 123)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Confirm that the l-interface was returned in the response + Assert.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithBooleanPropertyAsTrue_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // 0 is false, should return value + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', true)>l-interface*('priority', 123)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Confirm that the l-interface was returned in the response + Assert.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithBooleanPropertyAsTrueString_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // 0 is false, should return value + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 'true')>l-interface*('priority', 123)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + // Confirm that the l-interface was returned in the response + Assert.assertTrue(!responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithIntegerPropertyAsString_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // With expected boolean value "false" as a boolean value (no quotes) + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', false)>l-interface*('priority', '00123')"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Confirm that the l-interface was returned in the response + Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + dslQueryMap.remove("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', false)>l-interface*('priority', '00123')"); + + // With expected boolean value of in-maint, "false", in string form (with single quotes) + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>tenant*>vserver*('in-maint', 'false')>l-interface*('priority', 00123)"); + payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + responseString = responseEntity.getBody().toString(); + + // Confirm that the l-interface was returned in the response + Assert.assertTrue(responseString.contains("\"interface-name\":\"test-interface-name-02\"") ); + } + + @Test + public void testDslQuery_IsAgnosticWithLongPropertyAsString_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // With expected boolean value "false" as a boolean value (no quotes) + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>oam-network*('cvlan-tag', '456')"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Confirm that the oam-network was returned in the response + Assert.assertTrue(responseString.contains("\"cvlan-tag\":456")); + dslQueryMap.remove("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>oam-network*('cvlan-tag', '456')"); + + dslQueryMap.put("dsl-query", "cloud-region*('cloud-owner', 'test-cloud-owner-02')>oam-network*('cvlan-tag', 456)"); + payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + responseString = responseEntity.getBody().toString(); + + // Confirm that the oam-network was returned in the response + Assert.assertTrue(responseString.contains("\"cvlan-tag\":456")); + } + + @Test + public void testDslQuery_IsAgnosticWithPrimitivePropertiesInList_ReturnSuccessfulResponse() throws Exception { + Map<String, String> dslQueryMap = new HashMap<>(); + String endpoint = "/aai/v19/dsl?format=resource&nodesOnly=true"; + + // With expected boolean value "false" as a boolean value (no quotes) + dslQueryMap.put("dsl-query", "complex('state')>pserver*('number-of-cpus', '234', '364', 2342)"); + String payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + httpEntity = new HttpEntity(payload, headers); + ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + String responseString = responseEntity.getBody().toString(); + + // Confirm that the pserver was returned in the response + Assert.assertTrue(responseString.contains("\"number-of-cpus\":364")); + dslQueryMap.remove("dsl-query", "complex('state')>pserver*('number-of-cpus', '234', '364', 2342)"); + + dslQueryMap.put("dsl-query", "complex('state')>pserver*('number-of-cpus', '234', 364, 2342)"); + payload = PayloadUtil.getTemplatePayload("dsl-query.json", dslQueryMap); + + httpEntity = new HttpEntity(payload, headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + responseString = responseEntity.getBody().toString(); + + // Confirm that the pserver was returned in the response + Assert.assertTrue(responseString.contains("\"number-of-cpus\":364")); + } } diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java index c965407..8acbd4e 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/GfpVserverDataStoredQueryTest.java @@ -165,6 +165,8 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{ queryParameters.add("format", "resource_and_url"); Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters); when(uriInfo.getPath()).thenReturn(query); + HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); + when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8446" + query)); Response response = queryConsumer.executeQuery( payload, @@ -172,6 +174,7 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{ "resource_and_url", "" + "no_op", httpHeaders, + mockRequest, uriInfo, "-1", "-1" @@ -203,12 +206,16 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{ Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters); when(uriInfo.getPath()).thenReturn(query); + HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); + when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8446" + query)); + Response response = queryConsumer.executeQuery( payload, version.toString(), "resource_and_url", "" + "no_op", httpHeaders, + mockRequest, uriInfo, "-1", "-1" @@ -240,6 +247,9 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{ queryParameters.add("format", "resource_and_url"); Mockito.when(uriInfo.getQueryParameters()).thenReturn(queryParameters); when(uriInfo.getPath()).thenReturn(query); + HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); + when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8446" + query)); + Response response = queryConsumer.executeQuery( payload, @@ -247,6 +257,7 @@ public class GfpVserverDataStoredQueryTest extends AAISetup{ "resource_and_url", "" + "no_op", httpHeaders, + mockRequest, uriInfo, "-1", "-1" diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java index 9d36ac7..aa3e297 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV1Test.java @@ -24,6 +24,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.junit.Rule; import org.junit.Test; +import org.junit.Ignore; import org.junit.rules.ExpectedException; import org.onap.aai.AAISetup; import org.onap.aai.exceptions.AAIException; @@ -445,10 +446,12 @@ public class DslQueryProcessorV1Test extends AAISetup { assertEquals(dslQuery, query); } + @Ignore @Test public void hasPropertyIntegerTest() throws AAIException { - String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-tag*('vlan-id-inner', 20)"; - String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()"; + String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-range > vlan-tag*('vlan-id-inner', 20)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a')" + + ".createEdgeTraversal(EdgeType.TREE, 'cloud-region','vlan-range').createEdgeTraversal(EdgeType.TREE, 'vlan-range','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()"; String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString(); assertEquals(dslQuery, query); } @@ -517,6 +520,24 @@ public class DslQueryProcessorV1Test extends AAISetup { } @Test + public void getPserverWithAnEdgeToComplexAndCloudRegion() throws AAIException { + String aaiQuery = "pserver*('prov-status')(> complex)(> cloud-region)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('prov-status').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex')).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','cloud-region')).store('x').cap('x').unfold().dedup()"; + + String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString(); + assertEquals(dslQuery, query); + } + + @Test + public void getPserverWithAnEdgeToComplexButNotToCloudRegion() throws AAIException { + String aaiQuery = "pserver*('prov-status')(> complex)!(> cloud-region)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('prov-status').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex')).where(builder.newInstance().not(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','cloud-region'))).store('x').cap('x').unfold().dedup()"; + + String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString(); + assertEquals(dslQuery, query); + } + + @Test public void nestedUnionQueryTest() throws AAIException { String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union(" diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java index 85da551..9ff42e0 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/DslQueryProcessorV2Test.java @@ -46,6 +46,16 @@ public class DslQueryProcessorV2Test extends AAISetup { String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString(); assertEquals(dslQuery, query); } + @Test + public void apostropheTest() throws AAIException { + String aaiQuery = "logical-link*('link-id','dsl\\'link')"; + + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'logical-link').getVerticesByProperty('link-id','dsl\\'link')" + + ".store('x').cap('x').unfold().dedup()"; + + String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString(); + assertEquals(dslQuery, query); + } @Test public void cloudRegionFromVnf() throws AAIException { @@ -433,10 +443,12 @@ public class DslQueryProcessorV2Test extends AAISetup { assertEquals(dslQuery, query); } + @Ignore @Test public void hasPropertyIntegerTest() throws AAIException { - String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-tag*('vlan-id-inner', 20)"; - String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()"; + String aaiQuery = "cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'MTN61a') > vlan-range > vlan-tag*('vlan-id-inner', 20)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','att-nc').getVerticesByProperty('cloud-region-id','MTN61a')" + + ".createEdgeTraversal(EdgeType.TREE, 'cloud-region','vlan-range').createEdgeTraversal(EdgeType.TREE, 'vlan-range','vlan-tag').getVerticesByProperty('vlan-id-inner',20).store('x').cap('x').unfold().dedup()"; String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString(); assertEquals(dslQuery, query); } @@ -458,10 +470,12 @@ public class DslQueryProcessorV2Test extends AAISetup { } + @Ignore @Test public void returnSpecificPropsAndAllForDifferentVertices() throws AAIException { - String aaiQuery = "cloud-region{'cloud-owner'}('cloud-region-id','new-r111egion-111111') > [ l3-network*, vlan-tag*]"; - String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-region-id','new-r111egion-111111').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','l3-network').store('x'),builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag').store('x')).cap('x').unfold().dedup()"; + String aaiQuery = "cloud-region{'cloud-owner'}('cloud-region-id','new-r111egion-111111') > [ l3-network*, vlan-range > vlan-tag*]"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-region-id','new-r111egion-111111').store('x').union(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','l3-network').store('x'),builder.newInstance()" + + ".createEdgeTraversal(EdgeType.TREE, 'cloud-region','vlan-range').createEdgeTraversal(EdgeType.TREE, 'vlan-range','vlan-tag').store('x')).cap('x').unfold().dedup()"; String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2, aaiQuery).get("query").toString(); assertEquals(query, dslQuery); } @@ -529,6 +543,24 @@ public class DslQueryProcessorV2Test extends AAISetup { } @Test + public void getPserverWithAnEdgeToComplexAndCloudRegion() throws AAIException { + String aaiQuery = "pserver*('prov-status')(> complex)(> cloud-region)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('prov-status').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex')).where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','cloud-region')).store('x').cap('x').unfold().dedup()"; + + String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString(); + assertEquals(dslQuery, query); + } + + @Test + public void getPserverWithAnEdgeToComplexButNotToCloudRegion() throws AAIException { + String aaiQuery = "pserver*('prov-status')(> complex)!(> cloud-region)"; + String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'pserver').getVerticesByProperty('prov-status').where(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','complex')).where(builder.newInstance().not(builder.newInstance().createEdgeTraversal(EdgeType.COUSIN, 'pserver','cloud-region'))).store('x').cap('x').unfold().dedup()"; + + String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V2,aaiQuery).get("query").toString(); + assertEquals(dslQuery, query); + } + + @Test public void nestedUnionQueryTest() throws AAIException { String builderQuery = "builder.getVerticesByProperty('aai-node-type', 'generic-vnf').getVerticesByProperty('vnf-id','vnfId').store('x').union(" diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java index e8fee37..8c52a31 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/dsl/ProdDslTest.java @@ -20,6 +20,7 @@ package org.onap.aai.rest.dsl; import org.junit.Test; +import org.junit.Ignore; import org.onap.aai.AAISetup; import org.onap.aai.exceptions.AAIException; import org.onap.aai.rest.enums.QueryVersion; @@ -30,13 +31,14 @@ import static org.junit.Assert.assertEquals; //TODO: Add queries run by SEs public class ProdDslTest extends AAISetup { + @Ignore @Test public void msoQueryTest1() throws AAIException { - String aaiQuery = "cloud-region('cloud-owner', 'value')('cloud-region-id', 'value') > vlan-tag*('vlan-id-outer', 'value')"; + String aaiQuery = "cloud-region('cloud-owner', 'value')('cloud-region-id', 'value') > vlan-range > vlan-tag*('vlan-id-outer', '123')"; String dslQuery = "builder.getVerticesByProperty('aai-node-type', 'cloud-region').getVerticesByProperty('cloud-owner','value')" - + ".getVerticesByProperty('cloud-region-id','value').createEdgeTraversal(EdgeType.COUSIN, 'cloud-region','vlan-tag')" - + ".getVerticesByProperty('vlan-id-outer','value').store('x').cap('x').unfold().dedup()"; + + ".getVerticesByProperty('cloud-region-id','value').createEdgeTraversal(EdgeType.TREE, 'cloud-region','vlan-range').createEdgeTraversal(EdgeType.TREE, 'vlan-range','vlan-tag')" + + ".getVerticesByProperty('vlan-id-outer',123).store('x').cap('x').unfold().dedup()"; String query = dslQueryProcessor.parseAaiQuery(QueryVersion.V1,aaiQuery).get("query").toString(); assertEquals(dslQuery, query); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java index e1cd663..73f7595 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetClfiRoadmTailSummaryTest.java @@ -19,71 +19,71 @@ */ package org.onap.aai.rest.search; -import java.util.Map; - import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; import org.onap.aai.exceptions.AAIException; import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -public class GetClfiRoadmTailSummaryTest extends QueryTest { +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Map; + +public class GetClfiRoadmTailSummaryTest extends TreeQueryTest { public GetClfiRoadmTailSummaryTest() throws AAIException, NoEdgeRuleFoundException { super(); } - @Test - public void run() { - super.run(); - } - @Override protected void createGraph() throws AAIException, NoEdgeRuleFoundException { - Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", - "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1"); - Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", - "service-type", "service-subcription-1"); - Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "" - + "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1"); - Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "logical-link-1"); - Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "5", "aai-node-type", "logical-link", "link-name", "logical-link-2"); - Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1"); - Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2"); - Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3"); - Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "9", "aai-node-type", "pnf", "pnf-name", "pnf1name"); + Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "5", "aai-node-type", "logical-link", "link-name", "logical-link-1"); + Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1"); + Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2"); + Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3"); + Vertex pInterface4 = graph.addVertex(T.label, "p-interface", T.id, "9", "aai-node-type", "p-interface", "interface-name", "p-interface-4"); + Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "12", "aai-node-type", "pnf", "pnf-name", "pnf1name"); Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf2name"); + + Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1"); + + rules.addEdge(gts, logicalLink1, pInterface1); + rules.addEdge(gts, logicalLink1, pInterface2); + rules.addEdge(gts, logicalLink1, pInterface3); + rules.addEdge(gts, logicalLink1, pInterface4);//false + + rules.addTreeEdge(gts, pnf1, pInterface1); + rules.addTreeEdge(gts, pnf2, pInterface2); + rules.addTreeEdge(gts, pnf2, pInterface3); + + rules.addEdge(gts, logicalLink1, lInterface1);//false + + } + + @Test + public void run() { + super.run(); + Tree tree = treeList.get(0); + + Vertex l1 = graph.traversal().V().has("aai-node-type","logical-link").has("link-name","logical-link-1").next(); + Vertex pInt1 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-1").next(); + Vertex pInt2 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-2").next(); + Vertex pInt3 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-3").next(); + Vertex pInt4 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-4").next(); + Vertex pnf1 = graph.traversal().V().has("aai-node-type","pnf").has("pnf-name","pnf1name").next(); + Vertex pnf2 = graph.traversal().V().has("aai-node-type","pnf").has("pnf-name","pnf2name").next(); + + assertTrue(tree.containsKey(l1)); + assertTrue(((Tree) tree.get(l1)).containsKey(pInt1)); + assertTrue(((Tree) tree.get(l1)).containsKey(pInt2)); + assertTrue(((Tree) tree.get(l1)).containsKey(pInt3)); + assertFalse(((Tree) tree.get(l1)).containsKey(pInt4)); //pInt4 does not have an edge to any pnf + assertTrue(((Tree) tree.get(l1)).getLeafObjects().contains(pnf1)); + assertTrue(((Tree) tree.get(l1)).getLeafObjects().contains(pnf2)); - Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1"); - - GraphTraversalSource g = graph.traversal(); - rules.addTreeEdge(g, customer, serviceSubscription); - rules.addTreeEdge(g, serviceSubscription, serviceInstance); - - rules.addEdge(g, serviceInstance, logicalLink1); - rules.addEdge(g, logicalLink2, logicalLink1); - rules.addEdge(g, logicalLink2, pInterface1); - rules.addEdge(g, logicalLink2, pInterface2); - rules.addEdge(g, logicalLink2, pInterface3); - - rules.addTreeEdge(g, pnf1, pInterface1); - rules.addTreeEdge(g, pnf2, pInterface2); - rules.addTreeEdge(g, pnf2, pInterface3); - - rules.addEdge(g, logicalLink1, lInterface1);//false - - //expectedResult.add(logicalLink1); - expectedResult.add(pInterface1); - expectedResult.add(pnf1); - expectedResult.add(pInterface2); - expectedResult.add(pInterface3); - expectedResult.add(pnf2); - expectedResult.add(logicalLink2); - expectedResult.add(serviceInstance); - expectedResult.add(serviceSubscription); - expectedResult.add(customer); } @Override @@ -93,7 +93,7 @@ public class GetClfiRoadmTailSummaryTest extends QueryTest { @Override protected void addStartNode(GraphTraversal<Vertex, Vertex> g) { - g.has("aai-node-type", "logical-link").has("link-name", "logical-link-2"); + g.has("aai-node-type", "logical-link").has("link-name", "logical-link-1"); } @Override diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java index ee1a08a..6e0f852 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetRouterRoadmTailSummaryTest.java @@ -19,61 +19,50 @@ */ package org.onap.aai.rest.search; -import java.util.Map; - import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; -import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.junit.Test; import org.onap.aai.exceptions.AAIException; import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; -public class GetRouterRoadmTailSummaryTest extends QueryTest{ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Map; - public GetRouterRoadmTailSummaryTest() throws AAIException, NoEdgeRuleFoundException { - super(); - } +public class GetRouterRoadmTailSummaryTest extends TreeQueryTest{ - @Test - public void run() { - super.run(); - } + public GetRouterRoadmTailSummaryTest() throws AAIException, NoEdgeRuleFoundException { + super(); + } - @Override - protected void createGraph() throws AAIException, NoEdgeRuleFoundException { - Vertex serviceInstance = graph.addVertex(T.label, "service-instance", T.id, "1", "aai-node-type", "service-instance", - "service-instance-id", "service-instance-id-1", "service-instance-name", "service-instance-name-1"); - Vertex serviceSubscription = graph.addVertex(T.label, "service-subscription", T.id, "2", "aai-node-type", "service-subscription", - "service-type", "service-subcription-1"); - Vertex customer = graph.addVertex(T.label, "customer", T.id, "3", "aai-node-type", "customer", "" - + "global-customer-id", "customer-id-1", "subscriber-name", "customer-name1", "subscriber-type", "customer-type1"); + @Override + protected void createGraph() throws AAIException, NoEdgeRuleFoundException { Vertex logicalLink1 = graph.addVertex(T.label, "logical-link", T.id, "4", "aai-node-type", "logical-link", "link-name", "logical-link-1"); Vertex logicalLink2 = graph.addVertex(T.label, "logical-link", T.id, "5", "aai-node-type", "logical-link", "link-name", "logical-link-2"); - Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1"); - Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2"); - Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3"); + Vertex pInterface1 = graph.addVertex(T.label, "p-interface", T.id, "6", "aai-node-type", "p-interface", "interface-name", "p-interface-1"); + Vertex pInterface2 = graph.addVertex(T.label, "p-interface", T.id, "7", "aai-node-type", "p-interface", "interface-name", "p-interface-2"); + Vertex pInterface3 = graph.addVertex(T.label, "p-interface", T.id, "8", "aai-node-type", "p-interface", "interface-name", "p-interface-3"); + Vertex pInterface4 = graph.addVertex(T.label, "p-interface", T.id, "12", "aai-node-type", "p-interface", "interface-name", "p-interface-4"); Vertex pnf1 = graph.addVertex(T.label, "pnf", T.id, "9", "aai-node-type", "pnf", "pnf-name", "pnf1name"); Vertex pnf2 = graph.addVertex(T.label, "pnf", T.id, "10", "aai-node-type", "pnf", "pnf-name", "pnf2name"); - - Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1"); - - GraphTraversalSource g = graph.traversal(); - rules.addTreeEdge(g, customer, serviceSubscription); - rules.addTreeEdge(g, serviceSubscription, serviceInstance); - - rules.addEdge(g, serviceInstance, logicalLink1); - rules.addEdge(g, logicalLink2, logicalLink1); - rules.addEdge(g, logicalLink2, pInterface1); - rules.addEdge(g, logicalLink2, pInterface2); - rules.addEdge(g, logicalLink2, pInterface3); - - rules.addTreeEdge(g, pInterface1, pnf1); - rules.addTreeEdge(g, pInterface2, pnf2); - rules.addTreeEdge(g, pInterface3, pnf2); - - rules.addEdge(g, logicalLink2, lInterface1);//false - + + Vertex lInterface1 = graph.addVertex(T.label, "l-interface", T.id, "11", "aai-node-type", "l-interface", "interface-name", "l-interface-1"); + + rules.addEdge(gts, logicalLink2, logicalLink1); + rules.addEdge(gts, logicalLink2, pInterface1); + rules.addEdge(gts, logicalLink2, pInterface2); + rules.addEdge(gts, logicalLink2, pInterface3); + + rules.addTreeEdge(gts, pInterface1, pnf1); + rules.addTreeEdge(gts, pInterface2, pnf2); + rules.addTreeEdge(gts, pInterface3, pnf2); + rules.addTreeEdge(gts, pInterface4, pnf1); //false + + rules.addEdge(gts, logicalLink2, lInterface1);//false + expectedResult.add(pnf1); expectedResult.add(pInterface1); //expectedResult.add(logicalLink1); @@ -81,24 +70,67 @@ public class GetRouterRoadmTailSummaryTest extends QueryTest{ expectedResult.add(pInterface3); expectedResult.add(pnf2); expectedResult.add(logicalLink2); - expectedResult.add(serviceInstance); - expectedResult.add(serviceSubscription); - expectedResult.add(customer); - } + + } - @Override - protected String getQueryName() { - return "getRouterRoadmTailSummary"; - } + @Test + public void run() { + super.run(); + + Tree tree = treeList.get(0); //pnf1 + + Vertex l1 = graph.traversal().V().has("aai-node-type","logical-link").has("link-name","logical-link-1").next(); + + Vertex l2 = graph.traversal().V().has("aai-node-type","logical-link").has("link-name","logical-link-2").next(); + Vertex pInt1 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-1").next(); + Vertex pInt2 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-2").next(); + Vertex pInt3 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-3").next(); + Vertex pInt4 = graph.traversal().V().has("aai-node-type","p-interface").has("interface-name","p-interface-4").next(); + Vertex pnf1 = graph.traversal().V().has("aai-node-type","pnf").has("pnf-name","pnf1name").next(); + Vertex pnf2 = graph.traversal().V().has("aai-node-type","pnf").has("pnf-name","pnf2name").next(); + + /* + * Expected: + * {v[9] -> pnf1 + {v[6] -> pInt1 + {v[5] -> l2 + { + v[6] -> pInt1 + {v[9]={}}, -> pnf1 + v[7]= -> pInt2 + {v[10]={}}, -> pnf2 + v[8]= -> pInt3 + {v[10]={}} -> pnf2 + } + } + } + } + */ + + assertTrue(tree.containsKey(pnf1)); + assertFalse(((Tree) tree.get(pnf1)).containsKey(pInt4)); //pInt4 is not connected to any logical-link + assertTrue(((Tree) tree.get(pnf1)).containsKey(pInt1)); + assertTrue(tree.getObjectsAtDepth(3).contains(l2)); + assertTrue(tree.getObjectsAtDepth(4).contains(pInt1)); + assertTrue(tree.getObjectsAtDepth(5).contains(pnf1)); + assertTrue(tree.getObjectsAtDepth(4).contains(pInt2)); + assertTrue(tree.getObjectsAtDepth(4).contains(pInt3)); + assertTrue(tree.getObjectsAtDepth(5).contains(pnf2)); + } + + @Override + protected String getQueryName() { + return "getRouterRoadmTailSummary"; + } - @Override - protected void addStartNode(GraphTraversal<Vertex, Vertex> g) { - g.has("aai-node-type", "pnf").has("pnf-name", "pnf1name"); - } + @Override + protected void addStartNode(GraphTraversal<Vertex, Vertex> g) { + g.has("aai-node-type", "pnf").has("pnf-name", "pnf1name"); + } - @Override - protected void addParam(Map<String, Object> params) { - return; - } + @Override + protected void addParam(Map<String, Object> params) { + return; + } -} +}
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java index cab4ad0..0d26300 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/IpsNetworksFromVnfTest.java @@ -155,6 +155,7 @@ public class IpsNetworksFromVnfTest extends QueryTest { expectedResult.add(genericVnf); expectedResult.add(vnfc); + expectedResult.add(cp); expectedResult.add(vipIpv4AddressList); expectedResult.add(vipIpv6AddressList); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java index 04a7d21..5d593dc 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/VnfTopologyFromServiceInstanceTest.java @@ -25,6 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.junit.Ignore; import org.junit.Test; import org.onap.aai.exceptions.AAIException; import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException; @@ -33,7 +34,8 @@ public class VnfTopologyFromServiceInstanceTest extends QueryTest { public VnfTopologyFromServiceInstanceTest() throws AAIException, NoEdgeRuleFoundException { super(); } - + + @Ignore //TODO: Fix this when verification uses correct schema @Test public void run() { super.run(); @@ -56,6 +58,7 @@ public class VnfTopologyFromServiceInstanceTest extends QueryTest { Vertex vserver = graph.addVertex(T.label, "vserver", T.id, "11", "aai-node-type", "vserver", "vserver-name1", "vservername1"); Vertex tenant = graph.addVertex(T.label, "tenant", T.id, "12", "aai-node-type", "tenant", "tenant-name1", "tenant-name-1","tenant-id", "tenant-id-1"); Vertex region1 = graph.addVertex(T.label, "cloud-region", T.id, "13", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner1"); + Vertex range1 = graph.addVertex(T.label, "vlan-range", T.id, "26", "aai-node-type", "vlan-range", "vlan-range-id", "vlanRange1"); Vertex pserver = graph.addVertex(T.label, "pserver", T.id, "14", "aai-node-type", "pserver", "hostname", "pservername"); Vertex linter2 = graph.addVertex(T.label, "l-interface", T.id, "15", "aai-node-type", "l-interface", "l-interface-id", "l-interface-id-2", "l-interface-name", "l-interface-name2"); Vertex l3inter2ipv4addresslist = graph.addVertex(T.label, "interface-ipv6-address-list", T.id, "16", "aai-node-type", "l3-interface-ipv6-address-list", "l3-interface-ipv6-address-list-id", "l3-interface-ipv6-address-list-id-2", "l3-interface-ipv6-address-list-name", "l3-interface-ipv6-address-list-name2"); @@ -67,9 +70,10 @@ public class VnfTopologyFromServiceInstanceTest extends QueryTest { Vertex l3network6 = graph.addVertex(T.label, "l3-network", T.id, "24", "aai-node-type", "l3-network", "ll3-network-id", "l3-network-id-6", "l3-network-name", "l3-network-name6"); Vertex configuration = graph.addVertex(T.label, "configuration", T.id, "21", "aai-node-type", "configuration", "configuration-id", "configuration-id-1", "configuration-type", "configuration-type-1"); Vertex vlantag = graph.addVertex(T.label, "vlan-tag", T.id, "22", "aai-node-type", "vlan-tag", "vlan-tag-id", "vlan-tag-id-1"); + Vertex region2 = graph.addVertex(T.label, "cloud-region", T.id, "28", "aai-node-type", "cloud-region", "cloud-owner", "cloudOwner2"); + Vertex range2 = graph.addVertex(T.label, "vlan-range", T.id, "29", "aai-node-type", "vlan-range", "vlan-range-id", "vlanRange2"); Vertex vlantag2 = graph.addVertex(T.label, "vlan-tag", T.id, "25", "aai-node-type", "vlan-tag", "vlan-tag-id", "vlan-tag-id-2"); - - + GraphTraversalSource g = graph.traversal(); rules.addEdge(g, gnvf1, serviceinstance);//false @@ -80,9 +84,9 @@ public class VnfTopologyFromServiceInstanceTest extends QueryTest { rules.addTreeEdge(g, gnvf1, vfmodule);//true rules.addEdge(g, gnvf1, volumegroup);//false rules.addEdge(g, gnvf1, l3network5);//true - rules.addEdge(g, l3network5, vlantag);//true + rules.addEdge(g, l3network5, vlantag, "org.onap.relationships.inventory.Uses");//true rules.addEdge(g, l3network5, l3network6);//true - rules.addEdge(g, l3network6, vlantag2);//true + rules.addEdge(g, l3network6, vlantag2, "org.onap.relationships.inventory.Uses");//true rules.addTreeEdge(g, gnvf1, linter1);//true rules.addTreeEdge(g, linter1, l3inter1ipv4addresslist);//true rules.addEdge(g, l3inter1ipv4addresslist, l3network1);//false @@ -97,7 +101,10 @@ public class VnfTopologyFromServiceInstanceTest extends QueryTest { rules.addEdge(g, l3inter2ipv4addresslist, l3network3);//false rules.addTreeEdge(g, linter2, l3inter2ipv6addresslist);//true rules.addEdge(g, l3inter2ipv6addresslist, l3network4);//true - + rules.addTreeEdge(g, region1, range1); + rules.addTreeEdge(g, region2, range2); + rules.addTreeEdge(g, range1, vlantag); + rules.addTreeEdge(g, range2, vlantag2); expectedResult.add(gnvf1); expectedResult.add(serviceinstance); |