Replace deprecated methods in model-loader 67/132267/1 master
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 16 Nov 2022 15:03:38 +0000 (15:03 +0000)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Wed, 16 Nov 2022 15:03:38 +0000 (15:03 +0000)
- junit's assertThat was deprecated in favour of hamcrest
- apache-commons now requires a Charset argument

Issue-ID: AAI-3604

Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: I10bf46922e44b3a3adcc14eab6486401a5cf14e1

23 files changed:
src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java
src/main/java/org/onap/aai/modelloader/extraction/VnfCatalogExtractor.java
src/test/java/org/onap/aai/modelloader/csar/extractor/VnfCatalogExtractorTest.java
src/test/java/org/onap/aai/modelloader/entity/catalog/TestVnfCatalogArtifactHandler.java
src/test/java/org/onap/aai/modelloader/entity/catalog/TestVnfImageException.java
src/test/java/org/onap/aai/modelloader/entity/model/ModelSorterTest.java
src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactHandler.java
src/test/java/org/onap/aai/modelloader/entity/model/TestModelArtifactParser.java
src/test/java/org/onap/aai/modelloader/entity/model/TestNamedQueryArtifactParser.java
src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
src/test/java/org/onap/aai/modelloader/notification/TestNotificationDataImpl.java
src/test/java/org/onap/aai/modelloader/restclient/TestAaiRestClient.java
src/test/java/org/onap/aai/modelloader/restclient/TestAaiServiceClient.java
src/test/java/org/onap/aai/modelloader/restclient/TestBabelServiceClient.java
src/test/java/org/onap/aai/modelloader/service/TestArtifactInfoImpl.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderService.java
src/test/java/org/onap/aai/modelloader/service/TestModelLoaderServiceWithSdc.java
src/test/java/org/onap/aai/modelloader/util/ArtifactTestUtils.java
src/test/java/org/onap/aai/modelloader/util/TestGizmoTranslator.java
src/test/java/org/onap/aai/modelloader/util/TestJsonXmlConverter.java

index 77693bc..a49288d 100644 (file)
@@ -28,10 +28,10 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
+
 import org.apache.commons.lang3.StringUtils;
 import org.eclipse.jetty.util.security.Password;
 import org.onap.sdc.api.consumer.IConfiguration;
