X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fmodel-loader.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Fnotification%2FTestEventCallback.java;h=8c4ffedfa7af9f25d065efec4e7db94f6b55d931;hp=8276d90b0a226960d6d1d9077e4e372d52794cee;hb=HEAD;hpb=50889fa7107127868a9a4391218772ff58d0ac2e 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 8276d90..b5d7fd3 100644 --- a/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java +++ b/src/test/java/org/onap/aai/modelloader/notification/TestEventCallback.java @@ -21,24 +21,24 @@ package org.onap.aai.modelloader.notification; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; 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.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.mockito.Mockito; -import org.onap.aai.modelloader.config.ModelLoaderConfig; +import org.mockito.MockitoAnnotations; 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}. @@ -47,36 +47,25 @@ public class TestEventCallback { private static final String CONFIG_FILE = "model-loader.properties"; - private ModelLoaderConfig config; private Properties configProperties; private EventCallback eventCallback; - private ArtifactDeploymentManager mockArtifactDeploymentManager; - private ArtifactDownloadManager mockArtifactDownloadManager; - private IDistributionClient mockDistributionClient; - private NotificationPublisher mockNotificationPublisher; + @Mock private ArtifactDeploymentManager mockArtifactDeploymentManager; + @Mock private ArtifactDownloadManager mockArtifactDownloadManager; + @Mock private IDistributionClient mockDistributionClient; + @Mock private NotificationPublisher mockNotificationPublisher; - @Before + @BeforeEach public void setup() throws IOException { + MockitoAnnotations.openMocks(this); configProperties = new Properties(); configProperties.load(this.getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)); - config = new ModelLoaderConfig(configProperties, null); - - mockArtifactDeploymentManager = mock(ArtifactDeploymentManager.class); - mockArtifactDownloadManager = mock(ArtifactDownloadManager.class); - mockDistributionClient = mock(IDistributionClient.class); - mockNotificationPublisher = mock(NotificationPublisher.class); - - eventCallback = new EventCallback(mockDistributionClient, config, null); - ReflectionTestUtils.setField(eventCallback, "artifactDeploymentManager", mockArtifactDeploymentManager); - ReflectionTestUtils.setField(eventCallback, "artifactDownloadManager", mockArtifactDownloadManager); - ReflectionTestUtils.setField(eventCallback, "notificationPublisher", mockNotificationPublisher); + eventCallback = new EventCallback(mockDistributionClient, mockArtifactDeploymentManager, mockArtifactDownloadManager, mockNotificationPublisher); } - @After + @AfterEach public void tearDown() { - config = null; configProperties = null; eventCallback = null; mockArtifactDeploymentManager = null; @@ -96,7 +85,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") @@ -107,13 +96,13 @@ public class TestEventCallback { when(mockArtifactDownloadManager.downloadArtifacts(any(INotificationData.class), any(List.class), any(List.class), any(List.class))).thenReturn(true); - when(mockArtifactDeploymentManager.deploy(any(INotificationData.class), any(List.class), any(List.class))) + when(mockArtifactDeploymentManager.deploy(any(String.class), any(List.class), any(List.class))) .thenReturn(true); eventCallback.activateCallback(data); verify(mockArtifactDownloadManager).downloadArtifacts(any(INotificationData.class), any(List.class), any(List.class), any(List.class)); - verify(mockArtifactDeploymentManager).deploy(any(INotificationData.class), any(List.class), any(List.class)); + verify(mockArtifactDeploymentManager).deploy(any(String.class), any(List.class), any(List.class)); } }