diff options
Diffstat (limited to 'aai-traversal/src/test/java/org/onap')
11 files changed, 162 insertions, 106 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java index 266cb60..652c2f3 100644 --- a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java @@ -25,14 +25,20 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.fail; -import com.jayway.jsonpath.JsonPath; - -import java.util.*; +import java.util.Base64; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; 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.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; import org.onap.aai.config.PropertyPasswordConfiguration; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; @@ -44,13 +50,20 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Import; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; import org.springframework.web.client.RestTemplate; +import com.jayway.jsonpath.JsonPath; + /** * A sample junit test using spring boot that provides the ability to spin * up the application from the junit layer and run rest requests against @@ -92,8 +105,8 @@ public class AAIGremlinQueryTest { @BeforeClass public static void setupConfig() throws AAIException { - System.setProperty("AJSC_HOME", "./"); - System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); AAIConfig.init(); } diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java index 8c6364d..e3351ae 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java @@ -25,9 +25,6 @@ import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -57,6 +54,9 @@ import org.onap.aai.exceptions.AAIException; import org.onap.aai.rest.util.AAIExtensionMap; import org.onap.aai.util.AAIConstants; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + public class SearchGraphNamedQueryTest extends AAISetup { protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); @@ -83,7 +83,7 @@ public class SearchGraphNamedQueryTest extends AAISetup { private HttpTestUtil httpTestUtil; private String getJsonValue(String json, String key) { - JsonObject jsonObj = new JsonParser().parse(json).getAsJsonObject(); + JsonObject jsonObj = JsonParser.parseString(json).getAsJsonObject(); String strValue = ""; if (jsonObj.isJsonObject()) { strValue = jsonObj.get(key).getAsString(); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java index ac71b57..21a7862 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java @@ -29,10 +29,13 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.Vertex; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphTransaction; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; import org.onap.aai.TraversalApp; import org.onap.aai.TraversalTestConfiguration; -import org.onap.aai.config.PropertyPasswordConfiguration; import org.onap.aai.dbmap.AAIGraph; import org.onap.aai.exceptions.AAIException; import org.onap.aai.nodes.NodeIngestor; @@ -44,7 +47,6 @@ import org.springframework.context.annotation.Import; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.rules.SpringClassRule; import org.springframework.test.context.junit4.rules.SpringMethodRule; @@ -79,8 +81,8 @@ public abstract class AbstractSpringRestTest { @BeforeClass public static void setupConfig() throws AAIException { - System.setProperty("AJSC_HOME", "./"); - System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/"); + System.setProperty("AJSC_HOME", "."); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); } @Before 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 b72107f..b02911a 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 @@ -22,14 +22,16 @@ package org.onap.aai.rest; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.not; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -42,7 +44,16 @@ import org.onap.aai.util.AAIConfig; import org.onap.aai.util.TraversalConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; public class DslConsumerTest extends AbstractSpringRestTest { @@ -330,8 +341,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("properties").getAsJsonObject(); @@ -358,8 +368,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("properties").getAsJsonObject(); @@ -387,8 +396,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -416,8 +424,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -446,8 +453,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -475,8 +481,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); JsonObject properties = resultsValue.get("pserver").getAsJsonObject(); @@ -502,8 +507,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultsValue = resultsArray.get(0).getAsJsonObject(); assertNull( @@ -546,8 +550,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonArray resultsValue = resultsArray.get(0).getAsJsonArray(); assertNotNull(resultsValue.get(1).getAsJsonObject() @@ -592,8 +595,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject properties = resultsArray.get(0).getAsJsonObject() .get("/aai/v16/cloud-infrastructure/pservers/pserver/test-pserver-dsl") @@ -626,8 +628,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(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 @@ -654,8 +655,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); assertEquals(1, resultsArray.size()); // Returns only test-pserver-dsl-02 assertEquals(null, resultsArray.get(0).getAsJsonObject() @@ -698,8 +698,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); JsonObject resultValue = resultsArray.get(0).getAsJsonObject(); JsonObject complex = resultValue.get("complex").getAsJsonObject(); @@ -721,8 +720,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); for (JsonElement je : resultsArray) { JsonObject jo = je.getAsJsonObject(); @@ -752,8 +750,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { 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(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); boolean hasPserver1 = false, hasPserver2 = false; for (JsonElement je : resultsArray) { @@ -791,8 +788,7 @@ public class DslConsumerTest extends AbstractSpringRestTest { restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); String responseString = responseEntity.getBody().toString(); - JsonParser jsonParser = new JsonParser(); - JsonObject results = jsonParser.parse(responseString).getAsJsonObject(); + JsonObject results = JsonParser.parseString(responseString).getAsJsonObject(); JsonArray resultsArray = results.get("results").getAsJsonArray(); for (JsonElement je : resultsArray) { JsonObject jo = je.getAsJsonObject(); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java index 472cffb..7442386 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/CQAllChildernFromPnfStateTest.java @@ -20,12 +20,9 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import java.util.Arrays; import java.util.HashSet; @@ -45,6 +42,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -146,7 +148,7 @@ public class CQAllChildernFromPnfStateTest extends AbstractSpringHistoryRestTest httpEntity = new HttpEntity(payload.toString(), headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); @@ -162,7 +164,7 @@ public class CQAllChildernFromPnfStateTest extends AbstractSpringHistoryRestTest httpEntity = new HttpEntity(payload.toString(), headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java index d26eff2..3411c2a 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleEdgeTest.java @@ -20,14 +20,18 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -44,6 +48,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -148,7 +157,7 @@ public class DslConsumerHistoryLifecycleEdgeTest extends AbstractSpringHistoryRe httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java index dc794b8..4a94504 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest.java @@ -20,13 +20,16 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +45,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -200,7 +207,7 @@ public class DslConsumerHistoryLifecycleNodeDeletedThenRecreatedTest httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java index 6d1a36c..88cc91c 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryLifecycleSingleNodeTest.java @@ -20,13 +20,16 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +45,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The lifecycle format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -141,7 +148,7 @@ public class DslConsumerHistoryLifecycleSingleNodeTest extends AbstractSpringHis httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java index 6b9815c..1a88c8b 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateEdgeTest.java @@ -20,14 +20,20 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -44,6 +50,11 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -148,7 +159,7 @@ public class DslConsumerHistoryStateEdgeTest extends AbstractSpringHistoryRestTe httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java index 5b08d83..1596fd4 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/history/DslConsumerHistoryStateTest.java @@ -20,13 +20,18 @@ package org.onap.aai.rest.history; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.janusgraph.core.JanusGraphTransaction; @@ -42,6 +47,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + @Ignore("The state format requires the history schema to be loaded. " + "Because aaigraph is a singleton its very complicated to have 2 different schemas loaded for testing. " + "This needs to be addressed.") @@ -179,7 +188,7 @@ public class DslConsumerHistoryStateTest extends AbstractSpringHistoryRestTest { httpEntity = new HttpEntity(payload, headers); ResponseEntity responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); - JsonArray results = new JsonParser().parse(responseEntity.getBody().toString()) + JsonArray results = JsonParser.parseString(responseEntity.getBody().toString()) .getAsJsonObject().getAsJsonArray("results"); LOGGER.debug("Response for PUT request with uri {} : {}", baseUrl + endpoint, responseEntity.getBody()); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java index 08136c2..bdd52ee 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java @@ -157,9 +157,9 @@ public abstract class QueryTest { addParam(params); when(dbEngine.getQueryBuilder(any(QueryStyle.class))) .thenReturn(new GremlinTraversal<>(loader, graph.traversal())); - logger.info("Stored query in abstraction form {}", query); + logger.debug("Stored query in abstraction form {}", query); query = new GroovyQueryBuilder().executeTraversal(dbEngine, query, params); - logger.info("After converting to gremlin query {}", query); + logger.debug("After converting to gremlin query {}", query); query = "g" + query; GraphTraversal<Vertex, Vertex> g = graph.traversal().V(); addStartNode(g); @@ -173,8 +173,8 @@ public abstract class QueryTest { List<Vertex> vertices = result.toList(); - logger.info("Expected result set of vertexes [{}]", convert(expectedResult)); - logger.info("Actual Result set of vertexes [{}]", convert(vertices)); + logger.debug("Expected result set of vertexes [{}]", convert(expectedResult)); + logger.debug("Actual Result set of vertexes [{}]", convert(vertices)); List<Vertex> nonDuplicateExpectedResult = new ArrayList<>(new HashSet<>(expectedResult)); vertices = new ArrayList<>(new HashSet<>(vertices)); |