diff options
author | 2020-09-22 12:16:46 -0400 | |
---|---|---|
committer | 2020-09-22 13:49:05 -0400 | |
commit | 1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch) | |
tree | 4a821659cf3b50cf946cbb535d528be8508e9fff /ms/blueprintsprocessor/functions/netconf-executor/src/test | |
parent | d97021cd756d63402545fdc2e14ac7611c3da118 (diff) |
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation
Issue-ID: CCSDK-2852
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/test')
7 files changed, 82 insertions, 41 deletions
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<Int> = 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"> <close-session/> </rpc> - """.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<String> = 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<String> = 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<NetconfSessionImpl>() 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 = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<get-config><source><candidate/></source><filter type=\"subtree\">Test-Filter-Content</filter>" + - "</get-config></rpc>") + "</get-config></rpc>" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -45,10 +47,12 @@ class RpcMessageUtilsTest { @Test fun editConfig() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<edit-config><target><candidate/></target><default-operation>Test-Default-Operation</default-operation>" + - "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">Test-Filter-Content</config></edit-config></rpc>") + "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">Test-Filter-Content</config></edit-config></rpc>" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -64,9 +68,11 @@ class RpcMessageUtilsTest { @Test fun validate() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<validate><source><candidate/></source></validate></rpc>") + "<validate><source><candidate/></source></validate></rpc>" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -80,11 +86,13 @@ class RpcMessageUtilsTest { @Test fun cancelCommit() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<cancel-commit>" + "<persist-id>1234</persist-id>" + - "</cancel-commit></rpc>") + "</cancel-commit></rpc>" + ) val messageId = "Test-Message-ID" @@ -98,10 +106,12 @@ class RpcMessageUtilsTest { @Test fun cancelCommitNoPersistId() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<cancel-commit>" + - "</cancel-commit></rpc>") + "</cancel-commit></rpc>" + ) val messageId = "Test-Message-ID" @@ -113,9 +123,11 @@ class RpcMessageUtilsTest { @Test fun commit() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<commit></commit></rpc>") + "<commit></commit></rpc>" + ) val messageId = "Test-Message-ID" @@ -132,11 +144,13 @@ class RpcMessageUtilsTest { @Test fun commitPersistId() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<commit>" + "<persist-id>1234</persist-id>" + - "</commit></rpc>") + "</commit></rpc>" + ) val messageId = "Test-Message-ID" @@ -160,13 +174,15 @@ class RpcMessageUtilsTest { @Test fun commitPersist() { val checkString = - ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + "<commit>" + "<confirmed/>" + "<confirm-timeout>30</confirm-timeout>" + "<persist>1234</persist>" + - "</commit></rpc>") + "</commit></rpc>" + ) val messageId = "Test-Message-ID" @@ -189,9 +205,11 @@ class RpcMessageUtilsTest { @Test fun unlock() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<unlock><target><candidate/></target></unlock></rpc>") + "<unlock><target><candidate/></target></unlock></rpc>" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -204,9 +222,11 @@ class RpcMessageUtilsTest { @Test fun deleteConfig() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<delete-config><target><candidate/></target></delete-config></rpc>") + "<delete-config><target><candidate/></target></delete-config></rpc>" + ) val messageId = "Test-Message-ID" val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore @@ -228,9 +248,11 @@ class RpcMessageUtilsTest { @Test fun discardChanges() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<discard-changes/></rpc>") + "<discard-changes/></rpc>" + ) val messageId = "Test-Message-ID" @@ -242,9 +264,11 @@ class RpcMessageUtilsTest { @Test fun lock() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<rpc message-id=\"Test-Message-ID\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + - "<lock><target><candidate/></target></lock></rpc>") + "<lock><target><candidate/></target></lock></rpc>" + ) val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -273,8 +297,10 @@ class RpcMessageUtilsTest { @Test fun createHelloString() { - val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + - "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>") + val checkString = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + + "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>" + ) val capability = listOf<String>("hi", "hello") @@ -306,12 +332,16 @@ class RpcMessageUtilsTest { @Test fun formatRPCRequest() { - val checkString = ("#199" + + val checkString = ( + "#199" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> <capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>" + - "##") + "##" + ) - val request = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + - "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>") + val request = ( + "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"> " + + "<capabilities> <capability>hi</capability> <capability>hello</capability> </capabilities></hello>]]>]]>" + ) val messageId = "Test-Message-ID" |