import org.junit.Assert
import org.junit.Assert.assertTrue
+import org.junit.Ignore
import org.junit.Test
import org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.api.NetconfException
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
import kotlin.test.fail
class RpcMessageUtilsTest {
Assert.assertEquals(checkString, result)
}
+ @Test
+ fun deleteConfigThrowsNetconfExceptionOnRunningDataStore() {
+ assertFailsWith(exceptionClass = NetconfException::class) {
+ val netconfTargetConfig = NetconfDatastore.RUNNING.datastore
+ val msgId = "35"
+ NetconfMessageUtils.deleteConfig(msgId, netconfTargetConfig)
+ }
+ }
+
@Test
fun discardChanges() {
val checkString = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
}
@Test
- fun checkReply(){
+ fun `checkReply should return true on ok msg`() {
assertTrue(NetconfMessageUtils.checkReply("ok"))
}
+ @Test
+ fun `checkReply on rpc-error should return false`() {
+ assertFalse { NetconfMessageUtils.checkReply("something something rpc-error>") }
+ }
+
+ @Test
+ fun `checkReply on null input should return false`() {
+ assertFalse { NetconfMessageUtils.checkReply(null) }
+ }
+
@Test
fun formatRPCRequest(){
val checkString = ("#199" +
val result = NetconfMessageUtils.formatRPCRequest(request,messageId,capabilities).replace("[\n\r\t]".toRegex(), "")
Assert.assertEquals(checkString, result)
-
-
}
+ @Test
+ fun `validateRPCXML on empty input returns false`() {
+ assertFalse { NetconfMessageUtils.validateRPCXML("") }
+ }
-
+ @Test
+ fun `validateRPCXML on bad input returns false`() {
+ 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") }
+ }
}
\ No newline at end of file