Skip to content

Commit

Permalink
Add named ref function call working for metaschema-framework#283
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-gsa committed Dec 29, 2024
1 parent fd3ca06 commit 7d94dae
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import gov.nist.secauto.metaschema.core.metapath.function.IFunction;
import gov.nist.secauto.metaschema.core.metapath.item.IItem;
import gov.nist.secauto.metaschema.core.metapath.item.ISequence;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IAnyAtomicItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IBooleanItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IStringItem;
import gov.nist.secauto.metaschema.core.metapath.item.atomic.IUuidItem;
Expand Down Expand Up @@ -308,6 +309,24 @@ void testNamedFunctionRefNotFound(
: null);
}

static Stream<Arguments> testNamedFunctionRefCall() {
return Stream.of(
Arguments.of("fn:string#1(1)", string(String.valueOf(1))));
}

@ParameterizedTest
@MethodSource("testNamedFunctionRefCall")
void testNamedFunctionRefCall(
@NonNull String metapath,
@NonNull IItem expectedResult) {
StaticContext staticContext = StaticContext.builder().build();
DynamicContext dynamicContext = new DynamicContext(staticContext);

IItem result = IMetapathExpression.compile(metapath, staticContext)
.evaluateAs(null, IMetapathExpression.ResultType.ITEM, dynamicContext);
assertEquals(expectedResult, result);
}

static Stream<Arguments> testComparison() {
return Stream.of(
Arguments.of("A = B", GeneralComparison.class, ComparisonFunctions.Operator.EQ),
Expand Down

0 comments on commit 7d94dae

Please sign in to comment.