summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee, Tian (tl5884) <tianl@amdocs.com>2019-08-07 16:53:09 +0100
committerLee, Tian (tl5884) <tianl@amdocs.com>2019-08-07 16:53:09 +0100
commit378fac344f2de5a89b5410b9031e76841cd8fba6 (patch)
treebd017e875597729ad2fa93e658f800a63e03f859
parent3481baf3e358ec242c775b400b98a1e1a5f6e1ce (diff)
Upversion Spring Boot to 2.1.6
Change-Id: I0e8b3f738777ab106d13fa826f0b40e3392a0f6b Issue-ID: AAI-2539 Signed-off-by: Lee, Tian (tl5884) <tianl@amdocs.com>
-rw-r--r--pom.xml2
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java38
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java10
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java47
-rw-r--r--src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java11
5 files changed, 46 insertions, 62 deletions
diff --git a/pom.xml b/pom.xml
index d07d10f..25b4d67 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
<start-class>org.onap.aai.modelloader.service.ModelLoaderApplication</start-class>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<docker.location>${basedir}/target</docker.location>
- <spring-boot.version>1.5.20.RELEASE</spring-boot.version>
+ <spring-boot.version>2.1.6.RELEASE</spring-boot.version>
<apache.commons-text.version>1.1</apache.commons-text.version>
<commons-compress.version>1.18</commons-compress.version>
<hamcrest-all.version>1.3</hamcrest-all.version>
diff --git a/src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java b/src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
index 6c7a77f..c0de0ee 100644
--- a/src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
+++ b/src/test/java/org/onap/aai/modelloader/notification/ArtifactDownloadManagerVnfcTest.java
@@ -23,6 +23,7 @@ package org.onap.aai.modelloader.notification;
import static org.hamcrest.CoreMatchers.is;
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;
import static org.mockito.Mockito.when;
@@ -34,9 +35,7 @@ import java.util.List;
import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
@@ -56,6 +55,7 @@ import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Tests {@link ArtifactDownloadManager} with VNF Catalog Artifacts.
@@ -86,9 +86,9 @@ public class ArtifactDownloadManagerVnfcTest {
new ModelLoaderConfig(configProperties, "."), mockClientFactory);
- Whitebox.setInternalState(downloadManager, "notificationPublisher", mockNotificationPublisher);
- Whitebox.setInternalState(downloadManager, "babelArtifactConverter", mockBabelArtifactConverter);
- Whitebox.setInternalState(downloadManager, "vnfCatalogExtractor", mockVnfCatalogExtractor);
+ ReflectionTestUtils.setField(downloadManager, "notificationPublisher", mockNotificationPublisher);
+ ReflectionTestUtils.setField(downloadManager, "babelArtifactConverter", mockBabelArtifactConverter);
+ ReflectionTestUtils.setField(downloadManager, "vnfCatalogExtractor", mockVnfCatalogExtractor);
}
@Test
@@ -98,9 +98,8 @@ public class ArtifactDownloadManagerVnfcTest {
IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
setupValidDownloadCsarMocks(data, artifactInfo);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifacts());
- when(mockVnfCatalogExtractor.extract(Matchers.any(), Matchers.anyString())).thenReturn(new ArrayList<>());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifacts());
+ when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(new ArrayList<>());
List<Artifact> modelArtifacts = new ArrayList<>();
List<Artifact> catalogFiles = new ArrayList<>();
@@ -117,10 +116,8 @@ public class ArtifactDownloadManagerVnfcTest {
IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
setupValidDownloadCsarMocks(data, artifactInfo);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifactsNoVnfc());
- when(mockVnfCatalogExtractor.extract(Matchers.any(), Matchers.anyString()))
- .thenReturn(createXmlVnfcArtifacts());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifactsNoVnfc());
+ when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(createXmlVnfcArtifacts());
List<Artifact> modelArtifacts = new ArrayList<>();
List<Artifact> catalogFiles = new ArrayList<>();
@@ -137,9 +134,8 @@ public class ArtifactDownloadManagerVnfcTest {
IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
setupValidDownloadCsarMocks(data, artifactInfo);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifactsNoVnfc());
- when(mockVnfCatalogExtractor.extract(Matchers.any(), Matchers.anyString())).thenReturn(new ArrayList<>());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifactsNoVnfc());
+ when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(new ArrayList<>());
List<Artifact> modelArtifacts = new ArrayList<>();
List<Artifact> catalogFiles = new ArrayList<>();
@@ -156,10 +152,8 @@ public class ArtifactDownloadManagerVnfcTest {
IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
setupValidDownloadCsarMocks(data, artifactInfo);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifacts());
- when(mockVnfCatalogExtractor.extract(Matchers.any(), Matchers.anyString()))
- .thenReturn(createXmlVnfcArtifacts());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifacts());
+ when(mockVnfCatalogExtractor.extract(any(), any())).thenReturn(createXmlVnfcArtifacts());
doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
List<Artifact> modelArtifacts = new ArrayList<>();
@@ -184,10 +178,8 @@ public class ArtifactDownloadManagerVnfcTest {
when(mockDistributionClient.download(artifactInfo))
.thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
new ArtifactTestUtils().loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
- when(mockBabelArtifactConverter.convertToModel(Mockito.anyListOf(BabelArtifact.class)))
- .thenReturn(createModelArtifacts());
- when(mockBabelArtifactConverter.convertToCatalog(Mockito.anyListOf(BabelArtifact.class)))
- .thenReturn(createToscaVnfcArtifacts());
+ when(mockBabelArtifactConverter.convertToModel(Mockito.anyList())).thenReturn(createModelArtifacts());
+ when(mockBabelArtifactConverter.convertToCatalog(Mockito.anyList())).thenReturn(createToscaVnfcArtifacts());
}
private List<BabelArtifact> createBabelArtifacts() {
diff --git a/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java b/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
index d8cb19a..b50bd0d 100644
--- a/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
+++ b/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDeploymentManager.java
@@ -22,8 +22,8 @@ package org.onap.aai.modelloader.notification;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder.getNotificationDataWithCatalogFile;
@@ -37,7 +37,6 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
@@ -50,6 +49,7 @@ import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
import org.onap.aai.modelloader.util.ArtifactTestUtils;
import org.onap.sdc.api.notification.INotificationData;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Tests {@link ArtifactDeploymentManager}.
@@ -75,8 +75,8 @@ public class TestArtifactDeploymentManager {
manager = new ArtifactDeploymentManager(new ModelLoaderConfig(configProperties, null));
- Whitebox.setInternalState(manager, "modelArtifactHandler", mockModelArtifactHandler);
- Whitebox.setInternalState(manager, "vnfCatalogArtifactHandler", mockVnfCatalogArtifactHandler);
+ ReflectionTestUtils.setField(manager, "modelArtifactHandler", mockModelArtifactHandler);
+ ReflectionTestUtils.setField(manager, "vnfCatalogArtifactHandler", mockVnfCatalogArtifactHandler);
}
@After
diff --git a/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java b/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
index 030a0ff..f8b3de9 100644
--- a/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
+++ b/src/test/java/org/onap/aai/modelloader/notification/TestArtifactDownloadManager.java
@@ -24,6 +24,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
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;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -41,9 +43,7 @@ import org.hamcrest.collection.IsEmptyCollection;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
import org.onap.aai.babel.service.data.BabelArtifact;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.Artifact;
@@ -59,6 +59,7 @@ import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.impl.DistributionClientDownloadResultImpl;
import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Tests {@link ArtifactDownloadManager}.
@@ -79,15 +80,15 @@ public class TestArtifactDownloadManager {
mockNotificationPublisher = mock(NotificationPublisher.class);
mockBabelArtifactConverter = mock(BabelArtifactConverter.class);
mockClientFactory = mock(HttpsBabelServiceClientFactory.class);
- when(mockClientFactory.create(Mockito.any())).thenReturn(mockBabelClient);
+ when(mockClientFactory.create(any())).thenReturn(mockBabelClient);
Properties configProperties = new Properties();
configProperties.load(this.getClass().getClassLoader().getResourceAsStream("model-loader.properties"));
downloadManager = new ArtifactDownloadManager(mockDistributionClient,
new ModelLoaderConfig(configProperties, "."), mockClientFactory);
- Whitebox.setInternalState(downloadManager, "notificationPublisher", mockNotificationPublisher);
- Whitebox.setInternalState(downloadManager, "babelArtifactConverter", mockBabelArtifactConverter);
+ ReflectionTestUtils.setField(downloadManager, "notificationPublisher", mockNotificationPublisher);
+ ReflectionTestUtils.setField(downloadManager, "babelArtifactConverter", mockBabelArtifactConverter);
}
@After
@@ -133,7 +134,7 @@ public class TestArtifactDownloadManager {
@Test
public void testErrorCreatingBabelClient() throws Exception {
- when(mockClientFactory.create(Mockito.any())).thenThrow(new BabelServiceClientException(new Exception()));
+ when(mockClientFactory.create(any())).thenThrow(new BabelServiceClientException(new Exception()));
INotificationData data = getNotificationDataWithToscaCsarFile();
IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0);
@@ -156,16 +157,14 @@ public class TestArtifactDownloadManager {
when(mockDistributionClient.download(artifact)).thenReturn(createDistributionClientDownloadResult(
DistributionActionResultEnum.SUCCESS, null, "This is not a valid Tosca CSAR File".getBytes()));
doNothing().when(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenThrow(new BabelServiceClientException(""));
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenThrow(new BabelServiceClientException(""));
doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
assertThat(downloadManager.downloadArtifacts(data, data.getServiceArtifacts(), null, null), is(false));
Mockito.verify(mockDistributionClient).download(artifact);
Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifact);
- Mockito.verify(mockBabelClient).postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString());
+ Mockito.verify(mockBabelClient).postArtifact(any(), any(), any(), any());
Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifact);
Mockito.verifyZeroInteractions(mockBabelArtifactConverter);
@@ -209,10 +208,9 @@ public class TestArtifactDownloadManager {
Mockito.verify(mockDistributionClient).download(artifactInfo);
Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, artifactInfo);
- Mockito.verify(mockBabelClient).postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString());
- Mockito.verify(mockBabelArtifactConverter).convertToModel(Matchers.any());
- Mockito.verify(mockBabelArtifactConverter).convertToCatalog(Matchers.any());
+ Mockito.verify(mockBabelClient).postArtifact(any(), any(), any(), any());
+ Mockito.verify(mockBabelArtifactConverter).convertToModel(any());
+ Mockito.verify(mockBabelArtifactConverter).convertToCatalog(any());
}
private void setupValidDownloadCsarMocks(INotificationData data, IArtifactInfo artifactInfo,
@@ -220,8 +218,7 @@ public class TestArtifactDownloadManager {
when(mockDistributionClient.download(artifactInfo))
.thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
artifactTestUtils.loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifacts());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifacts());
}
private List<BabelArtifact> createBabelArtifacts() {
@@ -282,10 +279,9 @@ public class TestArtifactDownloadManager {
Mockito.verify(mockDistributionClient).download(serviceArtifact);
Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data, serviceArtifact);
- Mockito.verify(mockBabelClient).postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString());
- Mockito.verify(mockBabelArtifactConverter).convertToModel(Matchers.any());
- Mockito.verify(mockBabelArtifactConverter).convertToCatalog(Matchers.any());
+ Mockito.verify(mockBabelClient).postArtifact(any(), any(), any(), any());
+ Mockito.verify(mockBabelArtifactConverter).convertToModel(any());
+ Mockito.verify(mockBabelArtifactConverter).convertToCatalog(any());
Mockito.verify(mockDistributionClient).download(modelSpecArtifact);
Mockito.verify(mockNotificationPublisher).publishDownloadSuccess(mockDistributionClient, data,
@@ -295,7 +291,6 @@ public class TestArtifactDownloadManager {
}
@Test
- @SuppressWarnings("unchecked")
public void activateCallback_toscaToModelConverterHasProcessToscaArtifactsException() throws Exception {
ArtifactTestUtils artifactTestUtils = new ArtifactTestUtils();
INotificationData data = getNotificationDataWithToscaCsarFile();
@@ -304,11 +299,10 @@ public class TestArtifactDownloadManager {
when(mockDistributionClient.download(artifactInfo))
.thenReturn(createDistributionClientDownloadResult(DistributionActionResultEnum.SUCCESS, null,
artifactTestUtils.loadResource("compressedArtifacts/service-VscpaasTest-csar.csar")));
- when(mockBabelArtifactConverter.convertToModel(Mockito.anyList()))
+ when(mockBabelArtifactConverter.convertToModel(anyList()))
.thenThrow(BabelArtifactParsingException.class);
doNothing().when(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
- when(mockBabelClient.postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString())).thenReturn(createBabelArtifacts());
+ when(mockBabelClient.postArtifact(any(), any(), any(), any())).thenReturn(createBabelArtifacts());
List<Artifact> modelArtifacts = new ArrayList<>();
List<Artifact> catalogFiles = new ArrayList<>();
@@ -319,9 +313,8 @@ public class TestArtifactDownloadManager {
Mockito.verify(mockDistributionClient).download(artifactInfo);
Mockito.verify(mockNotificationPublisher).publishDeployFailure(mockDistributionClient, data, artifactInfo);
- Mockito.verify(mockBabelClient).postArtifact(Matchers.any(), Matchers.anyString(), Matchers.anyString(),
- Matchers.anyString());
- Mockito.verify(mockBabelArtifactConverter).convertToModel(Matchers.any());
+ Mockito.verify(mockBabelClient).postArtifact(any(), any(), any(), any());
+ Mockito.verify(mockBabelArtifactConverter).convertToModel(any());
}
@Test
diff --git a/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java b/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
index eb326fd..8276d90 100644
--- a/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
+++ b/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java
@@ -20,7 +20,7 @@
*/
package org.onap.aai.modelloader.notification;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -28,18 +28,17 @@ 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;
import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
import org.onap.aai.modelloader.service.ArtifactDeploymentManager;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.notification.INotificationData;
+import org.springframework.test.util.ReflectionTestUtils;
/**
* Tests {@link EventCallback}.
@@ -70,9 +69,9 @@ public class TestEventCallback {
eventCallback = new EventCallback(mockDistributionClient, config, null);
- Whitebox.setInternalState(eventCallback, "artifactDeploymentManager", mockArtifactDeploymentManager);
- Whitebox.setInternalState(eventCallback, "artifactDownloadManager", mockArtifactDownloadManager);
- Whitebox.setInternalState(eventCallback, "notificationPublisher", mockNotificationPublisher);
+ ReflectionTestUtils.setField(eventCallback, "artifactDeploymentManager", mockArtifactDeploymentManager);
+ ReflectionTestUtils.setField(eventCallback, "artifactDownloadManager", mockArtifactDownloadManager);
+ ReflectionTestUtils.setField(eventCallback, "notificationPublisher", mockNotificationPublisher);
}
@After