diff options
author | 2019-11-22 18:06:08 -0500 | |
---|---|---|
committer | 2019-11-26 21:32:38 +0000 | |
commit | 341db21b2ac0a14a1ed2b8bf7930914dda054bfe (patch) | |
tree | 113bba965b06cfe3a8af3a0a527d1a41c9faf0f9 /ms/blueprintsprocessor/functions/netconf-executor/src/test | |
parent | d274e5fc552cf9ae25500f504f0434981cf3accf (diff) |
Formatting Code base with ktlint
No Business logic change, just the code format.
Competible with IntelliJ: https://github.com/pinterest/ktlint#option-3
To format run: mvn process-sources -P format
Issue-ID: CCSDK-1947
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
Change-Id: Ic9e9209fb7023d77f434693ad5a01229f8d09331
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/test')
10 files changed, 373 insertions, 290 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt index be3ee4614..f3df55b4b 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt @@ -54,16 +54,22 @@ class ComponentNetconfExecutorTest { coEvery { blueprintJythonService.jythonComponentInstance(any(), any()) } returns mockAbstractScriptComponentFunction - val componentFunctionScriptingService = ComponentFunctionScriptingService(applicationContext, - blueprintJythonService) + val componentFunctionScriptingService = ComponentFunctionScriptingService( + applicationContext, + blueprintJythonService + ) val componentNetconfExecutor = ComponentNetconfExecutor(componentFunctionScriptingService) - val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json", - ExecutionServiceInput::class.java)!! + val executionServiceInput = JacksonUtils.readValueFromClassPathFile( + "requests/sample-activate-request.json", + ExecutionServiceInput::class.java + )!! - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime( + "1234", + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + ) val assignmentParams = """{ "ipAddress" : "127.0.0.1", @@ -77,12 +83,14 @@ class ComponentNetconfExecutorTest { """.trimIndent() bluePrintRuntimeService.assignInputs(json.asJsonType()) - bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", - JacksonUtils.jsonNode(assignmentParams)) + bluePrintRuntimeService.setNodeTemplateAttributeValue( + "resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams) + ) componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService - //TODO("Set Attribute properties") + // TODO("Set Attribute properties") val stepMetaData: MutableMap<String, JsonNode> = hashMapOf() stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf") stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor") @@ -98,4 +106,3 @@ class ComponentNetconfExecutorTest { } } } - 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 4e1ff655d..ab051597b 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 @@ -16,7 +16,6 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api - import org.junit.Test import kotlin.test.assertEquals @@ -24,13 +23,13 @@ class DeviceInfoTest { @Test fun testToString() { - val di: DeviceInfo = DeviceInfo().apply { - username = "username" - password = "password" - ipAddress = "localhost" - port = 2224 - connectTimeout = 10 - } + val di: DeviceInfo = DeviceInfo().apply { + username = "username" + password = "password" + ipAddress = "localhost" + port = 2224 + connectTimeout = 10 + } assertEquals("localhost:2224", di.toString()) } -}
\ No newline at end of file +} 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 70bf0158d..e5bacc547 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 @@ -37,13 +37,13 @@ class NetconfMessageTest { val dr: DeviceResponse = genUnsuccessfulEmptyDeviceResponse() assertFalse(dr.isSuccess()) - //case 2: Success, but with error message + // case 2: Success, but with error message val dr2: DeviceResponse = genUnsuccessfulEmptyDeviceResponse() dr2.errorMessage = "Some error message." assertFalse(dr2.isSuccess()) } - //helper function to generate a device response + // helper function to generate a device response private fun genSuccessfulEmptyDeviceResponse(): DeviceResponse { return DeviceResponse().apply { status = RpcStatus.SUCCESS @@ -61,5 +61,4 @@ class NetconfMessageTest { requestMessage = "" } } - -}
\ No newline at end of file +} 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 2240f48c2..1991fc4f6 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 @@ -16,7 +16,13 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core -import io.mockk.* +import io.mockk.CapturingSlot +import io.mockk.Runs +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.spyk +import io.mockk.verify import org.junit.Before import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo @@ -27,9 +33,10 @@ import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.R import java.io.IOException import java.io.InputStream import java.io.OutputStream -import java.nio.charset.* -import java.util.concurrent.* -import java.util.regex.* +import java.nio.charset.StandardCharsets +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ConcurrentHashMap +import java.util.regex.Pattern import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue @@ -43,10 +50,9 @@ class NetconfDeviceCommunicatorTest { private lateinit var replies: MutableMap<String, CompletableFuture<String>> 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) + // using example from section 4.2 of RFC6242 (https://tools.ietf.org/html/rfc6242#section-4.2) private val validChunkedEncodedMsg = """ | |#4 @@ -82,25 +88,27 @@ class NetconfDeviceCommunicatorTest { val communicator: NetconfDeviceCommunicator = NetconfDeviceCommunicator(mockInputStream, mockOutputStream, genDeviceInfo(), netconfSessionListener, replies) communicator.join() - //verify + // verify verify { mockInputStream.read(any(), any(), any()) } } @Test fun `NetconfDeviceCommunicator unregisters device on END_PATTERN`() { - //The reader will generate RpcMessageUtils.END_PATTERN "]]>]]>" which tells Netconf - //to unregister the device. - //we want to capture the slot to return the value as inputStreamReader will pass a char array - //create a slot where NetconfReceivedEvent will be placed to further verify Type.DEVICE_UNREGISTERED + // The reader will generate RpcMessageUtils.END_PATTERN "]]>]]>" which tells Netconf + // to unregister the device. + // we want to capture the slot to return the value as inputStreamReader will pass a char array + // create a slot where NetconfReceivedEvent will be placed to further verify Type.DEVICE_UNREGISTERED val eventSlot = CapturingSlot<NetconfReceivedEvent>() every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs stubInputStream = RpcMessageUtils.END_PATTERN.byteInputStream(StandardCharsets.UTF_8) val inputStreamSpy = spyk(stubInputStream) - //RUN the test - val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, - genDeviceInfo(), netconfSessionListener, replies) + // RUN the test + val communicator = NetconfDeviceCommunicator( + inputStreamSpy, mockOutputStream, + genDeviceInfo(), netconfSessionListener, replies + ) communicator.join() - //Verify + // Verify verify { inputStreamSpy.close() } assertTrue { eventSlot.isCaptured } assertEquals(NetconfReceivedEvent.Type.DEVICE_UNREGISTERED, eventSlot.captured.type) @@ -114,11 +122,13 @@ class NetconfDeviceCommunicatorTest { stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) val inputStreamSpy = spyk(stubInputStream) every { inputStreamSpy.read(any(), any(), any()) } returns 1 andThenThrows IOException("Fake IO Exception") - //RUN THE TEST - val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, - genDeviceInfo(), netconfSessionListener, replies) + // RUN THE TEST + val communicator = NetconfDeviceCommunicator( + inputStreamSpy, mockOutputStream, + genDeviceInfo(), netconfSessionListener, replies + ) communicator.join() - //Verify + // Verify assertTrue { eventSlot.isCaptured } assertEquals(genDeviceInfo(), eventSlot.captured.deviceInfo) assertEquals(NetconfReceivedEvent.Type.DEVICE_ERROR, eventSlot.captured.type) @@ -130,14 +140,16 @@ class NetconfDeviceCommunicatorTest { val payload = "<rpc-reply>blah</rpc-reply>" stubInputStream = "$payload${RpcMessageUtils.END_PATTERN}".byteInputStream(StandardCharsets.UTF_8) every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs - //RUN the test - val communicator = NetconfDeviceCommunicator(stubInputStream, mockOutputStream, - genDeviceInfo(), netconfSessionListener, replies) + // RUN the test + val communicator = NetconfDeviceCommunicator( + stubInputStream, mockOutputStream, + genDeviceInfo(), netconfSessionListener, replies + ) communicator.join() - //Verify - verify(exactly = 0) { mockInputStream.close() } //make sure the reader is not closed as this could cause problems + // Verify + verify(exactly = 0) { mockInputStream.close() } // make sure the reader is not closed as this could cause problems assertTrue { eventSlot.isCaptured } - //eventually, sessionListener is called with message type DEVICE_REPLY + // eventually, sessionListener is called with message type DEVICE_REPLY assertEquals(NetconfReceivedEvent.Type.DEVICE_REPLY, eventSlot.captured.type) assertEquals(payload, eventSlot.captured.messagePayload) } @@ -150,16 +162,18 @@ class NetconfDeviceCommunicatorTest { every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs stubInputStream = payloadWithChunkedEnding.byteInputStream(StandardCharsets.UTF_8) - //we have to ensure that the input stream is processed, so need to create a spy object. + // we have to ensure that the input stream is processed, so need to create a spy object. val inputStreamSpy = spyk(stubInputStream) - //RUN the test - val communicator = NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, genDeviceInfo(), - netconfSessionListener, replies) + // RUN the test + val communicator = NetconfDeviceCommunicator( + inputStreamSpy, mockOutputStream, genDeviceInfo(), + netconfSessionListener, replies + ) communicator.join() - //Verify - verify(exactly = 0) { inputStreamSpy.close() } //make sure the reader is not closed as this could cause problems + // Verify + verify(exactly = 0) { inputStreamSpy.close() } // make sure the reader is not closed as this could cause problems assertTrue { eventSlot.isCaptured } - //eventually, sessionListener is called with message type DEVICE_REPLY + // eventually, sessionListener is called with message type DEVICE_REPLY assertEquals(NetconfReceivedEvent.Type.DEVICE_ERROR, eventSlot.captured.type) assertEquals("", eventSlot.captured.messagePayload) } @@ -170,23 +184,25 @@ class NetconfDeviceCommunicatorTest { stubInputStream = validChunkedEncodedMsg.byteInputStream(StandardCharsets.UTF_8) val inputStreamSpy = spyk(stubInputStream) every { netconfSessionListener.accept(event = capture(eventSlot)) } just Runs - //RUN the test + // RUN the test NetconfDeviceCommunicator(inputStreamSpy, mockOutputStream, genDeviceInfo(), netconfSessionListener, replies).join() - //Verify - verify(exactly = 0) { inputStreamSpy.close() } //make sure the reader is not closed as this could cause problems + // Verify + verify(exactly = 0) { inputStreamSpy.close() } // make sure the reader is not closed as this could cause problems assertTrue { eventSlot.isCaptured } - //eventually, sessionListener is called with message type DEVICE_REPLY + // eventually, sessionListener is called with message type DEVICE_REPLY assertEquals(NetconfReceivedEvent.Type.DEVICE_REPLY, eventSlot.captured.type) - assertEquals(""" + assertEquals( + """ <rpc message-id="102" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <close-session/> </rpc> - """.trimIndent(), eventSlot.captured.messagePayload) + """.trimIndent(), eventSlot.captured.messagePayload + ) } @Test - //test to ensure that we have a valid test message to be then used in the case of chunked message + // test to ensure that we have a valid test message to be then used in the case of chunked message // validation code path fun `chunked sample is validated by the chunked response regex`() { val test1 = "\n#10\nblah\n##\n" @@ -196,7 +212,7 @@ class NetconfDeviceCommunicatorTest { } @Test - //Verify that our test sample passes the second pattern for chunked size + // Verify that our test sample passes the second pattern for chunked size fun `chunkSizeMatcher pattern finds matches in chunkedMessageSample`() { val sizePattern = Pattern.compile("\\n#([1-9][0-9]*)\\n") val matcher = sizePattern.matcher(validChunkedEncodedMsg) @@ -207,17 +223,18 @@ class NetconfDeviceCommunicatorTest { fun `sendMessage writes the request to NetconfDeviceCommunicator Writer`() { val msgPayload = "some text" val msgId = "100" - stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) //no data available in the stream... + stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) // no data available in the stream... every { mockOutputStream.write(any(), any(), any()) } just Runs every { mockOutputStream.write(msgPayload.toByteArray(Charsets.UTF_8)) } just Runs every { mockOutputStream.flush() } just Runs - //Run the command + // Run the command val communicator = NetconfDeviceCommunicator( stubInputStream, mockOutputStream, - genDeviceInfo(), netconfSessionListener, replies) + genDeviceInfo(), netconfSessionListener, replies + ) val completableFuture = communicator.sendMessage(msgPayload, msgId) communicator.join() - //verify + // verify verify { mockOutputStream.write(any(), any(), any()) } verify { mockOutputStream.flush() } assertFalse { completableFuture.isCompletedExceptionally } @@ -227,14 +244,15 @@ class NetconfDeviceCommunicatorTest { fun `sendMessage on IOError returns completed exceptionally future`() { val msgPayload = "some text" val msgId = "100" - every { mockOutputStream.write(any(), any(), any()) } throws IOException("Some IO error occurred!") - stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) //no data available in the stream... - //Run the command + every { mockOutputStream.write(any(), any(), any()) } throws IOException("Some IO error occurred!") + stubInputStream = "".byteInputStream(StandardCharsets.UTF_8) // no data available in the stream... + // Run the command val communicator = NetconfDeviceCommunicator( stubInputStream, mockOutputStream, - genDeviceInfo(), netconfSessionListener, replies) + genDeviceInfo(), netconfSessionListener, replies + ) val completableFuture = communicator.sendMessage(msgPayload, msgId) - //verify + // verify verify { mockOutputStream.write(any(), any(), any()) } verify(exactly = 0) { mockOutputStream.flush() } assertTrue { completableFuture.isCompletedExceptionally } @@ -248,5 +266,4 @@ class NetconfDeviceCommunicatorTest { port = 4567 } } - } diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt index ce7594c4a..e68e5d865 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/core/NetconfMessageStateTest.kt @@ -27,121 +27,166 @@ class NetconfMessageStateTest { @Test fun `NO_MATCHING_PATTERN transitions`() { - assertEquals(NetconfMessageState.FIRST_BRACKET, - NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(']')) - assertEquals(NetconfMessageState.FIRST_LF, - NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar('\n')) - - charList.minus(listOf(']','\n')).forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(it)) + assertEquals( + NetconfMessageState.FIRST_BRACKET, + NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(']') + ) + assertEquals( + NetconfMessageState.FIRST_LF, + NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar('\n') + ) + + charList.minus(listOf(']', '\n')).forEach { + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.NO_MATCHING_PATTERN.evaluateChar(it) + ) } } @Test fun `FIRST_BRACKET transitions`() { - assertEquals(NetconfMessageState.SECOND_BRACKET, - NetconfMessageState.FIRST_BRACKET.evaluateChar(']')) + assertEquals( + NetconfMessageState.SECOND_BRACKET, + NetconfMessageState.FIRST_BRACKET.evaluateChar(']') + ) - charList.minus( ']').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.FIRST_BRACKET.evaluateChar(it)) + charList.minus(']').forEach { + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.FIRST_BRACKET.evaluateChar(it) + ) } } @Test fun `SECOND_BRACKET transitions`() { - assertEquals(NetconfMessageState.FIRST_BIGGER, - NetconfMessageState.SECOND_BRACKET.evaluateChar('>')) + assertEquals( + NetconfMessageState.FIRST_BIGGER, + NetconfMessageState.SECOND_BRACKET.evaluateChar('>') + ) charList.minus('>').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.SECOND_BRACKET.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.SECOND_BRACKET.evaluateChar(it) + ) } } @Test fun `FIRST_BIGGER transitions`() { - assertEquals(NetconfMessageState.THIRD_BRACKET, - NetconfMessageState.FIRST_BIGGER.evaluateChar(']')) + assertEquals( + NetconfMessageState.THIRD_BRACKET, + NetconfMessageState.FIRST_BIGGER.evaluateChar(']') + ) charList.minus(']').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.FIRST_BIGGER.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.FIRST_BIGGER.evaluateChar(it) + ) } } @Test fun `THIRD_BRACKET transitions`() { - assertEquals(NetconfMessageState.ENDING_BIGGER, - NetconfMessageState.THIRD_BRACKET.evaluateChar(']')) + assertEquals( + NetconfMessageState.ENDING_BIGGER, + NetconfMessageState.THIRD_BRACKET.evaluateChar(']') + ) charList.minus(']').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.THIRD_BRACKET.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.THIRD_BRACKET.evaluateChar(it) + ) } } @Test fun `ENDING_BIGGER transitions`() { - assertEquals(NetconfMessageState.END_PATTERN, - NetconfMessageState.ENDING_BIGGER.evaluateChar('>')) + assertEquals( + NetconfMessageState.END_PATTERN, + NetconfMessageState.ENDING_BIGGER.evaluateChar('>') + ) charList.minus('>').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.ENDING_BIGGER.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.ENDING_BIGGER.evaluateChar(it) + ) } } @Test fun `FIRST_LF transitions`() { - assertEquals(NetconfMessageState.FIRST_HASH, - NetconfMessageState.FIRST_LF.evaluateChar('#')) - assertEquals(NetconfMessageState.FIRST_BRACKET, - NetconfMessageState.FIRST_LF.evaluateChar(']')) - assertEquals(NetconfMessageState.FIRST_LF, - NetconfMessageState.FIRST_LF.evaluateChar('\n')) + assertEquals( + NetconfMessageState.FIRST_HASH, + NetconfMessageState.FIRST_LF.evaluateChar('#') + ) + assertEquals( + NetconfMessageState.FIRST_BRACKET, + NetconfMessageState.FIRST_LF.evaluateChar(']') + ) + assertEquals( + NetconfMessageState.FIRST_LF, + NetconfMessageState.FIRST_LF.evaluateChar('\n') + ) charList.minus(listOf('#', ']', '\n')).forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.FIRST_LF.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.FIRST_LF.evaluateChar(it) + ) } } @Test fun `FIRST_HASH transitions`() { - assertEquals(NetconfMessageState.SECOND_HASH, - NetconfMessageState.FIRST_HASH.evaluateChar('#')) + assertEquals( + NetconfMessageState.SECOND_HASH, + NetconfMessageState.FIRST_HASH.evaluateChar('#') + ) charList.minus('#').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.FIRST_HASH.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.FIRST_HASH.evaluateChar(it) + ) } } @Test fun `SECOND_HASH transitions`() { - assertEquals(NetconfMessageState.END_CHUNKED_PATTERN, - NetconfMessageState.SECOND_HASH.evaluateChar('\n')) - - charList.minus( '\n').forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.SECOND_HASH.evaluateChar(it)) + assertEquals( + NetconfMessageState.END_CHUNKED_PATTERN, + NetconfMessageState.SECOND_HASH.evaluateChar('\n') + ) + + charList.minus('\n').forEach { + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.SECOND_HASH.evaluateChar(it) + ) } } @Test fun `END_CHUNKED_PATTERN transitions`() { charList.forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.END_CHUNKED_PATTERN.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.END_CHUNKED_PATTERN.evaluateChar(it) + ) } } @Test fun `END_PATTERN transitions`() { charList.forEach { - assertEquals(NetconfMessageState.NO_MATCHING_PATTERN, - NetconfMessageState.END_PATTERN.evaluateChar(it)) + assertEquals( + NetconfMessageState.NO_MATCHING_PATTERN, + NetconfMessageState.END_PATTERN.evaluateChar(it) + ) } } - } 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 7b0b799bc..9a3652aa1 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 @@ -21,7 +21,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.spyk import org.junit.Before - import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceResponse @@ -39,11 +38,15 @@ class NetconfRpcServiceImplTest { companion object { private const val someString = "someString" private const val replyStr = "this is a reply" - private val failedDeviceResponse = DeviceResponse(status = RpcStatus.FAILURE, - requestMessage = "request message", responseMessage = replyStr) //responseMessage will be null in this POJO - private val successfulDeviceResponse = DeviceResponse(status = RpcStatus.SUCCESS, - requestMessage = "request message", responseMessage = replyStr) //responseMessage will be null in this POJO - //but will be set later from mockSession + private val failedDeviceResponse = DeviceResponse( + status = RpcStatus.FAILURE, + requestMessage = "request message", responseMessage = replyStr + ) // responseMessage will be null in this POJO + private val successfulDeviceResponse = DeviceResponse( + 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 private val deviceInfo: DeviceInfo = DeviceInfo().apply { @@ -375,4 +378,4 @@ class NetconfRpcServiceImplTest { assertTrue { rpcResult.errorMessage!!.contains("failed in 'closeSession' command") } } } -}
\ No newline at end of file +} 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 e3cda5a49..b94c092e3 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 @@ -16,7 +16,13 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core -import io.mockk.* +import io.mockk.CapturingSlot +import io.mockk.Runs +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.spyk +import io.mockk.verify import org.apache.sshd.client.SshClient import org.apache.sshd.client.channel.ChannelSubsystem import org.apache.sshd.client.channel.ClientChannel @@ -37,8 +43,10 @@ import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.IOException import java.io.InputStream -import java.nio.charset.* -import java.util.concurrent.* +import java.nio.charset.StandardCharsets +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutionException +import java.util.concurrent.TimeoutException import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertTrue @@ -106,7 +114,7 @@ class NetconfSessionImplTest { verify { session["startClient"]() } } - //look for NetconfException being thrown when cannot connect + // look for NetconfException being thrown when cannot connect @Test fun `connect throws NetconfException on error`() { val errMsg = "$deviceInfo: Failed to establish SSH session" @@ -119,7 +127,7 @@ class NetconfSessionImplTest { @Test fun `disconnect without force option for rpcService succeeds`() { - //rpcService.closeSession succeeds with status not RpcStatus.FAILURE + // rpcService.closeSession succeeds with status not RpcStatus.FAILURE every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE every { mockClientSession.close() } just Runs every { mockSshClient.close() } just Runs @@ -128,9 +136,9 @@ class NetconfSessionImplTest { netconfSessionSpy.setSession(mockClientSession) netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setChannel(mockClientChannel) - //RUN + // RUN netconfSessionSpy.disconnect() - //make sure that rpcService.close session is not called again. + // make sure that rpcService.close session is not called again. verify(exactly = 0) { rpcService.closeSession(true) } verify { mockClientSession.close() } verify { mockSshClient.close() } @@ -139,24 +147,23 @@ class NetconfSessionImplTest { @Test fun `disconnect with force option for rpcService succeeds`() { - //rpcService.closeSession succeeds with status not RpcStatus.FAILURE + // 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 netconfSessionSpy.setSession(mockClientSession) netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setChannel(mockClientChannel) - //RUN + // RUN netconfSessionSpy.disconnect() - //VERIFY + // VERIFY verify(exactly = 2) { rpcService.closeSession(any()) } verify { mockClientSession.close() } verify { mockSshClient.close() } verify { mockClientChannel.close() } - } @Test @@ -185,9 +192,9 @@ class NetconfSessionImplTest { every { mockSshClient.isClosed } returns true netconfSessionSpy.setClient(mockSshClient) every { netconfSessionSpy["startConnection"]() as Unit } just Runs - //Call method + // Call method netconfSessionSpy.checkAndReestablish() - //Verify + // Verify verify { netconfSessionSpy.clearReplies() } verify { netconfSessionSpy["startConnection"]() } } @@ -200,9 +207,9 @@ class NetconfSessionImplTest { every { netconfSessionSpy["startSession"]() as Unit } just Runs netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setSession(mockClientSession) - //Call method + // Call method netconfSessionSpy.checkAndReestablish() - //Verify + // Verify verify { netconfSessionSpy.clearReplies() } verify { netconfSessionSpy["startSession"]() } } @@ -217,59 +224,57 @@ class NetconfSessionImplTest { netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setSession(mockClientSession) netconfSessionSpy.setChannel(mockClientChannel) - //Call method + // Call method netconfSessionSpy.checkAndReestablish() - //Verify + // Verify verify { netconfSessionSpy.clearReplies() } verify { netconfSessionSpy["openChannel"]() } } - @Test fun `syncRpc runs normally`() { val netconfSessionSpy = spyk(netconfSession) val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg) - //test the case where SSH connection did not need to be re-established. - //put an existing item into the replies + // test the case where SSH connection did not need to be re-established. + // put an existing item into the replies netconfSessionSpy.getReplies()["somekey"] = CompletableFuture.completedFuture("${futureMsg}2") every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } returns futureRet.get() every { netconfSessionSpy.checkAndReestablish() } just Runs - //call the method + // call the method assertEquals(futureMsg, netconfSessionSpy.syncRpc("0", "0")) - //make sure the replies didn't change + // 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() } } - @Test fun `syncRpc still succeeds and replies are cleared on client disconnect`() { val netconfSessionSpy = spyk(netconfSession, recordPrivateCalls = true) val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg) - //put an item into the replies + // put an item into the replies netconfSessionSpy.getReplies()["somekey"] = CompletableFuture.completedFuture("${futureMsg}2") - //tests the case where SSH session needs to be re-established. + // tests the case where SSH session needs to be re-established. every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfSessionSpy["startClient"]() as Unit } just Runs every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } returns futureRet.get() every { mockSshClient.isClosed } returns true netconfSessionSpy.setClient(mockSshClient) - //call the method + // call the method assertEquals(futureMsg, netconfSessionSpy.syncRpc("0", "0")) - //make sure the replies got cleared out + // make sure the replies got cleared out assertTrue { netconfSessionSpy.getReplies().isEmpty() } verify(exactly = 1) { netconfSessionSpy.clearReplies() } } - //Test for handling CompletableFuture.get returns InterruptedException inside NetconfDeviceCommunicator + // Test for handling CompletableFuture.get returns InterruptedException inside NetconfDeviceCommunicator @Test fun `syncRpc throws NetconfException if InterruptedException is caught`() { val expectedExceptionMsg = "$deviceInfo: Interrupted while waiting for reply for request: $formattedRequest" @@ -279,21 +284,22 @@ class NetconfSessionImplTest { every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws InterruptedException("interrupted") every { netconfSessionSpy.checkAndReestablish() } just Runs - //call the method + // call the method netconfSessionSpy.syncRpc("0", "0") } } @Test fun `syncRpc throws NetconfException if TimeoutException is caught`() { - val expectedExceptionMsg = "$deviceInfo: Timed out while waiting for reply for request $formattedRequest after ${deviceInfo.replyTimeout} sec." + val expectedExceptionMsg = + "$deviceInfo: Timed out while waiting for reply for request $formattedRequest after ${deviceInfo.replyTimeout} sec." assertFailsWith(exceptionClass = NetconfException::class, message = expectedExceptionMsg) { val netconfSessionSpy = spyk(netconfSession) val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg) every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet every { netconfCommunicator.getFutureFromSendMessage(any(), any(), any()) } throws TimeoutException("timed out") every { netconfSessionSpy.checkAndReestablish() } just Runs - //call the method + // call the method netconfSessionSpy.syncRpc("0", "0") } } @@ -306,11 +312,11 @@ 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) - //call the method + // call the method netconfSessionSpy.syncRpc("0", "0") } } @@ -323,12 +329,12 @@ 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 + // call the method netconfSessionSpy.syncRpc("0", "0") - //make sure replies are cleared... + // make sure replies are cleared... verify(exactly = 1) { netconfSessionSpy.clearReplies() } verify(exactly = 1) { netconfSessionSpy.clearErrorReplies() } } @@ -340,12 +346,12 @@ class NetconfSessionImplTest { every { netconfSessionSpy.checkAndReestablish() } just Runs val futureRet: CompletableFuture<String> = CompletableFuture.completedFuture(futureMsg) every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet - //run the method + // run the method val rpcResultFuture = netconfSessionSpy.asyncRpc("0", "0") every { netconfSessionSpy.checkAndReestablish() } just Runs - //make sure the future gets resolved + // make sure the future gets resolved assertTrue { rpcResultFuture.get() == futureMsg } - //make sure that clearReplies wasn't called (reestablishConnection check) + // make sure that clearReplies wasn't called (reestablishConnection check) verify(exactly = 0) { netconfSessionSpy.clearReplies() } } @@ -357,7 +363,7 @@ class NetconfSessionImplTest { throw Exception("blah") } every { netconfCommunicator.sendMessage(any(), any()) } returns futureRet - //run the method + // run the method val rpcResultFuture = netconfSessionSpy.asyncRpc("0", "0") every { netconfSessionSpy.checkAndReestablish() } just Runs val e = assertFailsWith(exceptionClass = ExecutionException::class, message = futureMsg) { @@ -386,11 +392,11 @@ class NetconfSessionImplTest { fun `startSession tries to connect to user supplied device`() { every { mockSshClient.start() } just Runs every { mockSshClient.properties } returns hashMapOf<String, Any>() - //setup slots to capture values from the invocations + // setup slots to capture values from the invocations val userSlot = CapturingSlot<String>() val ipSlot = CapturingSlot<String>() val portSlot = CapturingSlot<Int>() - //create a future that succeeded + // create a future that succeeded val succeededFuture = DefaultConnectFuture(Any(), Any()) succeededFuture.value = mockClientSession every { mockSshClient.connect(capture(userSlot), capture(ipSlot), capture(portSlot)) } returns succeededFuture @@ -398,9 +404,9 @@ class NetconfSessionImplTest { every { netconfSessionSpy["authSession"]() as Unit } just Runs every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs netconfSessionSpy.setClient(mockSshClient) - //RUN + // RUN netconfSessionSpy.connect() - //Verify + // Verify verify { mockSshClient.connect(deviceInfo.username, deviceInfo.ipAddress, deviceInfo.port) } assertEquals(deviceInfo.username, userSlot.captured) assertEquals(deviceInfo.ipAddress, ipSlot.captured) @@ -411,11 +417,11 @@ class NetconfSessionImplTest { @Test fun `authSession throws exception if ClientSession is not AUTHED`() { assertFailsWith(exceptionClass = NetconfException::class) { - //after client session connects, + // after client session connects, every { mockSshClient.start() } just Runs every { mockSshClient.properties } returns hashMapOf<String, Any>() val succeededAuthFuture = DefaultAuthFuture(Any(), Any()) - succeededAuthFuture.value = true //AuthFuture's value is Boolean + succeededAuthFuture.value = true // AuthFuture's value is Boolean val passSlot = CapturingSlot<String>() every { mockClientSession.addPasswordIdentity(capture(passSlot)) } just Runs every { mockClientSession.auth() } returns succeededAuthFuture @@ -423,21 +429,21 @@ 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) - //RUN + // RUN netconfSessionSpy.connect() } } - //common mock initializer for more weird tests. - private fun setupOpenChannelMocks(): Unit { + // common mock initializer for more weird tests. + private fun setupOpenChannelMocks() { every { mockSshClient.start() } just Runs every { mockSshClient.properties } returns hashMapOf<String, Any>() val succeededAuthFuture = DefaultAuthFuture(Any(), Any()) - succeededAuthFuture.value = true //AuthFuture's value is Boolean + succeededAuthFuture.value = true // AuthFuture's value is Boolean val passSlot = CapturingSlot<String>() every { mockClientSession.addPasswordIdentity(capture(passSlot)) } just Runs every { mockClientSession.auth() } returns succeededAuthFuture @@ -445,9 +451,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 @@ -456,7 +464,7 @@ class NetconfSessionImplTest { @Test fun `authSession opensChannel if ClientSession is AUTHED and session can be opened`() { - //after client session connects, make sure the client receives authentication + // after client session connects, make sure the client receives authentication setupOpenChannelMocks() val channelFuture = DefaultOpenFuture(Any(), Any()) channelFuture.value = true @@ -471,17 +479,16 @@ class NetconfSessionImplTest { every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs every { netconfSessionSpy["setupHandler"]() as Unit } just Runs netconfSessionSpy.setClient(mockSshClient) - //Run + // Run netconfSessionSpy.connect() - //Verify + // Verify verify { mockSubsystem.open() } } - @Test fun `authSession throws NetconfException if ClientSession is AUTHED but channelFuture timed out or not open`() { assertFailsWith(exceptionClass = NetconfException::class) { - //after client session connects, make sure the client receives authentication + // after client session connects, make sure the client receives authentication setupOpenChannelMocks() val channelFuture = DefaultOpenFuture(Any(), Any()) every { mockSubsystem.open() } returns channelFuture @@ -489,14 +496,13 @@ class NetconfSessionImplTest { every { netconfSessionSpy["setupNewSSHClient"]() as Unit } just Runs every { netconfSessionSpy["setupHandler"]() as Unit } just Runs netconfSessionSpy.setClient(mockSshClient) - //Run + // Run netconfSessionSpy.connect() - //Verify + // Verify verify { mockSubsystem.open() } } } - @Test fun `disconnect closes session, channel, and client`() { every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE @@ -507,16 +513,16 @@ class NetconfSessionImplTest { netconfSessionSpy.setChannel(mockClientChannel) netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setSession(mockClientSession) - //RUN + // RUN netconfSessionSpy.disconnect() - //VERIFY + // VERIFY verify { mockClientSession.close() } verify { mockClientChannel.close() } verify { mockSshClient.close() } } @Test - fun `disconnect wraps IOException if channel doesn't close`() { //this test is equivalent to others + fun `disconnect wraps IOException if channel doesn't close`() { // this test is equivalent to others every { rpcService.closeSession(false) } returns SUCCESSFUL_DEVICE_RESPONSE every { mockClientSession.close() } just Runs every { mockClientChannel.close() } throws IOException("channel doesn't want to close!") @@ -524,9 +530,9 @@ class NetconfSessionImplTest { netconfSessionSpy.setChannel(mockClientChannel) netconfSessionSpy.setClient(mockSshClient) netconfSessionSpy.setSession(mockClientSession) - //RUN + // RUN netconfSessionSpy.disconnect() - //VERIFY + // VERIFY verify { mockClientSession.close() } } } 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 f3817b7fc..ab762e821 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 @@ -16,16 +16,16 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core -import org.junit.Test import io.mockk.every import io.mockk.mockk import io.mockk.verifyAll import org.junit.Before +import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo 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 + // Note: mockk's verifyAll is akin to verify with verifyNoMoreInteractions in Mockito private val netconSession = mockk<NetconfSessionImpl>() @Before @@ -36,7 +36,7 @@ class NetconfSessionListenerImplTest { } @Test - //NetconfReceivedEvent wth DEVICE_UNREGISTERED TYPE should call disconnect() on the NetconfSession + // NetconfReceivedEvent wth DEVICE_UNREGISTERED TYPE should call disconnect() on the NetconfSession fun deviceUnregisteredMessageShouldCallSessionDisconnect() { val netconfSessionListener = NetconfSessionListenerImpl(netconSession) val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_UNREGISTERED) @@ -45,7 +45,7 @@ class NetconfSessionListenerImplTest { } @Test - //NetconfReceivedEvent wth SESSION_CLOSED TYPE should ALSO call disconnect() on the NetconfSession + // NetconfReceivedEvent wth SESSION_CLOSED TYPE should ALSO call disconnect() on the NetconfSession fun sessionClosedMessageShouldCallSesionDisconnect() { val netconfSessionListener = NetconfSessionListenerImpl(netconSession) val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.SESSION_CLOSED) @@ -54,8 +54,8 @@ class NetconfSessionListenerImplTest { } @Test - //NetconfReceivedEvent wth DEVICE_ERROR TYPE should call addDeviceErrorReply() on the NetconfSession - //with the event message payload + // NetconfReceivedEvent wth DEVICE_ERROR TYPE should call addDeviceErrorReply() on the NetconfSession + // with the event message payload fun deviceErrorMessageShouldCallAddDeviceErrorReply() { val netconfSessionListener = NetconfSessionListenerImpl(netconSession) val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_ERROR) @@ -64,7 +64,7 @@ class NetconfSessionListenerImplTest { } @Test - //NetconfReceivedEvent wth DEVICE_REPLY TYPE should call addDeviceReply(messageId, payload) on the NetconfSession + // NetconfReceivedEvent wth DEVICE_REPLY TYPE should call addDeviceReply(messageId, payload) on the NetconfSession fun deviceReplyMessageShouldCallAddDeviceReply() { val netconfSessionListener = NetconfSessionListenerImpl(netconSession) val event: NetconfReceivedEvent = genEventByType(NetconfReceivedEvent.Type.DEVICE_REPLY) @@ -74,14 +74,14 @@ class NetconfSessionListenerImplTest { /** * Helper to generate {@link NetconfReceivedEvent} object based on the {@link NetconfReceivedEvent.Type} - * @param type {@link NetconfReceivedEvent.Type} of event + * @param type {@link NetconfReceivedEvent.Type} of event */ private fun genEventByType(type: NetconfReceivedEvent.Type): NetconfReceivedEvent { return NetconfReceivedEvent( - type, - "messagePayload", - "messageId", - DeviceInfo() + type, + "messagePayload", + "messageId", + DeviceInfo() ) } -}
\ No newline at end of file +} diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt index fcfa12570..cec0fda66 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtilsTest.kt @@ -40,7 +40,7 @@ class NetconfMessageUtilsTest { @Test fun `test getConfig with filterContent parameter null`() { - val outcome = NetconfMessageUtils.getConfig("customMessageId", "customConfigType",null) + val outcome = NetconfMessageUtils.getConfig("customMessageId", "customConfigType", null) val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/getConfig-response-filterContent-null.xml") assertEquals("getConfig return was not correct", expectation, outcome) } @@ -54,16 +54,20 @@ class NetconfMessageUtilsTest { @Test fun `test editConfig with all parameters present`() { - val outcome = NetconfMessageUtils.editConfig("customMessageId", "customConfigType", "customDefaultOperation", - "customNewConfiguration") + val outcome = NetconfMessageUtils.editConfig( + "customMessageId", "customConfigType", "customDefaultOperation", + "customNewConfiguration" + ) val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/editConfig-response-all-parameters.xml") assertEquals("editConfig return was not correct", expectation, outcome) } @Test fun `test editConfig with defaultOperation parameter null`() { - val outcome = NetconfMessageUtils.editConfig("customMessageId", "customConfigType", null, - "customNewConfiguration") + val outcome = NetconfMessageUtils.editConfig( + "customMessageId", "customConfigType", null, + "customNewConfiguration" + ) val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/editConfig-response-defaultOperation-null.xml") assertEquals("editConfig return was not correct", expectation, outcome) } @@ -92,21 +96,24 @@ class NetconfMessageUtilsTest { @Test fun `test commit with confirmed true, persistId empty and persist empty`() { val outcome = NetconfMessageUtils.commit("customMessageId", true, 1, "", "") - val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-true-and-persistId-empty-and-persist-empty.xml") + val expectation = + JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-true-and-persistId-empty-and-persist-empty.xml") assertEquals("commit return was not correct", expectation, outcome) } @Test fun `test commit with confirmed false, persistId non-empty and persist empty`() { val outcome = NetconfMessageUtils.commit("customMessageId", false, 1, "", "customPersistId") - val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-empty-and-persist-not-empty.xml") + val expectation = + JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-empty-and-persist-not-empty.xml") assertEquals("commit return was not correct", expectation, outcome) } @Test fun `test commit with confirmed false, persistId empty and persist non-empty`() { val outcome = NetconfMessageUtils.commit("customMessageId", false, 1, "customPersist", "") - val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-not-empty-and-persist-empty.xml") + val expectation = + JacksonUtils.getClassPathFileContent("netconf-messages/commit-response-confirmed-false-and-persistId-not-empty-and-persist-empty.xml") assertEquals("commit return was not correct", expectation, outcome) } @@ -173,7 +180,7 @@ class NetconfMessageUtilsTest { assertEquals("closeSession return was not correct", expectation, outcome) } - //TODO validateRPCXML + // TODO validateRPCXML @Test fun `test getMsgId with valid message`() { @@ -197,6 +204,5 @@ class NetconfMessageUtilsTest { assertEquals("getMsgId return was not correct", expectation, outcome) } -//TODO validateChunkedFraming - + // TODO validateChunkedFraming } 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 b80dc2d88..0d791c2a6 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,29 +27,28 @@ class RpcMessageUtilsTest { @Test fun getConfig() { - 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>") + 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>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore val filterContent = "Test-Filter-Content" val result = - NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } - @Test fun editConfig() { - 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>") + 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>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -57,7 +56,7 @@ class RpcMessageUtilsTest { val defaultOperation = "Test-Default-Operation" val result = - NetconfMessageUtils.editConfig(messageId, configType, defaultOperation, filterContent).replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.editConfig(messageId, configType, defaultOperation, filterContent).replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) @@ -65,9 +64,9 @@ class RpcMessageUtilsTest { @Test fun validate() { - 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>") + 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>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -81,16 +80,16 @@ class RpcMessageUtilsTest { @Test fun cancelCommit() { 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\">" + - "<cancel-commit>" + - "<persist-id>1234</persist-id>" + - "</cancel-commit></rpc>") + ("<?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>") val messageId = "Test-Message-ID" val cancelCommitPersistId = - NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.cancelCommit(messageId, "1234").replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(cancelCommitPersistId)) Assert.assertEquals(checkString, cancelCommitPersistId) @@ -99,10 +98,10 @@ class RpcMessageUtilsTest { @Test fun cancelCommitNoPersistId() { 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\">" + - "<cancel-commit>" + - "</cancel-commit></rpc>") + ("<?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>") val messageId = "Test-Message-ID" @@ -114,31 +113,30 @@ class RpcMessageUtilsTest { @Test fun commit() { - 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>") + 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>") val messageId = "Test-Message-ID" val commit = NetconfMessageUtils.commit(messageId, false, 0, "", "").replace("[\n\r\t]".toRegex(), "") val commitWithPersistButNotConfirmed = - NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "") + NetconfMessageUtils.commit(messageId, false, 0, "1234", "").replace("[\n\r\t]".toRegex(), "") assertTrue(NetconfMessageUtils.validateRPCXML(commit)) Assert.assertEquals(checkString, commit) Assert.assertEquals(checkString, commitWithPersistButNotConfirmed) - } @Test fun commitPersistId() { 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>" + - "<persist-id>1234</persist-id>" + - "</commit></rpc>") + ("<?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>") val messageId = "Test-Message-ID" @@ -149,8 +147,10 @@ class RpcMessageUtilsTest { try { NetconfMessageUtils.commit(messageId, true, 30, "", "1234").replace("[\n\r\t]".toRegex(), "") } catch (e: NetconfException) { - Assert.assertEquals("Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.", - e.message) + Assert.assertEquals( + "Can't proceed <commit> with both confirmed flag and persistId(1234) specified. Only one should be specified.", + e.message + ) return } @@ -160,13 +160,13 @@ class RpcMessageUtilsTest { @Test fun commitPersist() { 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>" + - "<confirmed/>" + - "<confirm-timeout>30</confirm-timeout>" + - "<persist>1234</persist>" + - "</commit></rpc>") + ("<?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>") val messageId = "Test-Message-ID" @@ -178,8 +178,10 @@ class RpcMessageUtilsTest { try { NetconfMessageUtils.commit(messageId, false, 30, "1234", "1234").replace("[\n\r\t]".toRegex(), "") } catch (e: NetconfException) { - Assert.assertEquals("Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.", - e.message) + Assert.assertEquals( + "Can't proceed <commit> with both persist(1234) and persistId(1234) specified. Only one should be specified.", + e.message + ) return } fail() @@ -187,9 +189,9 @@ class RpcMessageUtilsTest { @Test fun unlock() { - 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>") + 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>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -202,9 +204,9 @@ class RpcMessageUtilsTest { @Test fun deleteConfig() { - 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>") + 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>") val messageId = "Test-Message-ID" val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore @@ -226,9 +228,9 @@ class RpcMessageUtilsTest { @Test fun discardChanges() { - 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>") + 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>") val messageId = "Test-Message-ID" @@ -240,9 +242,9 @@ class RpcMessageUtilsTest { @Test fun lock() { - 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>") + 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>") val messageId = "Test-Message-ID" val configType = NetconfDatastore.CANDIDATE.datastore @@ -271,8 +273,8 @@ 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") @@ -303,19 +305,19 @@ class RpcMessageUtilsTest { } @Test - fun formatRPCRequest(){ + fun formatRPCRequest() { 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" - val capabilities = setOf<String>("hi", "hello","urn:ietf:params:netconf:base:1.1") + val capabilities = setOf<String>("hi", "hello", "urn:ietf:params:netconf:base:1.1") - val result = NetconfMessageUtils.formatRPCRequest(request,messageId,capabilities).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.formatRPCRequest(request, messageId, capabilities).replace("[\n\r\t]".toRegex(), "") Assert.assertEquals(checkString, result) } @@ -329,5 +331,4 @@ class RpcMessageUtilsTest { println("Don't fear \"[Fatal Error] :1:1: Content is not allowed in prolog.\" TODO: adjust logging for NetconfMessageUtils") assertFalse { NetconfMessageUtils.validateRPCXML("really bad XML ~~~input") } } - } |