aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/test/java/org')
-rw-r--r--aai-resources/src/test/java/org/onap/aai/AAISetup.java36
-rw-r--r--aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java31
-rw-r--r--aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java15
-rw-r--r--aai-resources/src/test/java/org/onap/aai/ResourcesTestConfiguration.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java2
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java2
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java463
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java100
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java6
16 files changed, 597 insertions, 106 deletions
diff --git a/aai-resources/src/test/java/org/onap/aai/AAISetup.java b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
index acef23b..9a12007 100644
--- a/aai-resources/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
@@ -19,38 +19,32 @@
*/
package org.onap.aai;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-
import org.apache.commons.io.IOUtils;
import org.junit.BeforeClass;
-import org.onap.aai.config.ConfigConfiguration;
-import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.config.IntrospectionConfig;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.onap.aai.config.*;
+import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.introspection.MoxyLoader;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.config.RestBeanConfig;
import org.onap.aai.rest.db.HttpEntry;
-import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.serialization.db.EdgeSerializer;
+import org.onap.aai.setup.AAIConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.onap.aai.introspection.MoxyLoader;
-
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.onap.aai.edges.EdgeIngestor;
-import org.onap.aai.setup.AAIConfigTranslator;
-import org.onap.aai.serialization.db.EdgeSerializer;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+
@ContextConfiguration(classes = {
ConfigConfiguration.class,
AAIConfigTranslator.class,
@@ -58,7 +52,8 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
EdgeIngestor.class,
EdgeSerializer.class,
SpringContextAware.class,
- IntrospectionConfig.class,
+ IntrospectionConfig.class,
+ XmlFormatTransformerConfiguration.class,
RestBeanConfig.class
})
@TestPropertySource(properties = {
@@ -95,7 +90,6 @@ public abstract class AAISetup {
public static void setupBundleconfig() throws Exception {
System.setProperty("AJSC_HOME", "./");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
- LoggingContext.init();
}
public String getPayload(String filename) throws IOException {
diff --git a/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
index 6b49b78..bd93f73 100644
--- a/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -19,17 +19,12 @@
*/
package org.onap.aai;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import org.javatuples.Pair;
import org.mockito.Mockito;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.parsers.uri.URIToObject;
import org.onap.aai.rest.db.DBRequest;
@@ -37,6 +32,10 @@ import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.setup.SchemaVersions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.ws.rs.core.*;
import java.io.UnsupportedEncodingException;
@@ -51,7 +50,7 @@ import static org.mockito.Mockito.when;
public class HttpTestUtil extends RESTAPI {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(HttpTestUtil.class);
+ private static final Logger logger = LoggerFactory.getLogger(HttpTestUtil.class);
protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
@@ -100,7 +99,7 @@ public class HttpTestUtil extends RESTAPI {
schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
}
- public Response doPut(String uri, String payload) throws AAIException {
+ public Response doPut(String uri, String payload) {
this.init();
Response response = null;
@@ -116,7 +115,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
@@ -128,10 +127,8 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- DBConnectionType type = DBConnectionType.REALTIME;
- //HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
@@ -210,7 +207,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
uri = uri.replaceAll("^v\\d+", "");
@@ -221,10 +218,8 @@ public class HttpTestUtil extends RESTAPI {
version = schemaVersions.getDefaultVersion();
}
- DBConnectionType type = DBConnectionType.REALTIME;
- // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
@@ -293,7 +288,7 @@ public class HttpTestUtil extends RESTAPI {
SchemaVersion version = null;
- if(arr != null && arr.length > 1){
+ if(arr.length > 1){
if(arr[0].matches("^v\\d+")){
version = new SchemaVersion(arr[0]);
if(!uri.contains("relationship-list/relationship")){
@@ -307,10 +302,8 @@ public class HttpTestUtil extends RESTAPI {
}
Mockito.when(uriInfo.getPath()).thenReturn(uri);
- DBConnectionType type = DBConnectionType.REALTIME;
- // HttpEntry httpEntry = new HttpEntry(version, ModelType.MOXY, QueryStyle.TRAVERSAL, type);
HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalHttpEntry", HttpEntry.class);
- resourceHttpEntry.setHttpEntryProperties(version, type);
+ resourceHttpEntry.setHttpEntryProperties(version);
Loader loader = resourceHttpEntry.getLoader();
dbEngine = resourceHttpEntry.getDbEngine();
diff --git a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
index 53b162f..47dfdbe 100644
--- a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
@@ -21,16 +21,18 @@ package org.onap.aai;
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.Vertex;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
-
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
public class IncreaseNodesToolTest extends AAISetup {
@@ -46,6 +48,9 @@ public class IncreaseNodesToolTest extends AAISetup {
@Mock
Vertex mockVertex;
+ @Captor
+ ArgumentCaptor<String> nodeTypeCapture;
+
@Mock
GraphTraversal<org.apache.tinkerpop.gremlin.structure.Vertex, org.apache.tinkerpop.gremlin.structure.Vertex> graphTraversalVertex;
private IncreaseNodesTool increaseNodesTool;
@@ -61,13 +66,13 @@ public class IncreaseNodesToolTest extends AAISetup {
when(janusGraph.newTransaction()).thenReturn(janusGraphtransaction);
when(janusGraphtransaction.traversal()).thenReturn(graphTraversalSource);
- when(graphTraversalSource.addV()).thenReturn(graphTraversalVertex);
+ when(graphTraversalSource.addV(nodeTypeCapture.capture())).thenReturn(graphTraversalVertex);
when(graphTraversalVertex.next()).thenReturn(mockVertex);
increaseNodesTool.run(janusGraph,args);
Mockito.verify(janusGraph).newTransaction();
- Mockito.verify(graphTraversalSource,times(5)).addV();
+ Mockito.verify(graphTraversalSource,times(5)).addV(nodeTypeCapture.capture());
}
@Test
diff --git a/aai-resources/src/test/java/org/onap/aai/ResourcesTestConfiguration.java b/aai-resources/src/test/java/org/onap/aai/ResourcesTestConfiguration.java
index 8ec82ff..09bb7a5 100644
--- a/aai-resources/src/test/java/org/onap/aai/ResourcesTestConfiguration.java
+++ b/aai-resources/src/test/java/org/onap/aai/ResourcesTestConfiguration.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
@@ -46,7 +46,7 @@ import java.security.KeyStore;
@TestConfiguration
public class ResourcesTestConfiguration {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourcesTestConfiguration.class);
+ private static final Logger logger = LoggerFactory.getLogger(ResourcesTestConfiguration.class);
@Autowired
private Environment env;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
index c755838..ff985a9 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java
@@ -26,7 +26,7 @@ import org.janusgraph.core.JanusGraphTransaction;
import org.junit.*;
import org.onap.aai.ResourcesApp;
import org.onap.aai.ResourcesTestConfiguration;
-import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.nodes.NodeIngestor;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java
index 6e98a39..5366802 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java
@@ -29,11 +29,11 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkAddConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(BulkAddConsumerTest.class.getName());
@Test
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
index 1d8702a..d2dff7d 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java
@@ -33,13 +33,13 @@ import org.junit.Test;
import org.onap.aai.dbmap.AAIGraph;
import org.skyscreamer.jsonassert.JSONAssert;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.mock.web.MockHttpServletRequest;
public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(BulkProcessConsumerTest.class.getName());
private LegacyMoxyConsumer legacyMoxyConsumer;
@Test
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
index e735041..d5c112b 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java
@@ -42,8 +42,8 @@ import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class BulkProcessorTestAbstraction extends AAISetup {
@@ -73,7 +73,7 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup {
protected String uri;
private boolean initialized = false;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(BulkProcessorTestAbstraction.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(BulkProcessorTestAbstraction.class.getName());
@BeforeClass
public static void setupRest(){
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
index 0e1cbe4..af7d022 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java
@@ -24,7 +24,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.aai.ResourcesApp;
import org.onap.aai.ResourcesTestConfiguration;
-import org.onap.aai.config.PropertyPasswordConfiguration;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.config.SpringContextAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.embedded.LocalServerPort;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
index 3f50ba3..9d2a519 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -62,7 +62,7 @@ public class ExampleConsumerTest extends AAISetup {
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
@BeforeClass
public static void setupRest(){
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
index 028f596..748b032 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
@@ -19,8 +19,10 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.json.JSONArray;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@@ -45,8 +47,7 @@ import javax.ws.rs.core.*;
import java.io.IOException;
import java.util.*;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.when;
@@ -77,7 +78,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
private boolean initialized = false;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
@BeforeClass
public static void setupRest(){
@@ -172,7 +173,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
@@ -194,7 +195,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
String pserverEntity = response.getEntity().toString();
@@ -220,7 +221,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
@@ -300,7 +301,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertNotNull("Response from the legacy moxy consumer returned null", response);
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals("Expected to return status created from the response",
@@ -320,8 +321,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
@@ -359,7 +359,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
);
int code = response.getStatus();
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
}
@@ -384,7 +384,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
int code = response.getStatus();
assertNotNull("Response from the legacy moxy consumer returned null", response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
response = legacyMoxyConsumer.updateRelationship(
payload,
@@ -398,7 +398,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
assertNotNull("Response from the legacy moxy consumer returned null", response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
mockReq = new MockHttpServletRequest("GET", uri);
response = legacyMoxyConsumer.getLegacy(
"",
@@ -459,7 +459,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
);
int code = response.getStatus();
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
response = legacyMoxyConsumer.updateRelationship(
@@ -472,7 +472,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
);
code = response.getStatus();
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
mockReq = new MockHttpServletRequest("GET", uri);
@@ -504,7 +504,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
);
code = response.getStatus();
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
response = legacyMoxyConsumer.deleteRelationship(
@@ -560,7 +560,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
@@ -584,7 +584,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
assertNotNull("Response from the patch returned null", response);
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.OK.getStatusCode(), code);
}
@@ -625,7 +625,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertNotNull("Response from the legacy moxy consumer returned null", response);
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals("Expected to return status created from the response",
Response.Status.CREATED.getStatusCode(), response.getStatus());
@@ -676,7 +676,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
);
int code = response.getStatus();
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
}
@@ -827,7 +827,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertNotNull("Response from the legacy moxy consumer returned null", response);
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals("Expected to return status created from the response",
@@ -852,7 +852,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
@@ -890,7 +890,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertNotNull("Response from the legacy moxy consumer returned null", response);
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals("Expected to return status created from the response",
@@ -915,7 +915,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
@@ -983,9 +983,420 @@ public class LegacyMoxyConsumerTest extends AAISetup {
int code = response.getStatus();
if(!VALID_HTTP_STATUS_CODES.contains(code)){
- System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
+
+ @Test
+ public void testGetWithSkipRelatedToParam() throws IOException, JSONException {
+ String pserverData = getResourcePayload("pserver1");
+ String vserverData = getResourcePayload("vserver1");
+
+ String hostname = "pserver-hostname-test01";
+ String cloudRegionId ="testAIC01";
+ String tenant ="tenant01";
+ String vserver ="vserver01";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true", hostname);
+ String vserverUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s?skip-related-to=true", cloudRegionId);
+
+ // PUT the resources
+ putResourceWithQueryParam(pserverUri, pserverData);
+ putResourceWithQueryParam(vserverUri, vserverData);
+
+ String pserverMockRequestUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true", hostname);
+ String vserverMockRequestUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s?skip-related-to=true",
+ cloudRegionId, tenant, vserver);
+
+ // === GET - related-to-property should not exist ===
+ // pserver
+ Response pserverResponse = getMockResponse(pserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(pserverResponse, "pserver"));
+
+ // vserver
+ Response vserverResponse = getMockResponse(vserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(vserverResponse, "vserver"));
+ // ===
+
+ // === Clean up (DELETE) ===
+ // vserver
+ String deleteUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ Response response = deleteServerObject(vserverMockRequestUri, deleteUri, "vserver");
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ // pserver
+ deleteUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = deleteServerObject(pserverMockRequestUri, deleteUri, "pserver");
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testGetWithoutSkipRelatedToParam() throws IOException, JSONException {
+ String pserverData = getResourcePayload("pserver2");
+ String vserverData = getResourcePayload("vserver2");
+
+ String hostname = "pserver-hostname-test02";
+ String cloudRegionId ="testAIC02";
+ String tenant ="tenant02";
+ String vserver ="vserver02";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ String vserverUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s", cloudRegionId);
+
+ // PUT the resources
+ doSetupResource(pserverUri, pserverData);
+ doSetupResource(vserverUri, vserverData);
+
+ String pserverMockRequestUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ String vserverMockRequestUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+
+ // === GET - related-to-property should not exist ===
+ // pserver
+ Response pserverResponse = getMockResponse(pserverMockRequestUri);
+ assertFalse(isRelatedToPropertiesFieldNullInResponse(pserverResponse, "pserver"));
+
+ // vserver
+ Response vserverResponse = getMockResponse(vserverMockRequestUri);
+ assertFalse(isRelatedToPropertiesFieldNullInResponse(vserverResponse, "vserver"));
+ // ===
+
+ // === Clean up (DELETE) ===
+ // vserver
+ String deleteUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ Response response = deleteServerObject(vserverMockRequestUri, deleteUri, "vserver");
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ // pserver
+ deleteUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = deleteServerObject(pserverMockRequestUri, deleteUri, "pserver");
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testGetWithSkipRelatedToParamAndFormatResource() throws IOException, JSONException {
+ String pserverData = getResourcePayload("pserver3");
+ String vserverData = getResourcePayload("vserver3");
+
+ String hostname = "pserver-hostname-test03";
+ String cloudRegionId ="testAIC03";
+ String tenant ="tenant03";
+ String vserver ="vserver03";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true&format=resource", hostname);
+ String vserverUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s?skip-related-to=true&format=resource", cloudRegionId);
+
+ // PUT the resources
+ putResourceWithQueryParam(pserverUri, pserverData);
+ putResourceWithQueryParam(vserverUri, vserverData);
+
+ String pserverMockRequestUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true&format=resource", hostname);
+ String vserverMockRequestUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s?skip-related-to=true&format=resource",
+ cloudRegionId, tenant, vserver);
+
+ // === GET - related-to-property should not exist ===
+ // pserver
+ Response pserverResponse = getMockResponse(pserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(pserverResponse, "pserver"));
+
+ // vserver
+ Response vserverResponse = getMockResponse(vserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(vserverResponse, "vserver"));
+ // ===
+
+ // === Clean up (DELETE) ===
+ // vserver
+ String deleteUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ String vserverMockRequestUriNoFormat = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ Response response = deleteServerObject(vserverMockRequestUriNoFormat, deleteUri, "vserver");
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ // pserver
+ deleteUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = deleteServerObject(pserverMockRequestUri, deleteUri, "pserver");
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ }
+
+ @Test
+ public void testGetWithSkipRelatedToParamAndFormatResourceAndUrl() throws IOException, JSONException {
+ String pserverData = getResourcePayload("pserver4");
+ String vserverData = getResourcePayload("vserver4");
+
+ String hostname = "pserver-hostname-test04";
+ String cloudRegionId ="testAIC04";
+ String tenant ="tenant04";
+ String vserver ="vserver04";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true&format=resource_and_url", hostname);
+ String vserverUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s?skip-related-to=true&format=resource_and_url", cloudRegionId);
+
+ // PUT the resources
+ putResourceWithQueryParam(pserverUri, pserverData);
+ putResourceWithQueryParam(vserverUri, vserverData);
+
+ String pserverMockRequestUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true&format=resource_and_url", hostname);
+ String vserverMockRequestUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s?skip-related-to=true&format=resource_and_url",
+ cloudRegionId, tenant, vserver);
+
+ // === GET - related-to-property should not exist ===
+ // pserver
+ Response pserverResponse = getMockResponse(pserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(pserverResponse, "pserver"));
+
+ // vserver
+ Response vserverResponse = getMockResponse(vserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(vserverResponse, "vserver"));
+ // ===
+
+ // === Clean up (DELETE) ===
+ // vserver
+ String deleteUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ String vserverMockRequestUriNoFormat = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ Response response = deleteServerObject(vserverMockRequestUriNoFormat, deleteUri, "vserver");
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ // pserver
+ deleteUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = deleteServerObject(pserverMockRequestUri, deleteUri, "pserver");
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ @Test
+ public void testGetVserversWithSkipRelatedToParam() throws IOException, JSONException {
+ String pserverData = getResourcePayload("pserver5");
+ String vserverData = getResourcePayload("vserver5");
+
+ String hostname = "pserver-hostname-test05";
+ String cloudRegionId ="testAIC05";
+ String tenant ="tenant05";
+ String vserver ="vserver05";
+
+ String pserverUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true", hostname);
+ String vserverUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s?skip-related-to=true", cloudRegionId);
+
+ // PUT the resources
+ putResourceWithQueryParam(pserverUri, pserverData);
+ putResourceWithQueryParam(vserverUri, vserverData);
+
+ String pserverMockRequestUri = String.format("cloud-infrastructure/pservers/pserver/%s?skip-related-to=true", hostname);
+ String vserverMockRequestUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers?vserver-selflink=somelink05&skip-related-to=true",
+ cloudRegionId, tenant, vserver);
+
+ // === GET - related-to-property should not exist ===
+ // pserver
+ Response pserverResponse = getMockResponse(pserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(pserverResponse, "pserver"));
+
+ // vserver
+ Response vserverResponse = getMockResponse(vserverMockRequestUri);
+ assertTrue(isRelatedToPropertiesFieldNullInResponse(vserverResponse, "vserver"));
+ // ===
+
+ // === Clean up (DELETE) ===
+ // vserver
+ String deleteUri = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ String vserverMockRequestUriNoFormat = String.format("cloud-infrastructure/cloud-regions/cloud-region/test-aic/%s/tenants/tenant/%s/vservers/vserver/%s",
+ cloudRegionId, tenant, vserver);
+ Response response = deleteServerObject(vserverMockRequestUriNoFormat, deleteUri, "vserver");
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+
+ // pserver
+ deleteUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
+ response = deleteServerObject(pserverMockRequestUri, deleteUri, "pserver");
+ code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
+ }
+
+ private Response deleteServerObject(String mockUri, String deleteUri, String nodeType) throws IOException, JSONException {
+ Response response = getMockResponse(mockUri);
+ String serverEntity = response.getEntity().toString();
+ JSONObject serverJsonObject = new JSONObject(serverEntity);
+ boolean noResultsArray = false;
+ String resourceVersion = "";
+ try {
+ JSONArray resultsJsonArray = (JSONArray) serverJsonObject.get("results");
+ if (resultsJsonArray != null) {
+ JSONObject servers = (JSONObject) resultsJsonArray.get(0);
+ JSONObject server = (JSONObject) servers.get(nodeType);
+ resourceVersion = server.getString("resource-version");
+ }
+ } catch (Exception e) {
+ noResultsArray = true;
+ }
+ if (noResultsArray)
+ resourceVersion = serverJsonObject.getString("resource-version");
+ queryParameters.clear();
+ queryParameters.add("resource-version", resourceVersion);
+
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("DELETE", deleteUri);
+ Response deleteResponse = legacyMoxyConsumer.delete(
+ schemaVersions.getDefaultVersion().toString(),
+ deleteUri,
+ httpHeaders,
+ uriInfo,
+ resourceVersion,
+ mockReq
+ );
+ return deleteResponse;
+ }
+
+ private void putResourceWithQueryParam(String uri, String payload) {
+
+ String[] uriSplit = uri.split("\\?");
+ if (uriSplit[1] != null && !uriSplit[1].isEmpty()) {
+ String[] params;
+ if (!uriSplit[1].contains("&")) {
+ String param = uriSplit[1];
+ params = new String[]{param};
+ } else {
+ params = uriSplit[1].split("&");
+ }
+ for (String param : params) {
+ String[] splitParam = param.split("=");
+ String key = splitParam[0];
+ String value = splitParam[1];
+ uriInfo.getQueryParameters().add(key, value);
+ }
+ }
+ uri = uriSplit[0];
+
+ when(uriInfo.getPath()).thenReturn(uri);
+ when(uriInfo.getPath(false)).thenReturn(uri);
+
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri);
+ Response response = legacyMoxyConsumer.update(
+ payload,
+ schemaVersions.getDefaultVersion().toString(),
+ uri,
+ httpHeaders,
+ uriInfo,
+ mockReq
+ );
+
+ assertNotNull("Response from the legacy moxy consumer returned null", response);
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ assertEquals("Expected to return status created from the response",
+ Response.Status.CREATED.getStatusCode(), response.getStatus());
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+
+ private Response getMockResponse(String mockUri) throws IOException, JSONException {
+ MockHttpServletRequest mockReq = new MockHttpServletRequest("GET", mockUri);
+ Response response = legacyMoxyConsumer.getLegacy(
+ "",
+ null,
+ null,
+ schemaVersions.getDefaultVersion().toString(),
+ mockUri,
+ "10000",
+ "false",
+ httpHeaders,
+ uriInfo,
+ mockReq
+ );
+ String responseEntity = response.getEntity().toString();
+ int code = response.getStatus();
+ if(!VALID_HTTP_STATUS_CODES.contains(code)){
+ logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
+ }
+ return response;
+ }
+
+ private boolean isRelatedToPropertiesFieldNullInResponse(Response response, String nodeType) throws IOException, JSONException {
+ String responseEntity = response.getEntity().toString();
+ boolean noResultsArray = false;
+ JSONObject responseJsonObj = new JSONObject(responseEntity);
+ try {
+ JSONArray resultsJsonArray = (JSONArray) responseJsonObj.get("results");
+ if (resultsJsonArray != null) {
+ JSONObject servers = (JSONObject) resultsJsonArray.get(0);
+ JSONObject server = (JSONObject) servers.get(nodeType);
+ JSONObject relationshipList = (JSONObject) server.get("relationship-list");
+ if (relationshipList != null) {
+ JSONArray relationship = (JSONArray) relationshipList.get("relationship");
+ if (relationship != null) {
+ JSONObject relationshipObj = relationship.getJSONObject(0);
+ JSONArray relatedToProperty = (JSONArray) relationshipObj.get("related-to-property");
+ if (relatedToProperty != null)
+ return false;
+ }
+ }
+ }
+ } catch (Exception e) {
+ noResultsArray = true;
+ }
+
+ if (noResultsArray) {
+ try {
+ JSONObject relationshipList = (JSONObject) responseJsonObj.get("relationship-list");
+ if (relationshipList != null) {
+ JSONArray relationship = (JSONArray) relationshipList.get("relationship");
+ if (relationship != null) {
+ JSONObject relationshipObj = relationship.getJSONObject(0);
+ JSONArray relatedToProperty = (JSONArray) relationshipObj.get("related-to-property");
+ if (relatedToProperty != null)
+ return false;
+ }
+ }
+ } catch (JSONException je) {
+ logger.info("JSON Exception Error: " + je);
+ } catch (Exception e) {
+ logger.info("JSON Exception Error: " + e);
+ }
+ }
+ return true;
+ }
}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
index 2edec7b..c6885c7 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.json.JSONException;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -65,7 +65,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
private boolean initialized = false;
@BeforeClass
public static void setupRest(){
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
index 8d3f5a8..e4e7340 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.rest;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.json.JSONException;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -64,7 +64,7 @@ public class VertexIdConsumerTest extends AAISetup {
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumerTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
private boolean initialized = false;
@BeforeClass
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java
index e317297..8c24fb4 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java
@@ -19,6 +19,8 @@
*/
package org.onap.aai.rest.bulk;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonParser;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -33,6 +35,7 @@ import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.rest.BulkConsumer;
import org.onap.aai.rest.BulkProcessorTestAbstraction;
import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.test.context.TestPropertySource;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.Response;
@@ -44,9 +47,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
+@TestPropertySource(properties = {
+ "delta.events.enabled=true",
+})
public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstraction {
- private BulkSingleTransactionConsumer bulkSingleTransactionConsumer = new BulkSingleTransactionConsumer();
+ private BulkSingleTransactionConsumer bulkSingleTransactionConsumer = new BulkSingleTransactionConsumer("/aai");
@Rule
public TestName name = new TestName();
@@ -220,6 +226,8 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
assertThat("Response contains 204 status.",
response.getEntity().toString(),
containsString("\"response-status-code\":204"));
+
+
}
@Test
@@ -244,8 +252,10 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
.replaceAll("<methodName>", name.getMethodName());
Response response = executeRequest(payload);
+ System.out.println(response.getEntity().toString());
+
assertEquals("Request failed",
- Response.Status.BAD_REQUEST.getStatusCode(),
+ Response.Status.PRECONDITION_FAILED.getStatusCode(),
response.getStatus());
assertEquals("1 vertex exists after payload due to failure",
@@ -253,13 +263,17 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
AAIGraph.getInstance().getGraph().newTransaction().traversal().
V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
+ assertThat("Response contains resource version msg for failed transaction.",
+ response.getEntity().toString(),
+ containsString("Precondition Failed:resource-version MISMATCH for delete of generic-vnf"));
+
assertThat("Response contains correct index of failed operation.",
response.getEntity().toString(),
- containsString("Operation 3 failed with status code (412) and msg"));
+ containsString("Operation 3"));
- assertThat("Response contains resource version msg for failed transaction.",
+ assertThat("Response contains correct status code.",
response.getEntity().toString(),
- containsString("Precondition Failed:resource-version MISMATCH for delete of generic-vnf"));
+ containsString("failed with status code (412"));
}
@@ -342,7 +356,81 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
}
+ @Test
+ public void putComplexWithRelToNonExistentPserverBetween() throws IOException {
+
+ String payload = getBulkPayload("single-transaction/put-complex-with-rel-to-non-existent").replaceAll("<methodName>", name.getMethodName());
+ Response response = executeRequest(payload);
+
+ assertEquals("Request success",
+ Response.Status.NOT_FOUND.getStatusCode(),
+ response.getStatus());
+ assertEquals("0 vertex from this test in graph",
+ Long.valueOf(0L),
+ AAIGraph.getInstance().getGraph().newTransaction().traversal().
+ V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
+ assertEquals("Request fails with 404",
+ Response.Status.NOT_FOUND.getStatusCode(),
+ response.getStatus());
+
+ assertThat("Response contains correct index of failed operation.",
+ response.getEntity().toString(),
+ containsString("Operation 0"));
+
+ assertThat("Response contains correct status code.",
+ response.getEntity().toString(),
+ containsString("failed with status code (404"));
+
+ assertThat("Response contains correct msg.",
+ response.getEntity().toString(),
+ containsString("target node:Node of type pserver. Could not find"));
+ assertThat("Response contains correct Error Code.",
+ response.getEntity().toString(),
+ containsString("ERR.5.4.6129"));
+
+ }
+
+
+ @Test
+ public void deleteChildRecreateChildTest() throws IOException {
+ JsonArray requests = new JsonParser().parse(
+ getBulkPayload("single-transaction/delete-child-recreate-child").replaceAll("<methodName>", name.getMethodName()))
+ .getAsJsonObject().getAsJsonArray("array");
+ String payload = requests.get(0).toString();
+ Response response = executeRequest(payload);
+ System.out.println(response.getEntity().toString());
+ assertEquals("Request success",
+ Response.Status.CREATED.getStatusCode(),
+ response.getStatus());
+
+ payload = requests.get(1).toString();
+ response = executeRequest(payload);
+ System.out.println(response.getEntity().toString());
+ assertEquals("Request success",
+ Response.Status.CREATED.getStatusCode(),
+ response.getStatus());
+ }
+
+ @Test
+ public void deleteNodeRecreateNodeTest() throws IOException {
+ JsonArray requests = new JsonParser().parse(
+ getBulkPayload("single-transaction/delete-node-recreate-node").replaceAll("<methodName>", name.getMethodName()))
+ .getAsJsonObject().getAsJsonArray("array");
+ String payload = requests.get(0).toString();
+ Response response = executeRequest(payload);
+ System.out.println(response.getEntity().toString());
+ assertEquals("Request success",
+ Response.Status.CREATED.getStatusCode(),
+ response.getStatus());
+
+ payload = requests.get(1).toString();
+ response = executeRequest(payload);
+ System.out.println(response.getEntity().toString());
+ assertEquals("Request success",
+ Response.Status.CREATED.getStatusCode(),
+ response.getStatus());
+ }
protected Response executeRequest(String finalPayload) {
@@ -364,6 +452,6 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
@Override
protected String getUri() {
- return "/aai/" + schemaVersions.getDefaultVersion().toString() + "/bulk-single-transaction-multi-operation";
+ return "/aai/" + schemaVersions.getDefaultVersion().toString() + "/bulk/single-transaction";
}
} \ No newline at end of file
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
index c629ca7..cdd3a51 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.rest.retired;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.Test;
import org.onap.aai.rest.AbstractSpringRestTest;
import org.springframework.http.HttpMethod;
@@ -33,7 +33,7 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
public class RetiredConsumerSpringTest extends AbstractSpringRestTest {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(RetiredConsumerSpringTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(RetiredConsumerSpringTest.class);
private Map<String, HttpStatus> httpStatusMap;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
index aa60d94..9f55961 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java
@@ -19,8 +19,8 @@
*/
package org.onap.aai.rest.util;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -60,7 +60,7 @@ public class EchoResponseTest extends AAISetup {
private List<MediaType> outputMediaTypes;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(EchoResponseTest.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(EchoResponseTest.class.getName());
@Before
public void setup(){