From d3b56a45e948a2e3d0cf8c5514cdaf4e08a0b4fe Mon Sep 17 00:00:00 2001 From: Ganesh Date: Fri, 24 Jun 2022 19:18:42 +0530 Subject: sonar issue, Change the assertion arguments to not compare a primitive value with null Signed-off-by: Ganesh Change-Id: Idc8fcd5e6b2c7dce0da0b8f04721634ece05c5c7 Issue-ID: CCSDK-3476 --- .../netconf/NetconfConnectionDetailsTest.java | 235 ++++++++++----------- 1 file changed, 117 insertions(+), 118 deletions(-) (limited to 'adaptors/netconf-adaptor/netconf-adaptor-bundle/src/test') diff --git a/adaptors/netconf-adaptor/netconf-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/netconf/NetconfConnectionDetailsTest.java b/adaptors/netconf-adaptor/netconf-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/netconf/NetconfConnectionDetailsTest.java index 2d0bea92c..544b149b4 100644 --- a/adaptors/netconf-adaptor/netconf-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/netconf/NetconfConnectionDetailsTest.java +++ b/adaptors/netconf-adaptor/netconf-adaptor-bundle/src/test/java/org/onap/ccsdk/sli/adaptors/netconf/NetconfConnectionDetailsTest.java @@ -1,118 +1,117 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : APPC -* ================================================================================ -* Copyright 2018 TechMahindra -* ================================================================================ -* 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 -* -* 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.ccsdk.sli.adaptors.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 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(); - Assert.assertNull(netconfConnectionDetails.getCapabilities()); - } - - @Test - public void testCapabilitiesWithValues() { - capabilities = new ArrayList(); - capabilities.add("capabilities1"); - capabilities.add("capabilities2"); - netconfConnectionDetails.setCapabilities(capabilities); - Assert.assertTrue(capabilities.contains("capabilities2")); - } - - @Test - public void testCapabilities_Size() { - capabilities = new ArrayList(); - 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()); - } -} +/* +* ============LICENSE_START======================================================= +* ONAP : APPC +* ================================================================================ +* Copyright 2018 TechMahindra +* ================================================================================ +* 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 +* +* 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.ccsdk.sli.adaptors.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 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.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(); + Assert.assertNull(netconfConnectionDetails.getCapabilities()); + } + + @Test + public void testCapabilitiesWithValues() { + capabilities = new ArrayList(); + capabilities.add("capabilities1"); + capabilities.add("capabilities2"); + netconfConnectionDetails.setCapabilities(capabilities); + Assert.assertTrue(capabilities.contains("capabilities2")); + } + + @Test + public void testCapabilities_Size() { + capabilities = new ArrayList(); + 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()); + } +} -- cgit 1.2.3-korg