summaryrefslogtreecommitdiffstats
path: root/aai-resources/src/test
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-14 16:09:54 +0000
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-11-14 16:24:40 +0000
commita05789019bfd36f36a175ce5970dc46b9f55594d (patch)
tree15e01ce1944560b2f63fca3369989107e6b749e5 /aai-resources/src/test
parenta0234adccf748953c4f884275a7bd6036236263c (diff)
Replace deprecated methods in resources
Issue-ID: AAI-3595 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I848bd78338f9a8b15576e11718abbf64a1980663
Diffstat (limited to 'aai-resources/src/test')
-rw-r--r--aai-resources/src/test/java/org/onap/aai/AAISetup.java9
-rw-r--r--aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/PayloadUtil.java7
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/BulkProcessorTestAbstraction.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExampleConsumerTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/ExceptionHandlerTest.java11
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/URLFromVertexIdConsumerTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/VertexIdConsumerTest.java4
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumerTest.java11
-rw-r--r--aai-resources/src/test/java/org/onap/aai/rest/util/EchoResponseTest.java4
11 files changed, 39 insertions, 27 deletions
diff --git a/aai-resources/src/test/java/org/onap/aai/AAISetup.java b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
index 8227d37..dc1e6c8 100644
--- a/aai-resources/src/test/java/org/onap/aai/AAISetup.java
+++ b/aai-resources/src/test/java/org/onap/aai/AAISetup.java
@@ -24,13 +24,18 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
+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.onap.aai.config.*;
+import org.onap.aai.config.ConfigConfiguration;
+import org.onap.aai.config.IntrospectionConfig;
+import org.onap.aai.config.RestBeanConfig;
+import org.onap.aai.config.SpringContextAware;
+import org.onap.aai.config.XmlFormatTransformerConfiguration;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.MoxyLoader;
@@ -92,7 +97,7 @@ public abstract class AAISetup {
String message = String.format("Unable to find the %s in src/test/resources", filename);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
+ String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
return resource;
}
}
diff --git a/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
index 9235109..676da71 100644
--- a/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
+++ b/aai-resources/src/test/java/org/onap/aai/HttpTestUtil.java
@@ -20,7 +20,7 @@
package org.onap.aai;
-import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
@@ -102,7 +102,7 @@ public class HttpTestUtil extends RESTAPI {
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
- doReturn(null).when(queryParameters).remove(anyObject());
+ doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
schemaVersions = SpringContextAware.getBean(SchemaVersions.class);
}
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 3197c69..eb1c52c 100644
--- a/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java
+++ b/aai-resources/src/test/java/org/onap/aai/PayloadUtil.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
@@ -44,7 +45,7 @@ public class PayloadUtil {
String message = String.format("Unable to find the %s in src/test/resources", fileName);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
+ String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
inputStream.close();
return resource;
@@ -63,7 +64,7 @@ public class PayloadUtil {
if (cache.containsKey(fileName)) {
resource = cache.get(fileName);
} else {
- resource = IOUtils.toString(inputStream);
+ resource = IOUtils.toString(inputStream, Charset.defaultCharset());
cache.put(fileName, resource);
}
@@ -95,7 +96,7 @@ public class PayloadUtil {
String message = String.format("Unable to find the %s in src/test/resources/payloads/", fileName);
assertNotNull(message, inputStream);
- String resource = IOUtils.toString(inputStream);
+ String resource = IOUtils.toString(inputStream, Charset.defaultCharset());
inputStream.close();
return resource;
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 56ab500..e4a9d71 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
@@ -20,7 +20,7 @@
package org.onap.aai.rest;
-import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -119,7 +119,7 @@ public abstract class BulkProcessorTestAbstraction extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
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 1b2e98d..0039303 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
@@ -22,7 +22,7 @@ package org.onap.aai.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
@@ -112,7 +112,7 @@ public class ExampleConsumerTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
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 8a6f469..fab07fc 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
@@ -26,9 +26,10 @@ import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonLocation;
import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.core.JsonParser;
import com.sun.istack.SAXParseException2;
import java.util.ArrayList;
@@ -106,8 +107,8 @@ public class ExceptionHandlerTest extends AAISetup {
@Test
public void testConversionWhenJsonParseExceptionResultBadRequest() throws Exception {
- JsonLocation jsonLocation = mock(JsonLocation.class);
- Exception exception = new JsonParseException("", jsonLocation);
+ JsonParser parser = new JsonFactory().createParser("");
+ Exception exception = new JsonParseException(parser, "");
Response response = handler.toResponse(exception);
assertNotNull(response);
@@ -119,7 +120,9 @@ public class ExceptionHandlerTest extends AAISetup {
public void testConversionWhenJsonMappingExceptionResultBadRequest() throws Exception {
JsonLocation jsonLocation = mock(JsonLocation.class);
- Exception exception = new JsonMappingException("", jsonLocation);
+ // Exception exception = new JsonMappingException("", jsonLocation);
+ JsonParser parser = new JsonFactory().createParser("");
+ Exception exception = new JsonParseException(parser, "");
Response response = handler.toResponse(exception);
assertNotNull(response);
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 4285af8..7c0161f 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
@@ -24,7 +24,7 @@ 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.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -131,7 +131,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
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 5abe263..2f8c1b1 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
@@ -23,7 +23,7 @@ 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.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -124,7 +124,7 @@ public class URLFromVertexIdConsumerTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
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 52a5701..a6219e7 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
@@ -23,7 +23,7 @@ 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.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -124,7 +124,7 @@ public class VertexIdConsumerTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON);
}
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 eaa71a9..7629178 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
@@ -321,8 +321,8 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
@Test
public void deleteChildRecreateChildTest() throws IOException {
JsonArray requests =
- new JsonParser()
- .parse(getBulkPayload("single-transaction/delete-child-recreate-child")
+ JsonParser
+ .parseString(getBulkPayload("single-transaction/delete-child-recreate-child")
.replaceAll("<methodName>", name.getMethodName()))
.getAsJsonObject().getAsJsonArray("array");
String payload = requests.get(0).toString();
@@ -338,8 +338,11 @@ public class BulkSingleTransactionConsumerTest extends BulkProcessorTestAbstract
@Test
public void deleteNodeRecreateNodeTest() throws IOException {
- JsonArray requests = new JsonParser().parse(getBulkPayload("single-transaction/delete-node-recreate-node")
- .replaceAll("<methodName>", name.getMethodName())).getAsJsonObject().getAsJsonArray("array");
+ JsonArray requests =
+ JsonParser
+ .parseString(getBulkPayload("single-transaction/delete-node-recreate-node")
+ .replaceAll("<methodName>", name.getMethodName()))
+ .getAsJsonObject().getAsJsonArray("array");
String payload = requests.get(0).toString();
Response response = executeRequest(payload);
System.out.println(response.getEntity().toString());
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 21324e9..3662ebe 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
@@ -22,7 +22,7 @@ package org.onap.aai.rest.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
@@ -100,7 +100,7 @@ public class EchoResponseTest extends AAISetup {
when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters);
// TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable
- Mockito.doReturn(null).when(queryParameters).remove(anyObject());
+ Mockito.doReturn(null).when(queryParameters).remove(any());
}