Improve Test coverage of DFC
[nonrtric/plt/ranpm.git] / datafilecollector / src / test / java / org / oran / datafile / tasks / FileCollectorTest.java
index fa5d799..432e045 100644 (file)
@@ -49,9 +49,10 @@ import org.oran.datafile.model.Counters;
 import org.oran.datafile.model.FileData;
 import org.oran.datafile.model.FilePublishInformation;
 import org.oran.datafile.model.FileReadyMessage;
+import org.oran.datafile.oauth2.SecurityContext;
 import reactor.test.StepVerifier;
 
-public class FileCollectorTest {
+class FileCollectorTest {
 
     final static String DATAFILE_TMPDIR = "/tmp/onap_datafile/";
     private static final String PRODUCT_NAME = "NrRadio";
@@ -110,6 +111,8 @@ public class FileCollectorTest {
 
     private Counters counters;
 
+    static final SecurityContext securityContext = new SecurityContext("");
+
     FileReadyMessage.Event event(String location) {
         FileReadyMessage.MessageMetaData messageMetaData = FileReadyMessage.MessageMetaData.builder() //
             .lastEpochMicrosec(LAST_EPOCH_MICROSEC) //
@@ -187,8 +190,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenFtpesFile_returnCorrectResponse() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenFtpesFile_returnCorrectResponse() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
 
         FileData fileData = createFileData(FTPES_LOCATION_NO_PORT);
@@ -211,8 +214,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenSftpFile_returnCorrectResponse() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenSftpFile_returnCorrectResponse() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(sftpClientMock).when(collectorUndetTest).createSftpClient(any());
 
         FileData fileData = createFileData(SFTP_LOCATION_NO_PORT);
@@ -240,8 +243,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenHttpFile_returnCorrectResponse() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenHttpFile_returnCorrectResponse() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(dfcHttpClientMock).when(collectorUndetTest).createHttpClient(any());
 
         FileData fileData = createFileData(HTTP_LOCATION_NO_PORT);
@@ -272,8 +275,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenHttpsFile_returnCorrectResponse() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenHttpsFile_returnCorrectResponse() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(dfcHttpsClientMock).when(collectorUndetTest).createHttpsClient(any());
 
         FileData fileData = createFileData(HTTPS_LOCATION_NO_PORT);
@@ -304,8 +307,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenFtpesFileAlwaysFail_retryAndFail() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenFtpesFileAlwaysFail_retryAndFail() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
 
         FileData fileData = createFileData(FTPES_LOCATION);
@@ -324,8 +327,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenFtpesFileAlwaysFail_failWithoutRetry() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenFtpesFileAlwaysFail_failWithoutRetry() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
 
         FileData fileData = createFileData(FTPES_LOCATION);
@@ -344,8 +347,8 @@ public class FileCollectorTest {
     }
 
     @Test
-    public void whenFtpesFileFailOnce_retryAndReturnCorrectResponse() throws Exception {
-        FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
+    void whenFtpesFileFailOnce_retryAndReturnCorrectResponse() throws Exception {
+        FileCollector collectorUndetTest = spy(new FileCollector(securityContext, appConfigMock, counters));
         doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
         doThrow(new DatafileTaskException("Unable to collect file.")).doNothing().when(ftpesClientMock)
             .collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);