summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramshegokar <AS00500801@techmahindra.com>2018-03-23 18:58:36 +0530
committerRanda Maher <rx196w@att.com>2018-03-26 18:03:21 +0000
commitd79cb3a66a0ad576d92d60152437f3ef6f6f4c02 (patch)
tree2e20f7829a4f975f3fb2649247ada9daa4c88c56
parentb5c72a7419dcca3d5f6bb6bcf9aaf2168c07f96b (diff)
Coverage test
Unit Test Coverage for: 1) NetconfConnectionDetails.java 2) NetconfClientType.java Sonar-Link: https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Aappc-netconf-adapter-bundle%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fadapter%2Fnetconf Change-Id: I161d7bfe5e780c7c686ae014d87208e3da36b3cd Issue-ID: APPC-780 Signed-off-by: amshegokar <AS00500801@techmahindra.com>
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfClientTypeTest.java39
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfConnectionDetailsTest.java117
2 files changed, 156 insertions, 0 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfClientTypeTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfClientTypeTest.java
new file mode 100644
index 000000000..7715e2973
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfClientTypeTest.java
@@ -0,0 +1,39 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* 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
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.adapter.netconf;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NetconfClientTypeTest {
+ private NetconfClientType netconfClientType=NetconfClientType.RESTCONF;
+
+ @Test
+ public void testName() {
+ Assert.assertEquals("RESTCONF", netconfClientType.name());
+ }
+
+ @Test
+ public void testEquals() {
+ Assert.assertTrue(netconfClientType.equals(NetconfClientType.RESTCONF));
+ Assert.assertFalse(netconfClientType.equals(null));
+ }
+
+}
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfConnectionDetailsTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfConnectionDetailsTest.java
new file mode 100644
index 000000000..c36cc3f90
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfConnectionDetailsTest.java
@@ -0,0 +1,117 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* 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
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+* ============LICENSE_END=========================================================
+*/
+package org.onap.appc.adapter.netconf;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class NetconfConnectionDetailsTest {
+ private NetconfConnectionDetails netconfConnectionDetails;
+ private List<String> capabilities;
+ private Properties additionalProperties;
+
+ @Before
+ public void SetUp() {
+ netconfConnectionDetails=new NetconfConnectionDetails();
+ }
+
+ @Test
+ public void testGetHost() {
+ netconfConnectionDetails.setHost("host1");
+ Assert.assertNotNull(netconfConnectionDetails.getHost());
+ Assert.assertEquals("host1", netconfConnectionDetails.getHost());
+ }
+
+ @Test
+ public void testGetPort() {
+ netconfConnectionDetails.setPort(123);
+ Assert.assertNotNull(netconfConnectionDetails.getPort());
+ Assert.assertEquals(123, netconfConnectionDetails.getPort());
+ }
+
+ @Test
+ public void testGetUsername() {
+ netconfConnectionDetails.setUsername("ABC");
+ Assert.assertNotNull(netconfConnectionDetails.getUsername());
+ Assert.assertEquals("ABC", netconfConnectionDetails.getUsername());
+ }
+
+ @Test
+ public void testGetPassword() {
+ netconfConnectionDetails.setPassword("pass1");
+ Assert.assertNotNull(netconfConnectionDetails.getPassword());
+ Assert.assertEquals("pass1", netconfConnectionDetails.getPassword());
+ }
+
+ @Test
+ public void testNullCapabilities() {
+ capabilities=new ArrayList<String>();
+ Assert.assertNull(netconfConnectionDetails.getCapabilities());
+ }
+
+ @Test
+ public void testCapabilitiesWithValues() {
+ capabilities=new ArrayList<String>();
+ capabilities.add("capabilities1");
+ capabilities.add("capabilities2");
+ netconfConnectionDetails.setCapabilities(capabilities);
+ Assert.assertTrue(capabilities.contains("capabilities2"));
+ }
+
+ @Test
+ public void testCapabilities_Size() {
+ capabilities=new ArrayList<String>();
+ capabilities.add("capabilities1");
+ capabilities.add("capabilities2");
+ netconfConnectionDetails.setCapabilities(capabilities);
+ Assert.assertEquals(2, capabilities.size());
+ }
+
+ @Test
+ public void testAdditionalProperties() {
+ additionalProperties=new Properties();
+ Assert.assertNull(netconfConnectionDetails.getAdditionalProperties());
+ }
+
+ @Test
+ public void testAdditionalPropertiesWithValues() {
+ additionalProperties=new Properties();
+ additionalProperties.put("A", "a");
+ additionalProperties.put("B", "b");
+ netconfConnectionDetails.setAdditionalProperties(additionalProperties);
+ Assert.assertEquals("a",netconfConnectionDetails.getAdditionalProperties().get("A"));
+ }
+
+ @Test
+ public void testAdditionalProperties_Size() {
+ additionalProperties=new Properties();
+ additionalProperties.put("A", "a");
+ additionalProperties.put("B", "b");
+ additionalProperties.put("C", "c");
+ netconfConnectionDetails.setAdditionalProperties(additionalProperties);
+ Assert.assertNotNull(netconfConnectionDetails.getAdditionalProperties());
+ Assert.assertEquals(3,additionalProperties.size());
+ }
+}