Merge "Add test for FtpsClient, Improve code coverage."
diff --git a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
index c596217..9b6eacb 100644
--- a/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
+++ b/datafile-dmaap-client/src/main/java/org/onap/dcaegen2/collectors/datafile/ftp/FileCollectResult.java
@@ -44,6 +44,6 @@
 
     @Override
     public String toString() {
-        return "Download successful: " + result + " Error data: " + getErrorData();
+        return "FileCollectResult: " + result + " Error data: " + getErrorData();
     }
 }
diff --git a/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/ErrorDataTest.java b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/ErrorDataTest.java
new file mode 100644
index 0000000..e40d7d7
--- /dev/null
+++ b/datafile-dmaap-client/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/ErrorDataTest.java
@@ -0,0 +1,57 @@
+/*
+ * ============LICENSE_START======================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
+ * ===============================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END========================================================================
+ */
+
+package org.onap.dcaegen2.collectors.datafile.ftp;
+
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+public class ErrorDataTest {
+    private List<String> errorMessages = new ArrayList<>();
+    private List<Throwable> errorCauses = new ArrayList<>();
+    private ErrorData errorData = new ErrorData();
+
+    @BeforeEach
+    protected void setUp() {
+        int testSize = 3;
+        for (int i = 0; i < testSize; i++) {
+            errorMessages.add("test");
+            errorCauses.add(mock(Throwable.class));
+        }
+        for (int i = 0; i < testSize; i++) {
+            errorData.addError(errorMessages.get(i), errorCauses.get(i));
+        }
+    }
+
+    public String getMessageAsString() {
+        StringBuilder message = new StringBuilder();
+        for (int i = 0; i < errorMessages.size(); i++) {
+            message.append(errorMessages.get(i)).append(" Cause: ").append(errorCauses.get(i)).append("\n");
+        }
+        return message.toString();
+    }
+
+    @Test
+    public void testToString_returnExpectedString() {
+        Assertions.assertEquals(getMessageAsString(), errorData.toString());
+    }
+}
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 e5693d5..66d3b00 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
@@ -233,4 +233,26 @@
         assertFalse(result.downloadSuccessful());
         verify(localFileMock, times(1)).delete();
     }
+
+    @Test
+    public void collectFileFailingFileRetrieve_shouldFail() throws Exception {
+        when(keyManagerUtilsMock.getClientKeyManager()).thenReturn(keyManagerMock);
+        when(fileResourceMock.getInputStream()).thenReturn(inputStreamMock);
+        when(keyStoreWrapperMock.getKeyStore()).thenReturn(keyStoreMock);
+        when(trustManagerFactoryMock.getTrustManagers()).thenReturn(new TrustManager[] {trustManagerMock});
+        when(ftpsClientMock.login(USERNAME, PASSWORD)).thenReturn(true);
+        when(ftpsClientMock.getReplyCode()).thenReturn(HttpStatus.OK.value());
+        File fileMock = mock(File.class);
+        when(localFileMock.getFile()).thenReturn(fileMock);
+        OutputStream osMock = mock(OutputStream.class);
+        when(outputStreamMock.getOutputStream(fileMock)).thenReturn(osMock);
+        when(ftpsClientMock.retrieveFile(REMOTE_FILE_PATH, osMock)).thenReturn(false);
+
+        ImmutableFileServerData fileServerData = ImmutableFileServerData.builder().serverAddress(XNF_ADDRESS)
+                .userId(USERNAME).password(PASSWORD).port(PORT).build();
+
+        FileCollectResult result = clientUnderTest.collectFile(fileServerData, REMOTE_FILE_PATH, LOCAL_FILE_PATH);
+
+        assertFalse(result.downloadSuccessful());
+    }
 }
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index fc08dd2..6f8e7ed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
     <immutable.version>2.7.1</immutable.version>
     <spring.version>5.1.0.RELEASE</spring.version>
     <spring-boot.version>2.1.0.M4</spring-boot.version>
-    <tomcat.version>8.5.32</tomcat.version>
+    <tomcat.version>8.5.34</tomcat.version>
     <docker.maven.version>1.0.0</docker.maven.version>
     <resource.maven.plugin.version>3.1.0</resource.maven.plugin.version>
 
@@ -271,7 +271,7 @@
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
-        <version>2.16.0</version>
+        <version>2.23.0</version>
         <scope>test</scope>
       </dependency>
       <dependency>