<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 -->
<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>
<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>
<version>${testcontainers.version}</version>
<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>
<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>
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;
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;
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,
@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/");
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;
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;
String[] args = {"-numberOfNodes", "5", "-nodeType", "pserver", "-uri", "/cloud-infrastructure/pservers/pserver/",
"-child", "false"};
- @Before
+ @BeforeEach
public void setup() {
increaseNodesTool = new IncreaseNodesTool(loaderFactory, schemaVersions);
}
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;
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());
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;
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());
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;
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;
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();
baseUrl = "http://localhost:" + randomPort;
}
- @After
+ @AfterEach
public void tearDown() {
JanusGraph janusGraph = AAIGraph.getInstance().getGraph();
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;
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;
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
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
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
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
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
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
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
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;
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;
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
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
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
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
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
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}");
}
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 = "{}";
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
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
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
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
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
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;
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;
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;
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;
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;
private HttpHeaders headersGet;
private HttpHeaders headersPutPatch;
- @Before
+ @BeforeEach
public void setup() throws UnsupportedEncodingException {
headersGet = new HttpHeaders();
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;
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;
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;
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");
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();
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();
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;
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;
@InjectMocks
private ExceptionHandler handler = new ExceptionHandler();
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.openMocks(this);
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;
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;
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;
private String defaultSchemaVersion;
- @BeforeClass
+ @BeforeAll
public static void setupRest() {
// AAIGraph.getInstance();
}
- @Before
+ @BeforeEach
public void setup() {
if (!initialized) {
initialized = true;
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);
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
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());
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,
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);
}
@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");
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);
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 = "{}";
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();
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);
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 =
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());
}
*/
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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(),
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());
}
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;
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;
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;
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();
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;
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;
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);
@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) {
.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"));
.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"));
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 = "));
}
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"));
}
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"));
}
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(),
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(
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"));
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
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(),
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;
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;
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;
this.echoResponse = new EchoResponse(aaiGraphCheckerMock);
}
- @Before
+ @BeforeEach
public void setup() {
logger.info("Starting the setup for the integration tests of Rest Endpoints");
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 {
package org.onap.aai.rest.util;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.UnsupportedEncodingException;
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 {
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;