summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-30 09:39:17 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-30 09:53:36 +0900
commitd2e33ff4523ae4600e1c1bd7ddfd3e0e5870e5a3 (patch)
tree7f812c9e21661b5ab9ad8c190ada871df9d709d1
parent61c1c825b6d2bdfa1e66bef9559dba1b529e15a2 (diff)
Increase coverage for sshdDataAccessDervice
Issue-ID: APPC-1113 Change-Id: If7f466c6e6c205c220ae020c3e4ce24e1088f7f3 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java8
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessServiceTest.java111
2 files changed, 119 insertions, 0 deletions
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java
index 7c762c139..b0abcb4f7 100644
--- a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessService.java
@@ -44,11 +44,19 @@ public class SshdDataAccessService implements SshDataAccessService {
this.schema = schema;
}
+ public String getSchema() {
+ return this.schema;
+ }
+
@Override
public void setDbLibService(DbLibService dbLibService) {
this.dbLibService = dbLibService;
}
+ public DbLibService getDbLibService() {
+ return this.dbLibService;
+ }
+
@Override
public boolean retrieveConnectionDetails(String vnfType, SshConnectionDetails connectionDetails) throws SshDataAccessException {
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessServiceTest.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessServiceTest.java
new file mode 100644
index 000000000..0739e679b
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessServiceTest.java
@@ -0,0 +1,111 @@
+package org.onap.appc.adapter.ssh.sshd;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.appc.adapter.ssh.SshConnectionDetails;
+import org.onap.ccsdk.sli.core.dblib.DbLibService;
+
+import javax.sql.rowset.CachedRowSet;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.ArrayList;
+import java.util.logging.Logger;
+
+import static org.junit.Assert.assertEquals;
+
+public class SshdDataAccessServiceTest {
+
+ private SshdDataAccessService sshdDataAccessService;
+ private DbLibService db;
+ @Before
+ public void setUp() {
+ sshdDataAccessService = new SshdDataAccessService();
+ db = new DbLibService() {
+ @Override
+ public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean writeData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean isActive() {
+ return false;
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection(String username, String password) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
+
+ @Override
+ public PrintWriter getLogWriter() throws SQLException {
+ return null;
+ }
+
+ @Override
+ public void setLogWriter(PrintWriter out) throws SQLException {
+
+ }
+
+ @Override
+ public void setLoginTimeout(int seconds) throws SQLException {
+
+ }
+
+ @Override
+ public int getLoginTimeout() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ return null;
+ }
+ };
+ }
+
+ @Test
+ public void testSetSchema() {
+ sshdDataAccessService.setSchema("test");
+ assertEquals("test", sshdDataAccessService.getSchema());
+ }
+
+ @Test
+ public void testSetDbLibService() {
+ sshdDataAccessService.setDbLibService(db);
+ assertEquals(false, sshdDataAccessService.getDbLibService().isActive());
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRetrieveConnectionDetails() {
+ SshConnectionDetails connectionDetails = new SshConnectionDetails();
+ sshdDataAccessService.retrieveConnectionDetails("test", connectionDetails);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testRetrieveConfigFileName() {
+ SshConnectionDetails connectionDetails = new SshConnectionDetails();
+ sshdDataAccessService.retrieveConfigFileName("test");
+ }
+}