-import org.springframework.core.env.Environment;
 
 /**
  * Properties for the Model Loader
index 0e27d57..3dbdfcc 100644 (file)
 package org.onap.aai.modelloader.extraction;
 
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.regex.Pattern;
+
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
@@ -75,7 +77,7 @@ public class VnfCatalogExtractor {
                 ZipArchiveEntry entry = enumeration.nextElement();
                 if (fileShouldBeExtracted(entry)) {
                     vnfcFiles.add(new VnfCatalogArtifact(ArtifactType.VNF_CATALOG_XML,
-                            IOUtils.toString(zipFile.getInputStream(entry))));
+                            IOUtils.toString(zipFile.getInputStream(entry), Charset.defaultCharset())));
                 }
             }
         } catch (IOException e) {
index bd8c33f..043edc3 100644 (file)
 package org.onap.aai.modelloader.csar.extractor;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
+
 import org.junit.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.onap.aai.modelloader.entity.ArtifactType;
index cead699..d4a0020 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader.entity.catalog;
 
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -34,8 +34,10 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
index c8b14f7..88c1941 100644 (file)
@@ -22,7 +22,7 @@ package org.onap.aai.modelloader.entity.catalog;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.junit.Test;
 
index 8f4bf8d..86985d8 100644 (file)
@@ -24,13 +24,14 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.isEmptyString;
-import static org.junit.Assert.assertThat;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+
 import org.junit.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 
index 5ccd1d2..3418a6b 100644 (file)
 package org.onap.aai.modelloader.entity.model;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.isEmptyString;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+
 import javax.ws.rs.core.Response;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
index aef0acc..9b90aa2 100644 (file)
@@ -23,12 +23,13 @@ package org.onap.aai.modelloader.entity.model;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.text.IsEqualIgnoringCase.equalToIgnoringCase;
-import static org.junit.Assert.assertThat;
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.List;
+
 import org.junit.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 import org.springframework.util.CollectionUtils;
index 1d2d385..8eebd06 100644 (file)
 package org.onap.aai.modelloader.entity.model;
 
 import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.isEmptyString;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.List;
+
 import org.junit.Test;
 import org.onap.aai.modelloader.entity.Artifact;
 
index c0de0ee..3710d62 100644 (file)
@@ -21,8 +21,8 @@
 package org.onap.aai.modelloader.notification;
 
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.mock;
@@ -33,6 +33,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
index b50bd0d..a63710e 100644 (file)
@@ -21,7 +21,7 @@
 package org.onap.aai.modelloader.notification;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
@@ -33,6 +33,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
index f8b3de9..3d1cf15 100644 (file)
@@ -22,8 +22,8 @@ package org.onap.aai.modelloader.notification;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsEmptyCollection.empty;
-import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.Mockito.doNothing;
@@ -39,6 +39,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+
 import org.hamcrest.collection.IsEmptyCollection;
 import org.junit.After;
 import org.junit.Before;
@@ -109,7 +110,7 @@ public class TestArtifactDownloadManager {
                 catalogFiles), is(true));
         assertThat(modelFiles, is(empty()));
         assertThat(catalogFiles, is(empty()));
-        Mockito.verifyZeroInteractions(mockBabelClient, mockDistributionClient, mockNotificationPublisher,
+        Mockito.verifyNoInteractions(mockBabelClient, mockDistributionClient, mockNotificationPublisher,
                 mockBabelArtifactConverter);
     }
 
@@ -129,7 +130,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockNotificationPublisher).publishDownloadFailure(mockDistributionClient, data, artifact,
                 errorMessage);
 
-        Mockito.verifyZeroInteractions(mockBabelClient, mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelClient, mockBabelArtifactConverter);
     }
 
     @Test
@@ -147,7 +148,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifactInfo);
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
 
-        Mockito.verifyZeroInteractions(mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelArtifactConverter);
     }
 
     @Test
@@ -167,7 +168,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockBabelClient).postArtifact(any(), any(), any(), any());
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
 
-        Mockito.verifyZeroInteractions(mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelArtifactConverter);
 
     }
 
@@ -189,7 +190,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
 
-        Mockito.verifyZeroInteractions(mockBabelClient, mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelClient, mockBabelArtifactConverter);
     }
 
     @Test
@@ -246,7 +247,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
 
-        Mockito.verifyZeroInteractions(mockBabelClient, mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelClient, mockBabelArtifactConverter);
     }
 
     private void setupValidModelQuerySpecMocks(ArtifactTestUtils artifactTestUtils, INotificationData data,
@@ -332,7 +333,7 @@ public class TestArtifactDownloadManager {
         Mockito.verify(mockDistributionClient).download(artifact);
         Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
         Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
-        Mockito.verifyZeroInteractions(mockBabelClient, mockBabelArtifactConverter);
+        Mockito.verifyNoInteractions(mockBabelClient, mockBabelArtifactConverter);
     }
 
     private IDistributionClientDownloadResult createDistributionClientDownloadResult(
index 8276d90..8c4ffed 100644 (file)
@@ -28,6 +28,7 @@ import static org.mockito.Mockito.when;
 import java.io.IOException;
 import java.util.List;
 import java.util.Properties;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -96,7 +97,7 @@ public class TestEventCallback {
 
         verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class),
                 any(List.class), any(List.class));
-        Mockito.verifyZeroInteractions(mockArtifactDeploymentManager);
+        Mockito.verifyNoInteractions(mockArtifactDeploymentManager);
     }
 
     @SuppressWarnings("unchecked")
index c045910..d7441ec 100644 (file)
@@ -23,7 +23,7 @@ package org.onap.aai.modelloader.notification;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.junit.Test;
 
index 91aa182..ebdfcfe 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.aai.modelloader.restclient;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.io.File;
 import java.io.IOException;
@@ -30,9 +29,11 @@ import java.nio.file.Paths;
 import java.util.Properties;
 import java.util.stream.IntStream;
 import java.util.stream.Stream;
+
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.entity.ArtifactType;
 import org.onap.aai.modelloader.entity.model.ModelArtifact;
index 00bee09..c5da065 100644 (file)
@@ -25,11 +25,14 @@ import static org.apache.commons.io.IOUtils.write;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.util.Properties;
+
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.core.MediaType;
+
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
@@ -99,7 +102,7 @@ public class TestAaiServiceClient {
                     HttpServletResponse response) throws IOException, ServletException {
                 response.setStatus(SC_OK);
                 response.setContentType("text/json;charset=utf-8");
-                write("", response.getOutputStream());
+                write("", response.getOutputStream(), Charset.defaultCharset());
                 request.setHandled(true);
             }
         };
index 8da5f89..51c5642 100644 (file)
@@ -24,19 +24,21 @@ import static javax.servlet.http.HttpServletResponse.SC_OK;
 import static org.apache.commons.io.IOUtils.write;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
-import com.google.gson.Gson;
 import java.io.IOException;
 import java.net.URISyntaxException;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Server;
@@ -48,6 +50,8 @@ import org.onap.aai.babel.service.data.BabelArtifact;
 import org.onap.aai.modelloader.config.ModelLoaderConfig;
 import org.onap.aai.modelloader.service.HttpsBabelServiceClientFactory;
 
+import com.google.gson.Gson;
+
 /**
  * Local testing of the Babel service client.
  *
@@ -124,7 +128,7 @@ public class TestBabelServiceClient {
                     HttpServletResponse response) throws IOException, ServletException {
                 response.setStatus(SC_OK);
                 response.setContentType("text/xml;charset=utf-8");
-                write(responseBody, response.getOutputStream());
+                write(responseBody, response.getOutputStream(), Charset.defaultCharset());
                 request.setHandled(true);
             }
         };
index ec55f15..a791b46 100644 (file)
@@ -24,8 +24,8 @@ import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.empty;
-import static org.junit.Assert.assertThat;
 
 import org.junit.Test;
 
index f38cf77..1a55580 100644 (file)
 package org.onap.aai.modelloader.service;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.Base64;
+
 import javax.ws.rs.core.Response;
+
 import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
index d23b3ef..976acbc 100644 (file)
 package org.onap.aai.modelloader.service;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.IOException;
 import java.util.Base64;
+
 import javax.ws.rs.core.Response;
+
 import org.junit.After;
 import org.junit.Test;
 import org.junit.runner.RunWith;
index 50074f1..e5db2a5 100644 (file)
@@ -22,6 +22,8 @@ package org.onap.aai.modelloader.util;
 
 import java.io.IOException;
 import java.net.URL;
+import java.nio.charset.Charset;
+
 import org.apache.commons.io.IOUtils;
 import org.onap.aai.babel.service.data.BabelArtifact;
 
@@ -53,7 +55,7 @@ public class ArtifactTestUtils {
     }
 
     public static String loadResourceAsString(String resourceName) throws IOException {
-        return IOUtils.toString(getResource(resourceName));
+        return IOUtils.toString(getResource(resourceName), Charset.defaultCharset());
     }
 
     private static URL getResource(String resourceName) {
index 97d7a19..1746e05 100644 (file)
 package org.onap.aai.modelloader.util;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+
 import org.junit.Test;
 import org.onap.aai.modelloader.gizmo.GizmoBulkPayload;
 
index 81a4833..116e1e5 100644 (file)
 package org.onap.aai.modelloader.util;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.io.ByteArrayInputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;