Skip to content

Commit 9db1272

Browse files
committed
added JUnit tests for evalXMLExpressionList (Issue #948)
1 parent 1266ba2 commit 9db1272

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestEvaluateWorkflowResult.java

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ public void testEvaluateWorkflowResultWithGarbage() {
508508
}
509509

510510
/**
511-
* This test evaluates a event XML result by calling the the method
511+
* This test evaluates a event XML result by calling the method
512512
* evalWorkflowResultXMLTag
513513
*
514514
* @throws PluginException
@@ -540,4 +540,84 @@ public void testEvaluateWorkflowResultXML() {
540540
}
541541

542542
}
543+
544+
/**
545+
* This test evaluates a event result with no XML text by calling the method
546+
* evalWorkflowResultXMLTag. We expect an empty List of ItemCollections
547+
*
548+
* @throws PluginException
549+
*/
550+
@Test
551+
public void testEvaluateWorkflowResultXMLWithPlainText() {
552+
ItemCollection activityEntity = new ItemCollection();
553+
554+
try {
555+
activityEntity.replaceItemValue("txtActivityResult",
556+
" Some Kind of Data, but no XML ");
557+
List<ItemCollection> result = workflowEngine.workflowService.evalWorkflowResultXML(
558+
activityEntity,
559+
"imixs-config", "CONFIG", new ItemCollection(), false);
560+
assertNotNull(result);
561+
562+
assertEquals(0, result.size());
563+
564+
} catch (PluginException e) {
565+
e.printStackTrace();
566+
fail();
567+
}
568+
569+
}
570+
571+
/**
572+
* This test evaluates a XML string with the method evalWorkflowResultXMLTag. We
573+
* expect a List of ItemCollection with one element.
574+
*
575+
* @throws PluginException
576+
*/
577+
@Test
578+
public void testEvalXMLExpressionList() {
579+
try {
580+
String xml = " <imixs-config name=\"CONFIG\">\n"
581+
+ " <items>abc</items>\n"
582+
+ " <mode>123</mode>\n"
583+
+ " </imixs-config>";
584+
List<ItemCollection> result = workflowEngine.workflowService.evalXMLExpressionList(
585+
xml,
586+
"imixs-config", "CONFIG", new ItemCollection(), false);
587+
assertNotNull(result);
588+
assertEquals(1, result.size());
589+
590+
ItemCollection config = result.get(0);
591+
assertNotNull(config);
592+
assertEquals("abc", config.getItemValueString("items"));
593+
594+
} catch (PluginException e) {
595+
e.printStackTrace();
596+
fail();
597+
}
598+
599+
}
600+
601+
/**
602+
* This test evaluates a plain text string with the method
603+
* evalWorkflowResultXMLTag. We expect an empty List of ItemCollection
604+
*
605+
* @throws PluginException
606+
*/
607+
@Test
608+
public void testEvalXMLExpressionListWithPlainText() {
609+
try {
610+
String xml = " something <!-- some more --> nothing";
611+
List<ItemCollection> result = workflowEngine.workflowService.evalXMLExpressionList(
612+
xml,
613+
"imixs-config", "CONFIG", new ItemCollection(), false);
614+
assertNotNull(result);
615+
assertEquals(0, result.size());
616+
} catch (PluginException e) {
617+
e.printStackTrace();
618+
fail();
619+
}
620+
621+
}
622+
543623
}

0 commit comments

Comments
 (0)