2 * Copyright © 2019 Bell Canada
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api
19 import org.junit.Assert.assertFalse
20 import org.junit.Assert.assertTrue
22 import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
24 class NetconfMessageTest {
26 fun testSuccessfulDeviceResponse() {
27 val dr: DeviceResponse = genSuccessfulEmptyDeviceResponse()
28 assertTrue(dr.isSuccess())
30 val dr2: DeviceResponse = genSuccessfulEmptyDeviceResponse()
31 dr2.errorMessage = "some error msg"
32 assertFalse(dr2.isSuccess())
36 fun testUnsuccessfulDeviceResponse() {
37 val dr: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
38 assertFalse(dr.isSuccess())
40 // case 2: Success, but with error message
41 val dr2: DeviceResponse = genUnsuccessfulEmptyDeviceResponse()
42 dr2.errorMessage = "Some error message."
43 assertFalse(dr2.isSuccess())
46 // helper function to generate a device response
47 private fun genSuccessfulEmptyDeviceResponse(): DeviceResponse {
48 return DeviceResponse().apply {
49 status = RpcStatus.SUCCESS
56 private fun genUnsuccessfulEmptyDeviceResponse(): DeviceResponse {
57 return DeviceResponse().apply {
58 status = RpcStatus.FAILURE