Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
fix: fix try-catch on-when expression object
Browse files Browse the repository at this point in the history
Fixes: #554
  • Loading branch information
igarashitm committed Mar 24, 2023
1 parent 6bb67a0 commit d92edf5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void expressionObject() throws Exception {
System.out.println(yaml2);
List<Object> parsed = new Yaml().load(yaml2);
List<Object> steps = (List<Object>) ((Map)((Map)parsed.get(0)).get("from")).get("steps");
assertEquals(19, steps.size());
assertEquals(20, steps.size());
var choice = (Map<String, Object>) ((Map<String, Object>) steps.get(0)).get("choice");
var when0 = (Map<String, Object>) ((List<Object>)choice.get("when")).get(0);
assertExpression("choice", "simple", when0);
Expand Down Expand Up @@ -376,6 +376,10 @@ void expressionObject() throws Exception {
assertExpression("transform", "jq", transform);
var validate = (Map<String, Object>) ((Map<String, Object>) steps.get(18)).get("validate");
assertExpression("validate", "simple", validate);
var dotry = (Map<String, Object>) ((Map<String, Object>) steps.get(19)).get("do-try");
var docatch0 = (Map<String, Object>) ((List<Object>) dotry.get("do-catch")).get(0);
var onwhen = (Map<String, Object>) docatch0.get("on-when");
assertExpression("on-when", "simple", onwhen);
}

private void assertExpression(String name, String syntax, Map<String, Object> step) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,15 @@
expression:
simple:
expression: validate
- do-try:
steps: [ ]
do-catch:
- exception:
- java.lang.Exception
on-when:
expression:
simple:
expression: on-when
steps: [ ]
do-finally:
steps: [ ]
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ protected void setPropertiesFromMap(final Map map, final Expression expression)
expression.setResultType(String.valueOf(map.get(RESULT_TYPE2)));
}
if (map.containsKey(EXPRESSION_LABEL) && map.get(EXPRESSION_LABEL) != null) {
expression.setExpression((Expression) map.get(EXPRESSION_LABEL));
Object nested = map.get(EXPRESSION_LABEL);
Expression nestedExpression =
nested instanceof Expression ne ? ne : new Expression(nested);
expression.setExpression(nestedExpression);
}
if (map.containsKey("id") && map.get("id") != null) {
expression.setId(String.valueOf(map.get("id")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ protected void setPropertiesFromMap(final Map map, final ScriptExpression expres
expression.setResultType(String.valueOf(map.get(RESULT_TYPE2)));
}
if (map.containsKey(EXPRESSION_LABEL) && map.get(EXPRESSION_LABEL) != null) {
expression.setExpression((ScriptExpression) map.get(EXPRESSION_LABEL));
Object nested = map.get(EXPRESSION_LABEL);
ScriptExpression nestedExpression =
nested instanceof ScriptExpression ne ? ne : new ScriptExpression(nested);
expression.setExpression(nestedExpression);
}
if (map.containsKey("id") && map.get("id") != null) {
expression.setId(String.valueOf(map.get("id")));
Expand Down

0 comments on commit d92edf5

Please sign in to comment.