diff options
author | Gary Wu <gary.i.wu@huawei.com> | 2017-04-20 11:18:01 -0700 |
---|---|---|
committer | Gary Wu <gary.i.wu@huawei.com> | 2017-04-20 11:18:01 -0700 |
commit | c5d8c4ed78cc7b116783feb0d61572a230fa1a3f (patch) | |
tree | b520140680b81d3d4e0bdb63a5446c9397df7d18 /sli/provider/src/test/java | |
parent | 0ca979112add1fe6c2771676cfb36e90e6410174 (diff) |
Add assertions to SvcLogicExpressionResolverTest
Add JUnit assertions to SvcLogicExpressionResolverTest
so that it actually verifies the evaluated results
vs. the expected values.
Change-Id: I7d17c525e6940e25a994e0fe62d7c4c3d844381b
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'sli/provider/src/test/java')
-rw-r--r-- | sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java index d35d93c..6181548 100644 --- a/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java +++ b/sli/provider/src/test/java/org/openecomp/sdnc/sli/provider/SvcLogicExpressionResolverTest.java @@ -35,6 +35,7 @@ import org.openecomp.sdnc.sli.provider.SvcLogicExpressionResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import junit.framework.Assert; import junit.framework.TestCase; public class SvcLogicExpressionResolverTest extends TestCase { @@ -50,21 +51,22 @@ public class SvcLogicExpressionResolverTest extends TestCase { try { - String testExpr = null; SvcLogicContext ctx = new SvcLogicContext(); SvcLogicGraph graph = new SvcLogicGraph(); SvcLogicNode node = new SvcLogicNode(1, "return", graph); graph.setRootNode(node); - - while ((testExpr = testsReader.readLine()) != null) { - testExpr = testExpr.trim(); - if (testExpr.startsWith("#")) + + String line = null; + int lineNo = 0; + while ((line = testsReader.readLine()) != null) { + ++lineNo; + if (line.startsWith("#")) { - testExpr = testExpr.substring(1).trim(); + String testExpr = line.trim().substring(1).trim(); String[] nameValue = testExpr.split("="); String name = nameValue[0].trim(); String value = nameValue[1].trim(); - + if (name.startsWith("$")) { LOG.info("Setting context attribute "+name+" = "+value); @@ -80,6 +82,12 @@ public class SvcLogicExpressionResolverTest extends TestCase { } else { + // if the line contains #, what comes before is the expression to evaluate, and what comes after + // is the expected value + String[] substrings = line.split("#"); + String expectedValue = substrings.length > 1 ? substrings[1].trim() : null; + String testExpr = substrings[0].trim(); + LOG.info("Parsing expression "+testExpr); SvcLogicExpression expr = SvcLogicExpressionFactory.parse(testExpr); if (expr == null) @@ -96,7 +104,10 @@ public class SvcLogicExpressionResolverTest extends TestCase { } else { - LOG.info("Expression "+testExpr+" evaluates to "+exprValue); + LOG.info("Expression " + testExpr + " evaluates to " + exprValue); + if (expectedValue != null) { + Assert.assertEquals("Line " + lineNo + ": " + testExpr, expectedValue, exprValue); + } } } } |