From d2e33ff4523ae4600e1c1bd7ddfd3e0e5870e5a3 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Mon, 30 Jul 2018 09:39:17 +0900 Subject: Increase coverage for sshdDataAccessDervice Issue-ID: APPC-1113 Change-Id: If7f466c6e6c205c220ae020c3e4ce24e1088f7f3 Signed-off-by: Ganesh Chandrasekaran --- .../adapter/ssh/sshd/SshdDataAccessService.java | 8 ++ .../ssh/sshd/SshdDataAccessServiceTest.java | 111 +++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/test/java/org/onap/appc/adapter/ssh/sshd/SshdDataAccessServiceTest.java (limited to 'appc-adapters/appc-ssh-adapter') 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 arrayList, String s1) throws SQLException { + return null; + } + + @Override + public boolean writeData(String s, ArrayList 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 unwrap(Class 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"); + } +} -- cgit 1.2.3-korg