From cd01ebd601bf8d93db5146d5ef5a94c1710cc1ed Mon Sep 17 00:00:00 2001 From: Joss Armstrong Date: Tue, 5 Feb 2019 16:18:40 +0000 Subject: 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 --- .../internal/NetconfDataAccessServiceImpl.java | 2 +- .../internal/TestNetconfDataAccessServiceImpl.java | 24 ++++++---------------- 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src') 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 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); } } -- cgit 1.2.3-korg