Skip to content

Commit

Permalink
MID-7942:fix for custom 'null' function parameter when mP can't deter…
Browse files Browse the repository at this point in the history
…mine type of parameter
  • Loading branch information
skublik committed May 19, 2022
1 parent 78b9102 commit 79e1c99
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ private TypedValue<?> convertInput(Map.Entry<String, Object> entry, ExpressionTy

Class<?> valueClass;
if (value == null) {
valueClass = expressionParameterClass;
if (expressionParameterClass == null) {
valueClass = Object.class;
} else {
valueClass = expressionParameterClass;
}
} else {
valueClass = value.getClass();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ public void testCustomFunctionUntyped() throws Exception {
assertExecuteScriptExpressionString(variables, "s-1");
}

@Test
public void testCustomFunctionUntypedNullValue() throws Exception {
VariablesMap variables = VariablesMap.create(prismContext,
"var1", null, PrimitiveType.STRING,
"var2", null, PrimitiveType.STRING);

assertExecuteScriptExpressionString(variables, "null-null");
}

@NotNull
private PrismContainerValue<Containerable> createCustomValue() throws SchemaException {
return createCustomContainer().getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<script xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
<code>
import com.evolveum.midpoint.prism.path.ItemPath

pcv = functionLibrary.execute("untyped", [container: var1, containerValue: var2])
pcv?.findProperty(ItemPath.create('stringValue'))?.getRealValue() + '-' +
pcv?.findProperty(ItemPath.create('intValue'))?.getRealValue()
</code>
</script>

0 comments on commit 79e1c99

Please sign in to comment.