aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoss Armstrong <joss.armstrong@ericsson.com>2019-02-05 16:18:40 +0000
committerTakamune Cho <takamune.cho@att.com>2019-02-06 13:02:52 +0000
commitcd01ebd601bf8d93db5146d5ef5a94c1710cc1ed (patch)
tree3f42a938bff49e14c0e97d66130334ca6076c56f
parent441f27e9bafd79a0da9df831c10e660d5feefca1 (diff)
Improve testing and coverage of netconf class
Test now covers main success flows and increased coverage Issue-ID: APPC-1390 Change-Id: I951d5ac3426ae6d6aa3567c80aef5a5bb95fa1c7 Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java2
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfDataAccessServiceImpl.java24
2 files changed, 7 insertions, 19 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
index 70a202865..f78398f1d 100644
--- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/onap/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java
@@ -137,7 +137,7 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService {
try {
dbLibService.writeData(queryString, argList, schema);
} catch (SQLException e) {
- logger.error("Logging Device interaction failed - "+ queryString);
+ logger.error("Logging Device interaction failed - " + queryString);
throw new DataAccessException(e);
}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfDataAccessServiceImpl.java
index c1d28455c..e2d6f2704 100644
--- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfDataAccessServiceImpl.java
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfDataAccessServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 Samsung
* ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * ================================================================================
* 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
@@ -25,10 +27,9 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.onap.appc.adapter.netconf.ConnectionDetails;
import org.onap.appc.adapter.netconf.NetconfConnectionDetails;
+import org.onap.appc.adapter.netconf.util.Constants;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
-
import javax.sql.rowset.CachedRowSet;
import java.io.IOException;
import java.io.PrintWriter;
@@ -50,6 +51,8 @@ public class TestNetconfDataAccessServiceImpl {
@Override
public CachedRowSet getData(String s, ArrayList<String> arrayList, String s1) throws SQLException {
CachedRowSet cachedRowSetMocked = Mockito.mock(CachedRowSet.class);
+ Mockito.when(cachedRowSetMocked.first()).thenReturn(true);
+ Mockito.when(cachedRowSetMocked.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME)).thenReturn("File_Content");
return cachedRowSetMocked;
}
@@ -117,35 +120,20 @@ public class TestNetconfDataAccessServiceImpl {
@Test
public void testRetrieveConfigFileName() throws IOException {
String response = netconfDataAccessService.retrieveConfigFileName("test");
-
- Assert.assertEquals("", response);
- }
-
- @Test
- public void testRetrieveConnectionDetails() throws IOException {
- ConnectionDetails netconfConnectionDetails = new ConnectionDetails();
-
- boolean response = netconfDataAccessService.retrieveConnectionDetails("test", netconfConnectionDetails);
-
- Assert.assertEquals(false, response);
+ Assert.assertEquals("File_Content", response);
}
@Test
public void testRetrieveNetconfConnectionDetails() throws IOException {
NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
-
boolean response = netconfDataAccessService.retrieveNetconfConnectionDetails("test", netconfConnectionDetails);
-
Assert.assertEquals(true, response);
}
@Test
public void testLogDeviceInteraction() throws IOException {
- NetconfConnectionDetails netconfConnectionDetails = new NetconfConnectionDetails();
-
boolean response = netconfDataAccessService.logDeviceInteraction("test", "",
"", "");
-
Assert.assertEquals(true, response);
}
}