011b33a287fc698b63e636a90a6c02b2c0668805
[appc.git] /
1 package org.onap.appc.adapter.netconf.internal;
2
3 import org.junit.Assert;
4 import org.junit.Before;
5 import org.junit.Test;
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;
10
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;
19
20 public class TestNetconfDataAccessServiceImpl {
21     NetconfDataAccessServiceImpl netconfDataAccessService;
22     private String schema;
23     private DbLibService dbLibServiceMocked;
24
25     @Before
26     public void SetUp() {
27         schema = "test-netconf-adaptor";
28         dbLibServiceMocked = new DbLibService() {
29             @Override
30             public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
31                 CachedRowSet cachedRowSetMocked = Mockito.mock(CachedRowSet.class);
32                 return cachedRowSetMocked;
33             }
34
35             @Override
36             public boolean writeData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
37                 return false;
38             }
39
40             @Override
41             public boolean isActive() {
42                 return false;
43             }
44
45             @Override
46             public Connection getConnection() throws SQLException {
47                 return null;
48             }
49
50             @Override
51             public Connection getConnection(String username, String password) throws SQLException {
52                 return null;
53             }
54
55             @Override
56             public <T> T unwrap(Class<T> iface) throws SQLException {
57                 return null;
58             }
59
60             @Override
61             public boolean isWrapperFor(Class<?> iface) throws SQLException {
62                 return false;
63             }
64
65             @Override
66             public PrintWriter getLogWriter() throws SQLException {
67                 return null;
68             }
69
70             @Override
71             public void setLogWriter(PrintWriter out) throws SQLException {
72
73             }
74
75             @Override
76             public int getLoginTimeout() throws SQLException {
77                 return 0;
78             }
79
80             @Override
81             public void setLoginTimeout(int seconds) throws SQLException {
82
83             }
84
85             @Override
86             public Logger getParentLogger() throws SQLFeatureNotSupportedException {
87                 return null;
88             }
89         };
90
91         netconfDataAccessService = new NetconfDataAccessServiceImpl();
92         netconfDataAccessService.setSchema(schema);
93         netconfDataAccessService.setDbLibService(dbLibServiceMocked);
94     }
95
96     @Test
97     public void testRetrieveConfigFileName() throws IOException {
98         String response = netconfDataAccessService.retrieveConfigFileName("test");
99
100         Assert.assertEquals("", response);
101     }
102
103     @Test
104     public void testRetrieveConnectionDetails() throws IOException {
105         ConnectionDetails netconfConnectionDetails = new ConnectionDetails();
106
107         boolean response = netconfDataAccessService.retrieveConnectionDetails("test", netconfConnectionDetails);
108
109         Assert.assertEquals(false, response);
110     }
111
112     @Test
113     public void testRetrieveNetconfConnectionDetails() throws IOException {
114         NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
115
116         boolean response = netconfDataAccessService.retrieveNetconfConnectionDetails("test", netconfConnectionDetails);
117
118         Assert.assertEquals(true, response);
119     }
120
121     @Test
122     public void testLogDeviceInteraction() throws IOException {
123         NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
124
125         boolean response = netconfDataAccessService.logDeviceInteraction("test", "",
126                                                                          "", "");
127
128         Assert.assertEquals(true, response);
129     }
130 }