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";
private Counters counters;
+ static final SecurityContext securityContext = new SecurityContext("");
+
FileReadyMessage.Event event(String location) {
FileReadyMessage.MessageMetaData messageMetaData = FileReadyMessage.MessageMetaData.builder() //
.lastEpochMicrosec(LAST_EPOCH_MICROSEC) //
}
@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);
}
@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);
}
@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);
}
@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);
}
@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);
}
@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);
}
@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);