From 1072867dfac0df993cbd3e44bcc11a5cac7465fd Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Tue, 22 Sep 2020 12:16:46 -0400 Subject: Enabling Code Formatter Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8 --- .../netconf/executor/api/DeviceInfoTest.kt | 1 + .../netconf/executor/api/NetconfMessageTest.kt | 1 + .../executor/core/NetconfDeviceCommunicatorTest.kt | 6 +- .../executor/core/NetconfRpcServiceImplTest.kt | 3 + .../executor/core/NetconfSessionImplTest.kt | 21 ++--- .../core/NetconfSessionListenerImplTest.kt | 1 + .../netconf/executor/utils/RpcMessageUtilsTest.kt | 90 ++++++++++++++-------- 7 files changed, 82 insertions(+), 41 deletions(-) (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/test') diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt index ab051597b..930fb1276 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/DeviceInfoTest.kt @@ -20,6 +20,7 @@ import org.junit.Test import kotlin.test.assertEquals class DeviceInfoTest { + @Test fun testToString() { diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt index e5bacc547..f4e352165 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/api/NetconfMessageTest.kt @@ -22,6 +22,7 @@ import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus class NetconfMessageTest { + @Test fun testSuccessfulDeviceResponse() { val dr: DeviceResponse = genSuccessfulEmptyDeviceResponse() diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt index 1991fc4f6..c70a43e49 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfDeviceCommunicatorTest.kt @@ -42,6 +42,7 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue class NetconfDeviceCommunicatorTest { + private lateinit var netconfSession: NetconfSession private lateinit var netconfSessionListener: NetconfSessionListener private lateinit var mockInputStream: InputStream @@ -51,7 +52,9 @@ class NetconfDeviceCommunicatorTest { private val endPatternCharArray: List = stringToCharArray(RpcMessageUtils.END_PATTERN) companion object { + private val chunkedEnding = "\n##\n" + // using example from section 4.2 of RFC6242 (https://tools.ietf.org/html/rfc6242#section-4.2) private val validChunkedEncodedMsg = """ | @@ -197,7 +200,8 @@ class NetconfDeviceCommunicatorTest { xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - """.trimIndent(), eventSlot.captured.messagePayload + """.trimIndent(), + eventSlot.captured.messagePayload ) } diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt index 9a3652aa1..b119d26f0 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImplTest.kt @@ -33,9 +33,11 @@ import kotlin.test.assertFailsWith import kotlin.test.assertTrue class NetconfRpcServiceImplTest { + private lateinit var mockNetconfSession: NetconfSessionImpl companion object { + private const val someString = "someString" private const val replyStr = "this is a reply" private val failedDeviceResponse = DeviceResponse( @@ -46,6 +48,7 @@ class NetconfRpcServiceImplTest { status = RpcStatus.SUCCESS, requestMessage = "request message", responseMessage = replyStr ) // responseMessage will be null in this POJO + // but will be set later from mockSession private const val msgId = "100" private const val timeout = 5 diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt index b94c092e3..41e4f8290 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImplTest.kt @@ -53,6 +53,7 @@ import kotlin.test.assertTrue class NetconfSessionImplTest { companion object { + val SUCCESSFUL_DEVICE_RESPONSE = DeviceResponse().apply { status = RpcStatus.SUCCESS errorMessage = "" @@ -150,7 +151,7 @@ class NetconfSessionImplTest { // rpcService.closeSession succeeds with status not RpcStatus.FAILURE val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true) every { rpcService.closeSession(any()) } returns - FAILED_DEVICE_RESPONSE andThen SUCCESSFUL_DEVICE_RESPONSE + FAILED_DEVICE_RESPONSE andThen SUCCESSFUL_DEVICE_RESPONSE every { mockClientSession.close() } just Runs every { mockSshClient.close() } just Runs every { mockClientChannel.close() } just Runs @@ -247,7 +248,7 @@ class NetconfSessionImplTest { // make sure the replies didn't change assertTrue { netconfSessionSpy.getReplies().size == 1 && - netconfSessionSpy.getReplies().containsKey("somekey") + netconfSessionSpy.getReplies().containsKey("somekey") } verify(exactly = 0) { netconfSessionSpy.clearReplies() } } @@ -312,7 +313,7 @@ class NetconfSessionImplTest { val futureRet: CompletableFuture = CompletableFuture.completedFuture(futureMsg) every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws - ExecutionException("exec exception", Exception("nested exception")) + ExecutionException("exec exception", Exception("nested exception")) every { netconfSessionSpy["close"]() as Unit } just Runs every { netconfSessionSpy.checkAndReestablish() } just Runs netconfSessionSpy.setSession(mockClientSession) @@ -329,7 +330,7 @@ class NetconfSessionImplTest { val futureRet: CompletableFuture = CompletableFuture.completedFuture(futureMsg) every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws - ExecutionException("exec exception", Exception("nested exception")) + ExecutionException("exec exception", Exception("nested exception")) every { netconfSessionSpy["close"]() as Unit } throws IOException("got an IO exception") every { netconfSessionSpy.checkAndReestablish() } just Runs // call the method @@ -429,7 +430,7 @@ class NetconfSessionImplTest { succeededSessionFuture.value = mockClientSession every { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) } returns succeededSessionFuture every { mockClientSession.waitFor(any(), any()) } returns - setOf(ClientSession.ClientSessionEvent.WAIT_AUTH, ClientSession.ClientSessionEvent.CLOSED) + setOf(ClientSession.ClientSessionEvent.WAIT_AUTH, ClientSession.ClientSessionEvent.CLOSED) val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true) every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs netconfSessionSpy.setClient(mockSshClient) @@ -451,11 +452,11 @@ class NetconfSessionImplTest { succeededSessionFuture.value = mockClientSession every { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) } returns succeededSessionFuture every { mockClientSession.waitFor(any(), any()) } returns - setOf( - ClientSession.ClientSessionEvent.WAIT_AUTH, - ClientSession.ClientSessionEvent.CLOSED, - ClientSession.ClientSessionEvent.AUTHED - ) + setOf( + ClientSession.ClientSessionEvent.WAIT_AUTH, + ClientSession.ClientSessionEvent.CLOSED, + ClientSession.ClientSessionEvent.AUTHED + ) every { mockClientSession.createSubsystemChannel(any()) } returns mockSubsystem every { mockClientChannel.invertedOut } returns sampleInputStream diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt index ab762e821..abb3a8c4c 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionListenerImplTest.kt @@ -25,6 +25,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.Dev import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfReceivedEvent class NetconfSessionListenerImplTest { + // Note: mockk's verifyAll is akin to verify with verifyNoMoreInteractions in Mockito private val netconSession = mockk() diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt index 0d791c2a6..98d17e38b 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt @@ -27,10 +27,12 @@ class RpcMessageUtilsTest { @Test fun getConfig() { - val checkString = ("" + + val checkString = ( + "" + "" + "Test-Filter-Content" + - "") + "" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -45,10 +47,12 @@ class RpcMessageUtilsTest { @Test fun editConfig() { - val checkString = ("" + + val checkString = ( + "" + "" + "Test-Default-Operation" + - "Test-Filter-Content") + "Test-Filter-Content" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -64,9 +68,11 @@ class RpcMessageUtilsTest { @Test fun validate() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -80,11 +86,13 @@ class RpcMessageUtilsTest { @Test fun cancelCommit() { val checkString = - ("" + + ( + "" + "" + "" + "1234" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -98,10 +106,12 @@ class RpcMessageUtilsTest { @Test fun cancelCommitNoPersistId() { val checkString = - ("" + + ( + "" + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -113,9 +123,11 @@ class RpcMessageUtilsTest { @Test fun commit() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -132,11 +144,13 @@ class RpcMessageUtilsTest { @Test fun commitPersistId() { val checkString = - ("" + + ( + "" + "" + "" + "1234" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -160,13 +174,15 @@ class RpcMessageUtilsTest { @Test fun commitPersist() { val checkString = - ("" + + ( + "" + "" + "" + "" + "30" + "1234" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -189,9 +205,11 @@ class RpcMessageUtilsTest { @Test fun unlock() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -204,9 +222,11 @@ class RpcMessageUtilsTest { @Test fun deleteConfig() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore @@ -228,9 +248,11 @@ class RpcMessageUtilsTest { @Test fun discardChanges() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" @@ -242,9 +264,11 @@ class RpcMessageUtilsTest { @Test fun lock() { - val checkString = ("" + + val checkString = ( + "" + "" + - "") + "" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -273,8 +297,10 @@ class RpcMessageUtilsTest { @Test fun createHelloString() { - val checkString = (" " + - " hi hello ]]>]]>") + val checkString = ( + " " + + " hi hello ]]>]]>" + ) val capability = listOf("hi", "hello") @@ -306,12 +332,16 @@ class RpcMessageUtilsTest { @Test fun formatRPCRequest() { - val checkString = ("#199" + + val checkString = ( + "#199" + " hi hello " + - "##") + "##" + ) - val request = (" " + - " hi hello ]]>]]>") + val request = ( + " " + + " hi hello ]]>]]>" + ) val messageId = "Test-Message-ID" -- cgit 1.2.3-korg