From b47ed92edbf3b4f50b814a4b1912b5ef6185c294 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Tue, 9 Oct 2018 16:28:29 +0200 Subject: Fix retry when file download fails When the Datafile collector is unable to download the file from an xNF it now retries to collect the file. Change-Id: I61f68f9cf7af1a7fab160b0e936daafd1a23aaf8 Issue-ID: DCAEGEN2-864 Signed-off-by: elinuxhenrik --- .../collectors/datafile/ftp/FtpsClientTest.java | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'datafile-dmaap-client/src/test') diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java index 5d716a9b..e9e00c38 100644 --- a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java +++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java @@ -106,9 +106,9 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); - assertTrue(result); + assertTrue(result.downloadSuccessful()); verify(ftpsClientMock).setNeedClientAuth(true); verify(keyManagerUtilsMock).setCredentials(FTP_KEY_PATH, FTP_KEY_PASSWORD); verify(ftpsClientMock).setKeyManager(keyManagerMock); @@ -140,9 +140,9 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); - assertFalse(result); + assertFalse(result.downloadSuccessful()); } @Test @@ -156,9 +156,9 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); - assertFalse(result); + assertFalse(result.downloadSuccessful()); } @Test @@ -172,10 +172,10 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); verify(ftpsClientMock, times(1)).logout(); - assertFalse(result); + assertFalse(result.downloadSuccessful()); } @Test @@ -190,10 +190,10 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); verify(ftpsClientMock, times(1)).disconnect(); - assertFalse(result); + assertFalse(result.downloadSuccessful()); } @Test @@ -208,9 +208,9 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); - assertFalse(result); + assertFalse(result.downloadSuccessful()); } @Test @@ -227,8 +227,9 @@ public class FtpsClientTest { ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS) .userId(USERNAME).password(PASSWORD).port(PORT).build(); - boolean result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); + FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH); - assertFalse(result); + assertFalse(result.downloadSuccessful()); + verify(localFileMock, times(1)).delete(); } } \ No newline at end of file -- cgit 1.2.3-korg