aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-04-02 09:52:44 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-04-02 09:52:44 +0200
commit96222bb900d5dce5c3b2dcc91c67bf33fa426cdc (patch)
tree0f80425739b7bad1b2f176a76157cdd32bd07fdf
parent07d0f586e0dc280ac2b6dfebb47fb60e15c2914b (diff)
Migrate resources to Junit 5
Issue-ID: AAI-3815 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I6d4acbbb38c7674656690978cc1e50106f0c15cf
-rw-r--r--aai-resources/pom.xml31
-rw-r--r--aai-resources/src/test/java/org/onap/aai/AAISetup.java12
-rw-r--r--aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/PayloadUtil.java8
-rw-r--r--aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/AbstractSpringRestTest.java12
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkAddConsumerTest.java59
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessConsumerTest.java116
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java8
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ConfigurationTest.java10
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java18
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java12
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java85
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java6
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java22
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java20
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java174
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/retired/RetiredConsumerSpringTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java10
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/task/AaiGraphCheckerTest.java8
30 files changed, 363 insertions, 308 deletions
diff --git a/aai-resources/pom.xml b/aai-resources/pom.xml
index dcc656c..ced10c2 100644
--- a/aai-resources/pom.xml
+++ b/aai-resources/pom.xml
@@ -92,7 +92,7 @@
<micrometer-registry-prometheus.version>1.6.6</micrometer-registry-prometheus.version>
<micrometer-jersey2>1.6.6</micrometer-jersey2>
<testcontainers.version>1.6.1</testcontainers.version>
- <mockito.core.version>3.4.0</mockito.core.version>
+ <mockito.core.version>4.4.0</mockito.core.version>
<eclipse.persistence.version>2.6.2</eclipse.persistence.version>
<!-- Setting some default value to not complain by editor but it will be overridden by gmaven plugin -->
@@ -453,13 +453,14 @@
<version>6.6</version>
</dependency>
<dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-junit</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-junit</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -478,7 +479,12 @@
<artifactId>mockito-core</artifactId>
<version>${mockito.core.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
@@ -706,6 +712,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>${keycloak.version}</version>
@@ -1016,7 +1027,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
- <version>3.0.0-M4</version>
+ <version>3.1.2</version>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
</configuration>
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 dc1e6c8..b510c00 100644
--- a/aai-resources/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
@@ -20,7 +20,7 @@
package org.onap.aai;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
@@ -28,9 +28,11 @@ import java.nio.charset.Charset;
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.runner.RunWith;
import org.onap.aai.config.ConfigConfiguration;
import org.onap.aai.config.IntrospectionConfig;
import org.onap.aai.config.RestBeanConfig;
@@ -48,9 +50,11 @@ import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(
classes = {ConfigConfiguration.class, AAIConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class,
EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class,
@@ -84,7 +88,7 @@ public abstract class AAISetup {
@Rule
public final SpringMethodRule springMethodRule = new SpringMethodRule();
- @BeforeClass
+ @BeforeAll
public static void setupBundleconfig() throws Exception {
System.setProperty("AJSC_HOME", "./");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
@@ -95,7 +99,7 @@ public abstract class AAISetup {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(filename);
String message = String.format("Unable to find the %s in src/test/resources", filename);
- assertNotNull(message, inputStream);
+ assertNotNull(inputStream, message);
String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
return resource;
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 328e611..c5b96ed 100644
--- a/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/IncreaseNodesToolTest.java
@@ -28,8 +28,8 @@ 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.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
@@ -58,7 +58,7 @@ public class IncreaseNodesToolTest extends AAISetup {
String[] args = {"-numberOfNodes", "5", "-nodeType", "pserver", "-uri", "/cloud-infrastructure/pservers/pserver/",
"-child", "false"};
- @Before
+ @BeforeEach
public void setup() {
increaseNodesTool = new IncreaseNodesTool(loaderFactory, schemaVersions);
}
diff --git a/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java b/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java
index eb1c52c..9dd3375 100644
--- a/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java
+++ b/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java
@@ -20,7 +20,7 @@
package org.onap.aai;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
@@ -43,7 +43,7 @@ public class PayloadUtil {
PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/resource/" + fileName);
String message = String.format("Unable to find the %s in src/test/resources", fileName);
- assertNotNull(message, inputStream);
+ assertNotNull(inputStream, message);
String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
@@ -57,7 +57,7 @@ public class PayloadUtil {
PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/templates/" + fileName);
String message = String.format("Unable to find the %s in src/test/resources", fileName);
- assertNotNull(message, inputStream);
+ assertNotNull(inputStream, message);
String resource;
@@ -94,7 +94,7 @@ public class PayloadUtil {
InputStream inputStream = PayloadUtil.class.getClassLoader().getResourceAsStream("payloads/" + fileName);
String message = String.format("Unable to find the %s in src/test/resources/payloads/", fileName);
- assertNotNull(message, inputStream);
+ assertNotNull(inputStream, message);
String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
diff --git a/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java b/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java
index baa78c9..892b8e3 100644
--- a/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java
+++ b/aai-resources/src/test/java/org/onap/aai/it/multitenancy/MultiTenancyIT.java
@@ -20,14 +20,14 @@
package org.onap.aai.it.multitenancy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import dasniko.testcontainers.keycloak.KeycloakContainer;
+import org.junit.jupiter.api.Test;
import java.util.Collections;
-import org.junit.Test;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.representations.AccessTokenResponse;
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 b4a1b52..9e901ad 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
@@ -28,11 +28,11 @@ import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.onap.aai.ResourcesApp;
import org.onap.aai.ResourcesTestConfiguration;
import org.onap.aai.dbmap.AAIGraph;
@@ -79,13 +79,13 @@ public abstract class AbstractSpringRestTest {
protected String baseUrl;
protected HttpHeaders headers;
- @BeforeClass
+ @BeforeAll
public static void setupConfig() throws AAIException {
System.setProperty("AJSC_HOME", "./");
System.setProperty("BUNDLECONFIG_DIR", "src/main/resources/");
}
- @Before
+ @BeforeEach
public void setup() throws AAIException, UnsupportedEncodingException {
AAIConfig.init();
@@ -106,7 +106,7 @@ public abstract class AbstractSpringRestTest {
baseUrl = "http://localhost:" + randomPort;
}
- @After
+ @AfterEach
public void tearDown() {
JanusGraph janusGraph = AAIGraph.getInstance().getGraph();
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 de72d5c..52a62d8 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
@@ -20,7 +20,7 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -28,7 +28,7 @@ import java.io.IOException;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,9 +45,10 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-transactions");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 3 {\"201\":null}", 3,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(3,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 3 {\"201\":null}");
}
@Test
@@ -59,13 +60,16 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-process-transactions");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"201\":null}", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- assertEquals("Contains 1 {\"400\":\"{", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6118", 1,
- StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 1 {\"201\":null}");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"),
+ "Contains 1 {\"400\":\"{");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"),
+ "Contains 1 ERR.5.4.6118");
}
@Test
@@ -77,11 +81,13 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-transactions-invalid-method");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"400\":\"{", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6118", 1,
- StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"),
+ "Contains 1 {\"400\":\"{");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"),
+ "Contains 1 ERR.5.4.6118");
}
@Test
@@ -93,8 +99,8 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = "{\"transactions\":[]}";
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6118"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6118"), "Contains error code");
}
@Test
@@ -106,8 +112,8 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = "{";
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6111"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6111"), "Contains error code");
}
@Test
@@ -118,9 +124,10 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-limit-meet");
Response response = executeRequest(payload);
- assertEquals("Created", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 30 {\"201\":null}", 30,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Created");
+ assertEquals(30,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 30 {\"201\":null}");
}
@Test
@@ -131,8 +138,8 @@ public class BulkAddConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-limit-exceed");
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6147"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6147"), "Contains error code");
}
@Override
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 a435f45..e64ecc0 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
@@ -20,8 +20,8 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.dbmap.AAIGraph;
import org.skyscreamer.jsonassert.JSONAssert;
import org.slf4j.Logger;
@@ -51,9 +51,10 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-transactions");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 3 {\"201\":null}", 3,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(3,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 3 {\"201\":null}");
}
@Test
@@ -65,13 +66,16 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-process-transactions");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"201\":null}", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- assertEquals("Contains 1 {\"404\":\"{", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6114", 1,
- StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 1 {\"201\":null}");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"),
+ "Contains 1 {\"404\":\"{");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"),
+ "Contains 1 ERR.5.4.6114");
}
@Test
@@ -85,7 +89,7 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
System.out.println(response.getEntity());
System.out.println(
AAIGraph.getInstance().getGraph().newTransaction().traversal().V().has("fqdn", "NEW").count().next());
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
}
@Test
@@ -98,13 +102,16 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
Response response = executeRequest(payload);
System.out.println(response.getEntity().toString());
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 0 {\"201\":null}", 0,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
- assertEquals("Contains 1 {\"404\":\"{", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6114", 1,
- StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(0,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 0 {\"201\":null}");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"404\":\"{"),
+ "Contains 1 {\"404\":\"{");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6114"),
+ "Contains 1 ERR.5.4.6114");
}
@Test
@@ -133,14 +140,15 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
schemaVersions.getDefaultVersion().toString(), complexToPserverRelationshipUri, httpHeaders, uriInfo,
new MockHttpServletRequest("DELETE", "http://www.test.com"));
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
int code = response.getStatus();
if (!VALID_HTTP_STATUS_CODES.contains(code)) {
System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
}
- assertEquals("Expected to return status created from the response", Response.Status.OK.getStatusCode(),
- response.getStatus());
+ assertEquals(Response.Status.OK.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
// TODO - Need to actually verify the relationship between pserver and cloud-region
@@ -156,10 +164,12 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity());
System.out.println("Response Code: " + code + "\tEntity: " + responseBulkDelete.getEntity());
}
- assertEquals("Expected to return status created from the response", Response.Status.CREATED.getStatusCode(),
- responseBulkDelete.getStatus());
- assertEquals("Contains 0 {\"204\":null}", 1,
- StringUtils.countMatches(responseBulkDelete.getEntity().toString(), "{\"204\":null}"));
+ assertEquals(Response.Status.CREATED.getStatusCode(),
+ responseBulkDelete.getStatus(),
+ "Expected to return status created from the response");
+ assertEquals(1,
+ StringUtils.countMatches(responseBulkDelete.getEntity().toString(), "{\"204\":null}"),
+ "Contains 0 {\"204\":null}");
}
@@ -171,28 +181,29 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
Response response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(),
uri, "all", "false", httpHeaders, uriInfo, new MockHttpServletRequest("GET", "http://www.test.com"));
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to not have the data already in memory", Response.Status.NOT_FOUND.getStatusCode(),
- response.getStatus());
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
+ response.getStatus(),
+ "Expected to not have the data already in memory");
response = legacyMoxyConsumer.update(payload, schemaVersions.getDefaultVersion().toString(), uri, httpHeaders,
uriInfo, new MockHttpServletRequest("PUT", "http://www.test.com"));
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
int code = response.getStatus();
if (!VALID_HTTP_STATUS_CODES.contains(code)) {
System.out.println("Response Code: " + code + "\tEntity: " + response.getEntity());
}
- assertEquals("Expected to return status created from the response", Response.Status.CREATED.getStatusCode(),
- response.getStatus());
+ assertEquals(Response.Status.CREATED.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
queryParameters.add("depth", "10000");
response = legacyMoxyConsumer.getLegacy("", "-1", "-1", schemaVersions.getDefaultVersion().toString(), uri,
"all", "false", httpHeaders, uriInfo, new MockHttpServletRequest("GET", "http://www.test.com"));
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to return the pserver data that was just put in memory",
- Response.Status.OK.getStatusCode(), response.getStatus());
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus(), "Expected to return the pserver data that was just put in memory");
if ("".equalsIgnoreCase(payload)) {
payload = "{}";
@@ -210,11 +221,13 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-transactions-invalid-method");
Response response = executeRequest(payload);
- assertEquals("Valid Response Code", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 1 {\"400\":\"{", 1,
- StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"));
- assertEquals("Contains 1 ERR.5.4.6118", 1,
- StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Valid Response Code");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"400\":\"{"),
+ "Contains 1 {\"400\":\"{");
+ assertEquals(1,
+ StringUtils.countMatches(response.getEntity().toString(), "ERR.5.4.6118"),
+ "Contains 1 ERR.5.4.6118");
}
@Test
@@ -226,8 +239,8 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = "{\"transactions\":[]}";
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6118"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6118"), "Contains error code");
}
@Test
@@ -239,8 +252,8 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = "{";
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6111"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6111"), "Contains error code");
}
@Test
@@ -251,9 +264,10 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-limit-meet");
Response response = executeRequest(payload);
- assertEquals("Created", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("Contains 30 {\"201\":null}", 30,
- StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"));
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Created");
+ assertEquals(30,
+ StringUtils.countMatches(response.getEntity().toString(), "{\"201\":null}"),
+ "Contains 30 {\"201\":null}");
}
@Test
@@ -264,8 +278,8 @@ public class BulkProcessConsumerTest extends BulkProcessorTestAbstraction {
String payload = getBulkPayload("pserver-bulk-limit-exceed");
Response response = executeRequest(payload);
- assertEquals("Bad Request", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
- assertEquals("Contains error code", true, response.getEntity().toString().contains("ERR.5.4.6147"));
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Bad Request");
+ assertEquals(true, response.getEntity().toString().contains("ERR.5.4.6147"), "Contains error code");
}
@Override
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 e4a9d71..68974a3 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
@@ -37,8 +37,8 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
@@ -76,13 +76,13 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup {
private boolean initialized = false;
private static final Logger logger = LoggerFactory.getLogger(BulkProcessorTestAbstraction.class.getName());
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
// AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
if (!initialized) {
initialized = true;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java b/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java
index fd4d34b..dda8a8a 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/CloudRegionTest.java
@@ -22,11 +22,11 @@ package org.onap.aai.rest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.PayloadUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
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 8cc28fc..5e1142d 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
@@ -20,8 +20,8 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.jayway.jsonpath.JsonPath;
@@ -30,8 +30,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.ResourcesApp;
import org.onap.aai.ResourcesTestConfiguration;
import org.onap.aai.config.SpringContextAware;
@@ -79,7 +79,7 @@ public class ConfigurationTest extends AbstractSpringRestTest {
private HttpHeaders headersGet;
private HttpHeaders headersPutPatch;
- @Before
+ @BeforeEach
public void setup() throws UnsupportedEncodingException {
headersGet = new HttpHeaders();
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java
index 28347cb..3693da2 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/CustomerFilterSearchTest.java
@@ -21,13 +21,13 @@
package org.onap.aai.rest;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Base64;
import java.util.Collections;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.PayloadUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
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 0039303..96e7716 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
@@ -20,8 +20,8 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -38,9 +38,9 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
@@ -74,13 +74,13 @@ public class ExampleConsumerTest extends AAISetup {
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
logger.info("Starting the setup for the integration tests of Rest Endpoints");
@@ -123,7 +123,7 @@ public class ExampleConsumerTest extends AAISetup {
Response response = exampleConsumer.getExample(schemaVersions.getDefaultVersion().toString(), "pserver",
httpHeaders, uriInfo, null);
- assertNotNull("Response from the example consumer returned null", response);
+ assertNotNull(response, "Response from the example consumer returned null");
int code = Response.Status.OK.getStatusCode();
@@ -139,7 +139,7 @@ public class ExampleConsumerTest extends AAISetup {
Response response = exampleConsumer.getExample(schemaVersions.getDefaultVersion().toString(),
"testRandomCrazyObject", httpHeaders, uriInfo, null);
- assertNotNull("Response from the example consumer returned null", response);
+ assertNotNull(response, "Response from the example consumer returned null");
int code = Response.Status.BAD_REQUEST.getStatusCode();
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
index 27f702f..4b4c87b 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java
@@ -20,9 +20,9 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -43,8 +43,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.Response;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -63,7 +63,7 @@ public class ExceptionHandlerTest extends AAISetup {
@InjectMocks
private ExceptionHandler handler = new ExceptionHandler();
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java
index d0d0668..f350e5d 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/InvalidURITest.java
@@ -22,9 +22,9 @@ package org.onap.aai.rest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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 2855b57..1524f69 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
@@ -20,10 +20,10 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -46,10 +46,10 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.simple.parser.ParseException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
@@ -90,12 +90,12 @@ public class LegacyMoxyConsumerTest extends AAISetup {
private String defaultSchemaVersion;
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
// AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
if (!initialized) {
initialized = true;
@@ -144,8 +144,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
String uri = getUri();
String payload = getResourcePayload(getObjectName());
- assertNotNull("Introspector returned invalid string when marshalling the object", payload);
- assertNotNull("Introspector failed to return a valid uri", uri);
+ assertNotNull(payload, "Introspector returned invalid string when marshalling the object");
+ assertNotNull(uri, "Introspector failed to return a valid uri");
if (uri.length() != 0 && uri.charAt(0) == '/') {
uri = uri.substring(1);
@@ -250,14 +250,15 @@ public class LegacyMoxyConsumerTest extends AAISetup {
defaultSchemaVersion, cloudToPserverRelationshipUri, httpHeaders, uriInfo,
mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
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.OK.getStatusCode(),
- response.getStatus());
+ assertEquals(Response.Status.OK.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
// TODO - Need to actually verify the relationship between pserver and cloud-region
@@ -317,7 +318,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
httpHeaders, uriInfo, mockReq);
int code = response.getStatus();
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
@@ -325,14 +326,14 @@ public class LegacyMoxyConsumerTest extends AAISetup {
httpHeaders, uriInfo, mockReq);
code = response.getStatus();
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
mockReq = new MockHttpServletRequest("GET", uri);
response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
"all", "false", httpHeaders, uriInfo, mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), code);
mockReq = new MockHttpServletRequest("DELETE", uri);
response = legacyMoxyConsumer.delete(defaultSchemaVersion, uri, httpHeaders, uriInfo,
@@ -374,7 +375,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
"all", "false", httpHeaders, uriInfo, mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), code);
mockReq = new MockHttpServletRequest("DELETE", uri);
@@ -393,7 +394,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
}
@Test
- @Ignore("Unable to test this method due to WRITE_BIGDECIMAL_AS_PLAIN error")
+ @Disabled("Unable to test this method due to WRITE_BIGDECIMAL_AS_PLAIN error")
public void testPatchWithValidData() throws IOException {
String payload = getResourcePayload("pserver-patch-test");
@@ -434,7 +435,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
uriInfo, mockReq);
code = response.getStatus();
- assertNotNull("Response from the patch returned null", response);
+ assertNotNull(response, "Response from the patch returned null");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
assertEquals(Response.Status.OK.getStatusCode(), code);
@@ -451,28 +452,29 @@ public class LegacyMoxyConsumerTest extends AAISetup {
Response response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion,
uri, "all", "false", httpHeaders, uriInfo, mockRequest);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to not have the data already in memory", Response.Status.NOT_FOUND.getStatusCode(),
- response.getStatus());
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
+ response.getStatus(),
+ "Expected to not have the data already in memory");
response = legacyMoxyConsumer.update(payload, defaultSchemaVersion, uri, httpHeaders,
uriInfo, mockRequest);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
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());
+ assertEquals(Response.Status.CREATED.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
queryParameters.add("depth", "10000");
response = legacyMoxyConsumer.getLegacy("", null, null, defaultSchemaVersion, uri,
"all", "false", httpHeaders, uriInfo, mockRequest);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
- assertEquals("Expected to return the pserver data that was just put in memory",
- Response.Status.OK.getStatusCode(), response.getStatus());
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatus(), "Expected to return the pserver data that was just put in memory");
if ("".equalsIgnoreCase(payload)) {
payload = "{}";
@@ -568,7 +570,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
assertEquals(-1, timeout);
}
- @Ignore("Time sensitive test only times out if the response takes longer than 1 second")
+ @Disabled("Time sensitive test only times out if the response takes longer than 1 second")
@Test
public void testTimeoutGetCall() throws Exception {
String uri = getUri();
@@ -632,14 +634,15 @@ public class LegacyMoxyConsumerTest extends AAISetup {
defaultSchemaVersion, cloudToPserverRelationshipUri, httpHeaders, uriInfo,
mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
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.OK.getStatusCode(),
- response.getStatus());
+ assertEquals(Response.Status.OK.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
String getRelationshipUri = String.format("cloud-infrastructure/pservers/pserver/%s", hostname);
@@ -681,14 +684,15 @@ public class LegacyMoxyConsumerTest extends AAISetup {
defaultSchemaVersion, cloudToPserverRelationshipUri, httpHeaders, uriInfo,
mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
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.OK.getStatusCode(),
- response.getStatus());
+ assertEquals(Response.Status.OK.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
String getRelationshipMockRequestUri =
@@ -1121,14 +1125,15 @@ public class LegacyMoxyConsumerTest extends AAISetup {
Response response = legacyMoxyConsumer.update(payload, defaultSchemaVersion, uri,
httpHeaders, uriInfo, mockReq);
- assertNotNull("Response from the legacy moxy consumer returned null", response);
+ assertNotNull(response, "Response from the legacy moxy consumer returned null");
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());
+ assertEquals(Response.Status.CREATED.getStatusCode(),
+ response.getStatus(),
+ "Expected to return status created from the response");
logger.info("Response Code: " + code + "\tEntity: " + response.getEntity());
}
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java b/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
index 0962d43..f196353 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/ModelDistributionTest.java
@@ -19,7 +19,7 @@
*/
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.net.URI;
import java.nio.file.Files;
@@ -27,7 +27,7 @@ import java.nio.file.Paths;
import java.util.Collections;
import org.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.rest.AbstractSpringRestTest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java
index b59b134..9b1f932 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverGenerateUrlTest.java
@@ -22,16 +22,16 @@ package org.onap.aai.rest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.jayway.jsonpath.JsonPath;
+import org.junit.jupiter.api.Test;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.Collections;
import java.util.UUID;
-import org.junit.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java
index e6a185e..dd1c9a4 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverMissingTest.java
@@ -22,7 +22,7 @@ package org.onap.aai.rest;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Base64;
import java.util.Collections;
@@ -30,7 +30,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.PayloadUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java
index f6917cf..80dfdab 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverRelationshipTest.java
@@ -24,14 +24,14 @@ import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.PayloadUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java
index f23abd2..daffddd 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverTest.java
@@ -20,13 +20,13 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-
import com.jayway.jsonpath.JsonPath;
+import org.junit.jupiter.api.Test;
import java.util.UUID;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java
index 4c93f58..5af17d0 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/PserverWrongHeaderTest.java
@@ -20,13 +20,13 @@
package org.onap.aai.rest;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
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 2f8c1b1..b04ba21 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
@@ -20,9 +20,9 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -41,9 +41,9 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
@@ -81,12 +81,12 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
private boolean initialized = false;
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
// AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
if (!initialized) {
initialized = true;
@@ -156,8 +156,8 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
MultivaluedMap<String, Object> responseHeaders = response.getMetadata();
- assertNotNull("Unable to retrieve the response headers from response object", responseHeaders);
- assertTrue("Response doesn't contain the key vertexId", responseHeaders.containsKey("vertex-id"));
+ assertNotNull(responseHeaders, "Unable to retrieve the response headers from response object");
+ assertTrue(responseHeaders.containsKey("vertex-id"), "Response doesn't contain the key vertexId");
String vertexId = responseHeaders.get("vertex-id").get(0).toString();
response = urlFromVertexIdConsumer.generateUrlFromVertexId("", schemaVersions.getDefaultVersion().toString(),
@@ -181,7 +181,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
urlFromVertexIdConsumer.generateUrlFromVertexId("", schemaVersions.getDefaultVersion().toString(),
Long.valueOf(vertexId).longValue(), httpHeaders, uriInfo, mockReqGet);
- assertNotNull("Check if the response is not null", response);
+ assertNotNull(response, "Check if the response is not null");
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
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 a6219e7..0f56348 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
@@ -20,9 +20,9 @@
package org.onap.aai.rest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
@@ -41,9 +41,9 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.json.JSONException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
@@ -81,12 +81,12 @@ public class VertexIdConsumerTest extends AAISetup {
private static final Logger logger = LoggerFactory.getLogger(LegacyMoxyConsumerTest.class.getName());
private boolean initialized = false;
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
// AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
if (!initialized) {
initialized = true;
@@ -157,8 +157,8 @@ public class VertexIdConsumerTest extends AAISetup {
MultivaluedMap<String, Object> responseHeaders = response.getMetadata();
- assertNotNull("Unable to retrieve the response headers from response object", responseHeaders);
- assertTrue("Response doesn't contain the key vertexId", responseHeaders.containsKey("vertex-id"));
+ assertNotNull(responseHeaders, "Unable to retrieve the response headers from response object");
+ assertTrue(responseHeaders.containsKey("vertex-id"), "Response doesn't contain the key vertexId");
String vertexId = responseHeaders.get("vertex-id").get(0).toString();
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 fb9f13f..6d652ab 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
@@ -21,15 +21,17 @@
package org.onap.aai.rest.bulk;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.when;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import java.io.IOException;
+import java.lang.reflect.Method;
import java.util.Iterator;
+import java.util.Optional;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.Response;
@@ -39,10 +41,9 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.json.JSONException;
import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.rest.BulkConsumer;
@@ -55,14 +56,18 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
private BulkSingleTransactionConsumer bulkSingleTransactionConsumer = new BulkSingleTransactionConsumer("/aai");
- @Rule
- public TestName name = new TestName();
+
+ public String name;
private String sot = "Junit";
- @Before
- public void before() {
- sot = "JUNIT-" + name.getMethodName();
+ @BeforeEach
+ public void before(TestInfo testInfo) {
+ Optional<Method> testMethod = testInfo.getTestMethod();
+ if (testMethod.isPresent()) {
+ this.name = testMethod.get().getName();
+ }
+ sot = "JUNIT-" + name;
when(uriInfo.getPath()).thenReturn(uri);
when(uriInfo.getPath(false)).thenReturn(uri);
headersMultiMap.addFirst("X-FromAppId", sot);
@@ -72,63 +77,66 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
@Test
public void addPserverPatchSamePserverTest() throws IOException {
- String payload = getBulkPayload("single-transaction/put-patch-same-pserver").replaceAll("<methodName>",
- name.getMethodName());
+ String payload = getBulkPayload("single-transaction/put-patch-same-pserver").replaceAll("<methodName>", name);
Response response = executeRequest(payload);
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("1 vertex from this test in graph", Long.valueOf(1L), AAIGraph.getInstance().getGraph()
- .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
- assertEquals("1 vertex from this test with fqdn = patched-fqdn", Long.valueOf(1L),
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
+ assertEquals(Long.valueOf(1L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "1 vertex from this test in graph");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
- .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("fqdn", "patched-fqdn").count().next());
+ .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("fqdn", "patched-fqdn").count().next(),
+ "1 vertex from this test with fqdn = patched-fqdn");
}
@Test
public void putPserverComplexRelBetween() throws IOException {
- String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between").replaceAll("<methodName>",
- name.getMethodName());
+ String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between").replaceAll("<methodName>", name);
Response response = executeRequest(payload);
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("2 vertex from this test in graph", Long.valueOf(2L), AAIGraph.getInstance().getGraph()
- .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
- assertEquals("1 complex vertex", Long.valueOf(1L),
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
+ assertEquals(Long.valueOf(2L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "2 vertex from this test in graph");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "complex").count()
- .next());
- assertEquals("1 pserver vertex", Long.valueOf(1L),
+ .next(),
+ "1 complex vertex");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "pserver").count()
- .next());
- assertEquals("pserver has edge to complex", Long.valueOf(1L),
+ .next(),
+ "1 pserver vertex");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "pserver").bothE()
.otherV().has(AAIProperties.NODE_TYPE, "complex").has(AAIProperties.SOURCE_OF_TRUTH, sot)
- .count().next());
+ .count().next(),
+ "pserver has edge to complex");
}
@Test
public void putPatchSamePserverPutAnotherPserver() throws IOException {
String payload = getBulkPayload("single-transaction/put-patch-same-pserver-put-another-pserver")
- .replaceAll("<methodName>", name.getMethodName());
+ .replaceAll("<methodName>", name);
Response response = executeRequest(payload);
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("2 vertex from this test in graph", Long.valueOf(2L), AAIGraph.getInstance().getGraph()
- .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
- assertEquals("pserver 1 has hostname pserver-1-" + name.getMethodName() + " fqdn = patched-fqdn",
- Long.valueOf(1L),
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
+ assertEquals(Long.valueOf(2L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "2 vertex from this test in graph");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
- .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("hostname", "pserver-1-" + name.getMethodName())
- .has("fqdn", "patched-fqdn").count().next());
- assertEquals("pserver 2 has hostname pserver-2-" + name.getMethodName(), Long.valueOf(1L),
+ .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("hostname", "pserver-1-" + name)
+ .has("fqdn", "patched-fqdn").count().next(),
+ "pserver 1 has hostname pserver-1-" + name + " fqdn = patched-fqdn");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
- .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("hostname", "pserver-2-" + name.getMethodName())
- .count().next());
+ .has(AAIProperties.SOURCE_OF_TRUTH, sot).has("hostname", "pserver-2-" + name)
+ .count().next(),
+ "pserver 2 has hostname pserver-2-" + name);
}
protected String asString(Vertex v) {
@@ -154,39 +162,44 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
.property(AAIProperties.SOURCE_OF_TRUTH, sot)
.property(AAIProperties.AAI_URI,
"/network/generic-vnfs/generic-vnf/gvnf-putPserverComplexRelBetweenDelExistingGvnf")
- .property(AAIProperties.RESOURCE_VERSION, "0").property("vnf-id", "gvnf-" + name.getMethodName())
+ .property(AAIProperties.RESOURCE_VERSION, "0").property("vnf-id", "gvnf-" + name)
.next();
AAIGraph.getInstance().getGraph().tx().commit();
- assertEquals("1 generic-vnf vertex exists before payload", Long.valueOf(1L),
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "generic-vnf").count()
- .next());
+ .next(),
+ "1 generic-vnf vertex exists before payload");
String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between-del-existing-gvnf")
- .replaceAll("<methodName>", name.getMethodName());
+ .replaceAll("<methodName>", name);
Response response = executeRequest(payload);
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
- assertEquals("2 vertex from this test in graph", Long.valueOf(2L), AAIGraph.getInstance().getGraph()
- .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
- assertEquals("1 complex vertex", Long.valueOf(1L),
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
+ assertEquals(Long.valueOf(2L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "2 vertex from this test in graph");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "complex").count()
- .next());
- assertEquals("1 pserver vertex", Long.valueOf(1L),
+ .next(),
+ "1 complex vertex");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "pserver").count()
- .next());
- assertEquals("pserver has edge to complex", Long.valueOf(1L),
+ .next(),
+ "1 pserver vertex");
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "pserver").bothE()
.otherV().has(AAIProperties.NODE_TYPE, "complex").has(AAIProperties.SOURCE_OF_TRUTH, sot)
- .count().next());
- assertEquals("0 generic-vnf vertex exists after payload", Long.valueOf(0L),
+ .count().next(),
+ "pserver has edge to complex");
+ assertEquals(Long.valueOf(0L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "generic-vnf").count()
- .next());
+ .next(),
+ "0 generic-vnf vertex exists after payload");
assertThat("Response contains 204 status.", response.getEntity().toString(),
containsString("\"response-status-code\":204"));
@@ -200,25 +213,26 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
.property(AAIProperties.SOURCE_OF_TRUTH, sot)
.property(AAIProperties.AAI_URI,
"/network/generic-vnfs/generic-vnf/gvnf-putPserverComplexRelBetweenDelExistingGvnfFail")
- .property(AAIProperties.RESOURCE_VERSION, "0").property("vnf-id", "gvnf-" + name.getMethodName())
+ .property(AAIProperties.RESOURCE_VERSION, "0").property("vnf-id", "gvnf-" + name)
.next();
AAIGraph.getInstance().getGraph().tx().commit();
- assertEquals("1 generic-vnf vertex exists before payload", Long.valueOf(1L),
+ assertEquals(Long.valueOf(1L),
AAIGraph.getInstance().getGraph().newTransaction().traversal().V()
.has(AAIProperties.SOURCE_OF_TRUTH, sot).has(AAIProperties.NODE_TYPE, "generic-vnf").count()
- .next());
+ .next(),
+ "1 generic-vnf vertex exists before payload");
String payload = getBulkPayload("single-transaction/put-pserver-complex-rel-between-del-existing-gvnf-fail")
- .replaceAll("<methodName>", name.getMethodName());
+ .replaceAll("<methodName>", name);
Response response = executeRequest(payload);
System.out.println(response.getEntity().toString());
- assertEquals("Request failed", Response.Status.PRECONDITION_FAILED.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.PRECONDITION_FAILED.getStatusCode(), response.getStatus(), "Request failed");
- assertEquals("1 vertex exists after payload due to failure", Long.valueOf(1L), AAIGraph.getInstance().getGraph()
- .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next());
+ assertEquals(Long.valueOf(1L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "1 vertex exists after payload due to failure");
assertThat("Response contains resource version msg for failed transaction.", response.getEntity().toString(),
containsString("Precondition Failed:resource-version MISMATCH for delete of generic-vnf"));
@@ -237,7 +251,7 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
String payload = getBulkPayload("single-transaction/pserver-bulk-limit-exceed");
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains payload limit msg.", response.getEntity().toString(),
containsString("Payload Limit Reached, reduce payload: Allowed limit = "));
}
@@ -248,7 +262,7 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
String payload = "{]}";// malformed json
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains invalid payload msg.", response.getEntity().toString(), containsString(
"JSON processing error:Input payload does not follow bulk/single-transaction interface"));
}
@@ -259,7 +273,7 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
String payload = "{'operations':[]}";
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains invalid payload msg.", response.getEntity().toString(),
containsString("Required Field not passed.: Payload has no objects to operate on"));
}
@@ -270,7 +284,7 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
String payload = getBulkPayload("single-transaction/invalid-action");
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains invalid payload msg.", response.getEntity().toString(),
containsString("JSON processing error:input payload missing required properties"));
assertThat("Response contains invalid payload details.", response.getEntity().toString(),
@@ -284,7 +298,7 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
String payload = getBulkPayload("single-transaction/missing-fields");
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains invalid payload msg.", response.getEntity().toString(),
containsString("JSON processing error:input payload missing required properties"));
assertThat("Response contains invalid payload details.", response.getEntity().toString(), containsString(
@@ -296,13 +310,13 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
public void putComplexWithRelToNonExistentPserverBetween() throws IOException {
String payload = getBulkPayload("single-transaction/put-complex-with-rel-to-non-existent")
- .replaceAll("<methodName>", name.getMethodName());
+ .replaceAll("<methodName>", name);
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());
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus(), "Request success");
+ assertEquals(Long.valueOf(0L), AAIGraph.getInstance().getGraph()
+ .newTransaction().traversal().V().has(AAIProperties.SOURCE_OF_TRUTH, sot).count().next(), "0 vertex from this test in graph");
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus(), "Request fails with 404");
assertThat("Response contains correct index of failed operation.", response.getEntity().toString(),
containsString("Operation 0"));
@@ -323,17 +337,17 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
JsonArray requests =
JsonParser
.parseString(getBulkPayload("single-transaction/delete-child-recreate-child")
- .replaceAll("<methodName>", name.getMethodName()))
+ .replaceAll("<methodName>", name))
.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());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
payload = requests.get(1).toString();
response = executeRequest(payload);
System.out.println(response.getEntity().toString());
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
}
@Test
@@ -341,26 +355,26 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
JsonArray requests =
JsonParser
.parseString(getBulkPayload("single-transaction/delete-node-recreate-node")
- .replaceAll("<methodName>", name.getMethodName()))
+ .replaceAll("<methodName>", name))
.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());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
payload = requests.get(1).toString();
response = executeRequest(payload);
System.out.println(response.getEntity().toString());
- assertEquals("Request success", Response.Status.CREATED.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), "Request success");
}
@Test
public void invalidNodeCreationPaylodTest() throws IOException {
String payload = getBulkPayload("single-transaction/put-complex-with-missing-properties")
- .replaceAll("<methodName>", name.getMethodName());
+ .replaceAll("<methodName>", name);
Response response = executeRequest(payload);
- assertEquals("Request fails with 400", Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus(), "Request fails with 400");
assertThat("Response contains correct index of failed operation.", response.getEntity().toString(),
containsString("Error with operation 0"));
assertThat("Response contains information about missing properties.", response.getEntity().toString(),
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 d729266..bd21dd2 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
@@ -20,12 +20,12 @@
package org.onap.aai.rest.retired;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.rest.AbstractSpringRestTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 3662ebe..f754449 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
@@ -20,8 +20,8 @@
package org.onap.aai.rest.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -40,8 +40,8 @@ import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
import org.onap.aai.tasks.AaiGraphChecker;
@@ -68,7 +68,7 @@ public class EchoResponseTest extends AAISetup {
this.echoResponse = new EchoResponse(aaiGraphCheckerMock);
}
- @Before
+ @BeforeEach
public void setup() {
logger.info("Starting the setup for the integration tests of Rest Endpoints");
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
index ad3f9c2..b00ae59 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/LogFormatToolsTest.java
@@ -20,9 +20,9 @@
package org.onap.aai.rest.util;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class LogFormatToolsTest {
diff --git a/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java b/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
index 442c0fc..4c2a0c9 100644
--- a/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/rest/util/ValidateEncodingTest.java
@@ -20,7 +20,7 @@
package org.onap.aai.rest.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.UnsupportedEncodingException;
@@ -28,7 +28,7 @@ import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
public class ValidateEncodingTest {
diff --git a/aai-resources/src/test/java/org/onap/aai/task/AaiGraphCheckerTest.java b/aai-resources/src/test/java/org/onap/aai/task/AaiGraphCheckerTest.java
index 11a5134..a4e8330 100644
--- a/aai-resources/src/test/java/org/onap/aai/task/AaiGraphCheckerTest.java
+++ b/aai-resources/src/test/java/org/onap/aai/task/AaiGraphCheckerTest.java
@@ -18,11 +18,11 @@
package org.onap.aai.task;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.tasks.AaiGraphChecker;
import org.springframework.beans.factory.annotation.Autowired;