diff options
author | 2021-03-14 19:13:35 -0400 | |
---|---|---|
committer | 2021-03-19 19:47:40 +0000 | |
commit | 8ee06cef9a605d8220a6c5ebafc5da8eb7491f8d (patch) | |
tree | e3f3a6892b23b014f8f51995eb326ad1143f2fb6 /ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test | |
parent | 95de87b0f902a55f1313403a5954b394f022e519 (diff) |
Prohibit cycles in imperative workflows
Issue-ID: CCSDK-3221
Change-Id: I767003dde40c0fc53a673c4a41cb2430624d7b04
Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test')
-rw-r--r-- | ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt index 86cb473ae..ba4115f02 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt @@ -18,7 +18,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core import org.junit.Test import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel +import kotlin.test.assertFalse import kotlin.test.assertNotNull +import kotlin.test.assertTrue class GraphExtensionFunctionsTest { @@ -34,4 +36,73 @@ class GraphExtensionFunctionsTest { val nodePath = graph.nodes["p"]!!.neighbors(EdgeLabel.SUCCESS) assertNotNull(nodePath, "failed to nodePath from graph for 'p' node 'SUCCESS' label") } + + @Test + fun `isAcyclic should return false`() { + assertFalse( + """[ + assign>deploy/SUCCESS, + deploy>assign/FAILURE + ]""".toGraph().isAcyclic() + ) + + assertFalse( + """[ + assign>deploy/SUCCESS, + deploy>recover/FAILURE, + recover>deploy/SUCCESS + ]""".toGraph().isAcyclic() + ) + + assertFalse( + """[ + assign>deploy/SUCCESS, + assign>recover/FAILURE, + recover>deploy/SUCCESS, + deploy>finalize/SUCCESS, + deploy>recover/FAILURE + ]""".toGraph().isAcyclic() + ) + + assertFalse( + """[ + A>B/SUCCESS, + A>C/SUCCESS, + B>E/SUCCESS, + B>D/FAILURE, + D>B/FAILURE, + C>E/SUCCESS + ]""".toGraph().isAcyclic() + ) + } + + @Test + fun `isAcyclic should return true`() { + assertTrue( + """[ + assign>deploy/SUCCESS, + deploy>recover/FAILURE + ]""".toGraph().isAcyclic() + ) + + assertTrue( + """[ + A>C/SUCCESS, + A>B/FAILURE, + C>B/SUCCESS + ]""".toGraph().isAcyclic() + ) + + assertTrue( + """[ + assign>execute1/SUCCESS, + assign>execute2/SUCCESS, + execute1>finalize/SUCCESS, + execute2>finalize/SUCCESS, + execute1>cleanup/FAILURE, + execute2>cleanup/FAILURE, + finalize>cleanup/SUCCESS + ]""".toGraph().isAcyclic() + ) + } } |