1 package org.onap.appc.adapter.netconf.internal;
3 import org.junit.Assert;
4 import org.junit.Before;
6 import org.mockito.Mockito;
7 import org.onap.appc.adapter.netconf.ConnectionDetails;
8 import org.onap.appc.adapter.netconf.NetconfConnectionDetails;
9 import org.onap.ccsdk.sli.core.dblib.DbLibService;
11 import javax.sql.rowset.CachedRowSet;
12 import java.io.IOException;
13 import java.io.PrintWriter;
14 import java.sql.Connection;
15 import java.sql.SQLException;
16 import java.sql.SQLFeatureNotSupportedException;
17 import java.util.ArrayList;
18 import java.util.logging.Logger;
20 public class TestNetconfDataAccessServiceImpl {
21 NetconfDataAccessServiceImpl netconfDataAccessService;
22 private String schema;
23 private DbLibService dbLibServiceMocked;
27 schema = "test-netconf-adaptor";
28 dbLibServiceMocked = new DbLibService() {
30 public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
31 CachedRowSet cachedRowSetMocked = Mockito.mock(CachedRowSet.class);
32 return cachedRowSetMocked;
36 public boolean writeData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
41 public boolean isActive() {
46 public Connection getConnection() throws SQLException {
51 public Connection getConnection(String username, String password) throws SQLException {
56 public <T> T unwrap(Class<T> iface) throws SQLException {
61 public boolean isWrapperFor(Class<?> iface) throws SQLException {
66 public PrintWriter getLogWriter() throws SQLException {
71 public void setLogWriter(PrintWriter out) throws SQLException {
76 public int getLoginTimeout() throws SQLException {
81 public void setLoginTimeout(int seconds) throws SQLException {
86 public Logger getParentLogger() throws SQLFeatureNotSupportedException {
91 netconfDataAccessService = new NetconfDataAccessServiceImpl();
92 netconfDataAccessService.setSchema(schema);
93 netconfDataAccessService.setDbLibService(dbLibServiceMocked);
97 public void testRetrieveConfigFileName() throws IOException {
98 String response = netconfDataAccessService.retrieveConfigFileName("test");
100 Assert.assertEquals("", response);
104 public void testRetrieveConnectionDetails() throws IOException {
105 ConnectionDetails netconfConnectionDetails = new ConnectionDetails();
107 boolean response = netconfDataAccessService.retrieveConnectionDetails("test", netconfConnectionDetails);
109 Assert.assertEquals(false, response);
113 public void testRetrieveNetconfConnectionDetails() throws IOException {
114 NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
116 boolean response = netconfDataAccessService.retrieveNetconfConnectionDetails("test", netconfConnectionDetails);
118 Assert.assertEquals(true, response);
122 public void testLogDeviceInteraction() throws IOException {
123 NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
125 boolean response = netconfDataAccessService.logDeviceInteraction("test", "",
128 Assert.assertEquals(true, response);