-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug when NullValue is nested inside ObjectValue #91
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,6 @@ public Object parseValue(Object input) throws CoercingParseValueException { | |
@Override | ||
public Object parseLiteral(Object input) throws CoercingParseLiteralException { | ||
// on purpose - object scalars can be null | ||
//noinspection ConstantConditions | ||
return parseLiteral(input, Collections.emptyMap()); | ||
} | ||
|
||
|
@@ -94,7 +93,12 @@ public Object parseLiteral(Object input, Map<String, Object> variables) throws C | |
List<ObjectField> values = ((ObjectValue) input).getObjectFields(); | ||
Map<String, Object> parsedValues = new LinkedHashMap<>(); | ||
values.forEach(fld -> { | ||
Object parsedValue = parseLiteral(fld.getValue(), variables); | ||
Object parsedValue; | ||
if (fld.getValue() instanceof NullValue) { // Nested NullValue inside ObjectValue | ||
parsedValue = null; | ||
} else { | ||
parsedValue = parseLiteral(fld.getValue(), variables); | ||
} | ||
parsedValues.put(fld.getName(), parsedValue); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The overall Object value is guaranteed not to be |
||
}); | ||
return parsedValues; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,10 @@ class ObjectScalarTest extends Specification { | |
childFl2 : mkVarRef("varRef1") | ||
] as Map<String, Value>) | ||
] as Map<String, Value>) | [fld1: "s", fld2: 99, fld3: [childFld1: "child1", childFl2: "value1"]] | ||
|
||
mkObjectValue([ | ||
field1: mkNullValue() | ||
] as Map<String, Value>) | [field1: null] // Nested NullValue inside ObjectValue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails with the old behaviour, and passes with the new behaviour |
||
} | ||
|
||
@Unroll | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDE said this is redundant