Coverage test 89/38089/3
authoramshegokar <AS00500801@techmahindra.com>
Fri, 23 Mar 2018 13:28:36 +0000 (18:58 +0530)
committerRanda Maher <rx196w@att.com>
Mon, 26 Mar 2018 18:03:21 +0000 (18:03 +0000)
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>
appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfClientTypeTest.java [new file with mode: 0644]
appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/NetconfConnectionDetailsTest.java [new file with mode: 0644]

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 (file)
index 0000000..7715e29
--- /dev/null
@@ -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 (file)
index 0000000..c36cc3f
--- /dev/null
@@ -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());
+    }
+}