diff options
author | Brinda Santh Muthuramalingam <brindasanth@in.ibm.com> | 2019-08-28 02:55:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-08-28 02:55:10 +0000 |
commit | f5c26aa8745348cc54ad12c47d67cc13f0a56740 (patch) | |
tree | 86729852eebb8ea1e294e8c336713fdd2c9b0fbb /ms/blueprintsprocessor/functions/netconf-executor/src/test | |
parent | 49df3104ad130b17d5c8ba1df0d436386662c922 (diff) | |
parent | 6dec3fb775386767a7b4008b0862e6a32247bb97 (diff) |
Merge "Add Get function in Netconf execution service for operational commands"
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/test')
3 files changed, 55 insertions, 2 deletions
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 eb32c546b..7b0b799bc 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 @@ -1,5 +1,6 @@ /* * Copyright © 2019 Bell Canada + * Modifications Copyright (c) 2019 IBM * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,13 +82,34 @@ class NetconfRpcServiceImplTest { } @Test + fun `get completes normally`() { + val netconfRpcService = NetconfRpcServiceImpl(deviceInfo) + netconfRpcService.setNetconfSession(mockNetconfSession) + val spy = spyk(netconfRpcService) + every { spy.asyncRpc(any(), any()) } returns successfulDeviceResponse + val getRpcrResult = spy.get(someString) + assertEquals(successfulDeviceResponse, getRpcrResult) + } + + @Test + fun `get on error sets DeviceResponse status to FAILURE`() { + val netconfRpcService = NetconfRpcServiceImpl(deviceInfo) + netconfRpcService.setNetconfSession(mockNetconfSession) + val spy = spyk(netconfRpcService) + every { spy.asyncRpc(any(), any()) } throws IOException("Some IO exception...") + val getRpcResult = spy.get(someString) + assertEquals(failedDeviceResponse.status, getRpcResult.status) + assertTrue { getRpcResult.errorMessage!!.contains("failed in 'get' command") } + } + + @Test fun `getConfig completes normally`() { val netconfRpcService = NetconfRpcServiceImpl(deviceInfo) netconfRpcService.setNetconfSession(mockNetconfSession) val spy = spyk(netconfRpcService) every { spy.asyncRpc(any(), any()) } returns successfulDeviceResponse - val invokeRpcrResult = spy.getConfig(someString) - assertEquals(successfulDeviceResponse, invokeRpcrResult) + val getConfigRpcResult = spy.getConfig(someString) + assertEquals(successfulDeviceResponse, getConfigRpcResult) } @Test 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 e24659d1d..33135e30f 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 @@ -1,3 +1,19 @@ +/* + * Copyright © 2019 Bell Canada + * Modifications Copyright (c) 2019 IBM + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils import org.junit.Assert.* @@ -16,6 +32,13 @@ class NetconfMessageUtilsTest { } @Test + fun `test get operational`() { + val outcome = NetconfMessageUtils.get("customMessageId", "customConfigType") + val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/get-response.xml") + assertEquals("get return was not correct", expectation, outcome) + } + + @Test fun `test getConfig with filterContent parameter null`() { val outcome = NetconfMessageUtils.getConfig("customMessageId", "customConfigType",null) val expectation = JacksonUtils.getClassPathFileContent("netconf-messages/getConfig-response-filterContent-null.xml") diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/netconf-messages/get-response.xml b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/netconf-messages/get-response.xml new file mode 100644 index 000000000..d9fd72e9c --- /dev/null +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/netconf-messages/get-response.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rpc message-id="customMessageId" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> +<get> +<filter type="subtree"> +customConfigType +</filter> +</get> +</rpc>
\ No newline at end of file |