diff --git a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel index eab664280..3cd371f55 100644 --- a/runtime/src/main/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/main/java/dev/cel/runtime/BUILD.bazel @@ -244,6 +244,7 @@ java_library( ":type_resolver", "//common/annotations", "//common/types", + "//common/types:default_type_provider", "//common/types:type_providers", "//common/values", "@maven//:com_google_errorprone_error_prone_annotations", @@ -665,6 +666,7 @@ java_library( "//runtime/standard:string", "//runtime/standard:subtract", "//runtime/standard:timestamp", + "//runtime/standard:type", "//runtime/standard:uint", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", @@ -723,6 +725,7 @@ cel_android_library( "//runtime/standard:string_android", "//runtime/standard:subtract_android", "//runtime/standard:timestamp_android", + "//runtime/standard:type_android", "//runtime/standard:uint_android", "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", diff --git a/runtime/src/main/java/dev/cel/runtime/CelLiteRuntimeImpl.java b/runtime/src/main/java/dev/cel/runtime/CelLiteRuntimeImpl.java index 46f25ce02..d5a376788 100644 --- a/runtime/src/main/java/dev/cel/runtime/CelLiteRuntimeImpl.java +++ b/runtime/src/main/java/dev/cel/runtime/CelLiteRuntimeImpl.java @@ -189,17 +189,24 @@ public CelLiteRuntime build() { } } + CelTypeProvider celTypeProvider = DefaultTypeProvider.getInstance(); + if (this.celTypeProvider != null) { + celTypeProvider = + new CelTypeProvider.CombinedCelTypeProvider(celTypeProvider, this.celTypeProvider); + } + ImmutableMap.Builder functionBindingsBuilder = ImmutableMap.builder(); ImmutableSet standardFunctions = standardFunctionBuilder.build(); - if (!standardFunctions.isEmpty()) { - for (CelStandardFunction standardFunction : standardFunctions) { - ImmutableSet standardFunctionBinding = - standardFunction.newFunctionBindings(celOptions, runtimeEquality); - for (CelFunctionBinding func : standardFunctionBinding) { - functionBindingsBuilder.put(func.getOverloadId(), func); - } + for (CelStandardFunction standardFunction : standardFunctions) { + for (CelFunctionBinding func : + standardFunction.newFunctionBindings( + celOptions, + runtimeEquality, + celTypeProvider, + celValueProvider.celValueConverter())) { + functionBindingsBuilder.put(func.getOverloadId(), func); } } @@ -222,12 +229,6 @@ public CelLiteRuntime build() { func.getDefinition()); }); - CelTypeProvider celTypeProvider = DefaultTypeProvider.getInstance(); - if (this.celTypeProvider != null) { - celTypeProvider = - new CelTypeProvider.CombinedCelTypeProvider(celTypeProvider, this.celTypeProvider); - } - ProgramPlanner planner = ProgramPlanner.newPlanner( celTypeProvider, diff --git a/runtime/src/main/java/dev/cel/runtime/CelStandardFunctions.java b/runtime/src/main/java/dev/cel/runtime/CelStandardFunctions.java index c9fd4a50e..e3eb2ee9e 100644 --- a/runtime/src/main/java/dev/cel/runtime/CelStandardFunctions.java +++ b/runtime/src/main/java/dev/cel/runtime/CelStandardFunctions.java @@ -105,6 +105,7 @@ import dev.cel.runtime.standard.SubtractOperator.SubtractOverload; import dev.cel.runtime.standard.TimestampFunction; import dev.cel.runtime.standard.TimestampFunction.TimestampOverload; +import dev.cel.runtime.standard.TypeFunction; import dev.cel.runtime.standard.UintFunction; import dev.cel.runtime.standard.UintFunction.UintOverload; import java.util.Collection; @@ -186,6 +187,7 @@ public final class CelStandardFunctions { StringFunction.create(), SubtractOperator.create(), TimestampFunction.create(), + TypeFunction.create(), UintFunction.create(), NotStrictlyFalseFunction.create()); diff --git a/runtime/src/main/java/dev/cel/runtime/DescriptorTypeResolver.java b/runtime/src/main/java/dev/cel/runtime/DescriptorTypeResolver.java index 3d5208e2e..263c5dea3 100644 --- a/runtime/src/main/java/dev/cel/runtime/DescriptorTypeResolver.java +++ b/runtime/src/main/java/dev/cel/runtime/DescriptorTypeResolver.java @@ -21,6 +21,7 @@ import dev.cel.common.annotations.Internal; import dev.cel.common.types.CelType; import dev.cel.common.types.CelTypeProvider; +import dev.cel.common.types.DefaultTypeProvider; import dev.cel.common.types.StructTypeReference; import dev.cel.common.types.TypeType; import dev.cel.common.values.CelValueConverter; @@ -89,7 +90,8 @@ public TypeType resolveObjectType(Object obj, CelType typeCheckedType) { private DescriptorTypeResolver( @Nullable CelTypeProvider typeProvider, CelValueConverter celValueConverter) { - super(celValueConverter); + super( + typeProvider != null ? typeProvider : DefaultTypeProvider.getInstance(), celValueConverter); this.typeProvider = typeProvider; } } diff --git a/runtime/src/main/java/dev/cel/runtime/TypeResolver.java b/runtime/src/main/java/dev/cel/runtime/TypeResolver.java index 531641d2e..f44ddb727 100644 --- a/runtime/src/main/java/dev/cel/runtime/TypeResolver.java +++ b/runtime/src/main/java/dev/cel/runtime/TypeResolver.java @@ -28,6 +28,7 @@ import com.google.protobuf.Timestamp; import dev.cel.common.annotations.Internal; import dev.cel.common.types.CelType; +import dev.cel.common.types.CelTypeProvider; import dev.cel.common.types.ListType; import dev.cel.common.types.MapType; import dev.cel.common.types.OptionalType; @@ -55,10 +56,12 @@ @Internal public class TypeResolver { + private final CelTypeProvider celTypeProvider; private final CelValueConverter celValueConverter; - static TypeResolver create(CelValueConverter celValueConverter) { - return new TypeResolver(celValueConverter); + public static TypeResolver create( + CelTypeProvider celTypeProvider, CelValueConverter celValueConverter) { + return new TypeResolver(celTypeProvider, celValueConverter); } // Sentinel runtime value representing the special "type" ident. This ensures following to be @@ -121,11 +124,7 @@ TypeType adaptType(CelType typeCheckedType) { } } - Optional resolveWellKnownObjectType(Object obj) { - return findWellKnownObjectType(obj); - } - - private static Optional findWellKnownObjectType(Object obj) { + static Optional resolveWellKnownObjectType(Object obj) { if (obj instanceof TypeType) { return Optional.of(RUNTIME_TYPE_TYPE); } @@ -157,7 +156,7 @@ private static Optional findWellKnownObjectType(Object obj) { */ public static String resolveTypeName(Object obj) { checkNotNull(obj); - Optional resolvedType = findWellKnownObjectType(obj); + Optional resolvedType = resolveWellKnownObjectType(obj); if (!resolvedType.isPresent()) { resolvedType = resolveExtendableObjectType(obj.getClass()); } @@ -195,11 +194,10 @@ public TypeType resolveObjectType(Object obj, CelType typeCheckedType) { return wellKnownTypeType.get(); } - if (celValueConverter != null) { - Object celVal = celValueConverter.toRuntimeValue(obj); - if (celVal instanceof CelValue) { - return TypeType.create(((CelValue) celVal).celType()); - } + Object celVal = celValueConverter.toRuntimeValue(obj); + if (celVal instanceof CelValue) { + CelType celType = ((CelValue) celVal).celType(); + return TypeType.create(celTypeProvider.findType(celType.name()).orElse(celType)); } if (obj instanceof MessageLiteOrBuilder) { @@ -234,7 +232,8 @@ private static CelType adaptStructType(StructType typeOfType) { return newTypeOfType; } - protected TypeResolver(CelValueConverter celValueConverter) { + TypeResolver(CelTypeProvider celTypeProvider, CelValueConverter celValueConverter) { + this.celTypeProvider = checkNotNull(celTypeProvider); this.celValueConverter = checkNotNull(celValueConverter); } } diff --git a/runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel b/runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel index 3e6e5137a..e801158c2 100644 --- a/runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel +++ b/runtime/src/main/java/dev/cel/runtime/standard/BUILD.bazel @@ -17,6 +17,8 @@ java_library( deps = [ ":standard_overload", "//common:options", + "//common/types:type_providers", + "//common/values", "//runtime:function_binding", "//runtime:runtime_equality", "@maven//:com_google_errorprone_error_prone_annotations", @@ -32,6 +34,8 @@ cel_android_library( deps = [ ":standard_overload_android", "//common:options", + "//common/types:type_providers_android", + "//common/values:values_android", "//runtime:function_binding_android", "//runtime:runtime_equality_android", "@maven//:com_google_errorprone_error_prone_annotations", @@ -1407,10 +1411,14 @@ java_library( ":standard_overload", "//common:options", "//common/types", + "//common/types:type_providers", + "//common/values", "//runtime:function_binding", "//runtime:runtime_equality", "//runtime:type_resolver", + "@maven//:com_google_errorprone_error_prone_annotations", "@maven//:com_google_guava_guava", + "@maven//:org_jspecify_jspecify", ], ) @@ -1423,10 +1431,14 @@ cel_android_library( ":standard_function_android", ":standard_overload_android", "//common:options", + "//common/types:type_providers_android", "//common/types:types_android", + "//common/values:values_android", "//runtime:function_binding_android", "//runtime:runtime_equality_android", "//runtime:type_resolver_android", + "@maven//:com_google_errorprone_error_prone_annotations", + "@maven//:org_jspecify_jspecify", "@maven_android//:com_google_guava_guava", ], ) diff --git a/runtime/src/main/java/dev/cel/runtime/standard/CelStandardFunction.java b/runtime/src/main/java/dev/cel/runtime/standard/CelStandardFunction.java index f9f919413..004876e4b 100644 --- a/runtime/src/main/java/dev/cel/runtime/standard/CelStandardFunction.java +++ b/runtime/src/main/java/dev/cel/runtime/standard/CelStandardFunction.java @@ -21,6 +21,8 @@ import com.google.common.collect.ImmutableSet; import com.google.errorprone.annotations.Immutable; import dev.cel.common.CelOptions; +import dev.cel.common.types.CelTypeProvider; +import dev.cel.common.values.CelValueConverter; import dev.cel.runtime.CelFunctionBinding; import dev.cel.runtime.RuntimeEquality; @@ -43,6 +45,14 @@ public ImmutableSet newFunctionBindings( return CelFunctionBinding.fromOverloads(name, overloadBindings); } + public ImmutableSet newFunctionBindings( + CelOptions celOptions, + RuntimeEquality runtimeEquality, + CelTypeProvider celTypeProvider, + CelValueConverter celValueConverter) { + return newFunctionBindings(celOptions, runtimeEquality); + } + CelStandardFunction(String name, ImmutableSet overloads) { checkArgument(!Strings.isNullOrEmpty(name), "Function name must be provided."); checkArgument(!overloads.isEmpty(), "At least 1 overload must be provided."); diff --git a/runtime/src/main/java/dev/cel/runtime/standard/TypeFunction.java b/runtime/src/main/java/dev/cel/runtime/standard/TypeFunction.java index b325c0e9c..fae5489e1 100644 --- a/runtime/src/main/java/dev/cel/runtime/standard/TypeFunction.java +++ b/runtime/src/main/java/dev/cel/runtime/standard/TypeFunction.java @@ -14,27 +14,42 @@ package dev.cel.runtime.standard; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.Immutable; import dev.cel.common.CelOptions; +import dev.cel.common.types.CelTypeProvider; import dev.cel.common.types.SimpleType; import dev.cel.common.types.TypeType; +import dev.cel.common.values.CelValueConverter; import dev.cel.runtime.CelFunctionBinding; import dev.cel.runtime.RuntimeEquality; import dev.cel.runtime.TypeResolver; +import java.util.Arrays; +import org.jspecify.annotations.Nullable; -/** - * Standard function for the {@code type} function. - * - *

The {@code type} function returns the CEL type of its argument. It accepts a - * {@link TypeResolver} so that different runtimes can supply the appropriate resolver (e.g. a - * descriptor-based resolver for full proto, or a base resolver for lite proto). - */ +/** Standard function for the {@code type} function. */ +@Immutable public final class TypeFunction extends CelStandardFunction { + private static final TypeFunction ALL_OVERLOADS = create(TypeOverload.values()); + + private final @Nullable TypeResolver typeResolver; + + public static TypeFunction create() { + return ALL_OVERLOADS; + } - private final TypeResolver typeResolver; + public static TypeFunction create(TypeFunction.TypeOverload... overloads) { + return create(Arrays.asList(overloads)); + } + + public static TypeFunction create(Iterable overloads) { + return new TypeFunction(ImmutableSet.copyOf(overloads), /* typeResolver= */ null); + } public static TypeFunction create(TypeResolver typeResolver) { - return new TypeFunction(typeResolver); + return new TypeFunction(ImmutableSet.copyOf(TypeOverload.values()), checkNotNull(typeResolver)); } /** Overloads for the standard {@code type} function. */ @@ -48,24 +63,38 @@ public CelFunctionBinding newFunctionBinding( // TypeResolver instance. // TODO: Instantiate from CelStandardFunctions. throw new UnsupportedOperationException( - "TypeOverload bindings must be created through TypeFunction.create(TypeResolver)"); + "TypeOverload bindings must be created through TypeFunction"); } } @Override public ImmutableSet newFunctionBindings( CelOptions celOptions, RuntimeEquality runtimeEquality) { + return newFunctionBindings(checkNotNull(typeResolver)); + } + + @Override + public ImmutableSet newFunctionBindings( + CelOptions celOptions, + RuntimeEquality runtimeEquality, + CelTypeProvider celTypeProvider, + CelValueConverter celValueConverter) { + return newFunctionBindings(TypeResolver.create(celTypeProvider, celValueConverter)); + } + + private static ImmutableSet newFunctionBindings(TypeResolver typeResolver) { CelFunctionBinding binding = CelFunctionBinding.from( "type", Object.class, arg -> typeResolver.resolveObjectType(arg, TypeType.create(SimpleType.DYN))); - return CelFunctionBinding.fromOverloads("type", ImmutableSet.of(binding)); + return CelFunctionBinding.fromOverloads("type", binding); } - private TypeFunction(TypeResolver typeResolver) { - super("type", ImmutableSet.copyOf(TypeOverload.values())); + private TypeFunction( + ImmutableSet overloads, @Nullable TypeResolver typeResolver) { + super("type", overloads); this.typeResolver = typeResolver; } } \ No newline at end of file diff --git a/runtime/src/test/java/dev/cel/runtime/BUILD.bazel b/runtime/src/test/java/dev/cel/runtime/BUILD.bazel index 1dbb053c0..61b0cd7a2 100644 --- a/runtime/src/test/java/dev/cel/runtime/BUILD.bazel +++ b/runtime/src/test/java/dev/cel/runtime/BUILD.bazel @@ -58,6 +58,7 @@ java_library( "//common/internal:well_known_proto", "//common/types", "//common/types:cel_v1alpha1_types", + "//common/types:default_type_provider", "//common/types:message_type_provider", "//common/values", "//common/values:cel_byte_string", @@ -101,9 +102,11 @@ java_library( "//runtime:unknown_attributes", "//runtime:unknown_options", "//runtime/standard:add", + "//runtime/standard:equals", "//runtime/standard:not_strictly_false", "//runtime/standard:standard_overload", "//runtime/standard:subtract", + "//runtime/standard:type", "//testing:cel_runtime_flavor", "//testing/protos:message_with_enum_cel_java_proto", "//testing/protos:message_with_enum_java_proto", diff --git a/runtime/src/test/java/dev/cel/runtime/CelLiteRuntimeTest.java b/runtime/src/test/java/dev/cel/runtime/CelLiteRuntimeTest.java index 79de0b70d..f439c1431 100644 --- a/runtime/src/test/java/dev/cel/runtime/CelLiteRuntimeTest.java +++ b/runtime/src/test/java/dev/cel/runtime/CelLiteRuntimeTest.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import com.google.common.primitives.UnsignedLong; import com.google.protobuf.BoolValue; import com.google.protobuf.ByteString; @@ -56,6 +55,9 @@ import dev.cel.expr.conformance.proto3.TestAllTypes.NestedMessage; import dev.cel.expr.conformance.proto3.TestAllTypesCelDescriptor; import dev.cel.parser.CelStandardMacro; +import dev.cel.runtime.standard.EqualsOperator; +import dev.cel.runtime.standard.TypeFunction; +import dev.cel.runtime.standard.TypeFunction.TypeOverload; import dev.cel.testing.testdata.MessageWithEnum; import dev.cel.testing.testdata.MessageWithEnumCelDescriptor; import dev.cel.testing.testdata.MultiFile; @@ -91,17 +93,16 @@ public class CelLiteRuntimeTest { private static final CelLiteRuntime CEL_RUNTIME = CelLiteRuntimeFactory.newLiteRuntimeBuilder() .setStandardFunctions(CelStandardFunctions.ALL_STANDARD_FUNCTIONS) - .setTypeProvider( - ProtoMessageTypeProvider.newBuilder() - .addDescriptors( - ImmutableSet.of( - dev.cel.expr.conformance.proto2.TestAllTypes.getDescriptor(), - TestAllTypes.getDescriptor())) - .build()) .setValueProvider( ProtoMessageLiteValueProvider.newInstance( dev.cel.expr.conformance.proto2.TestAllTypesCelDescriptor.getDescriptor(), TestAllTypesCelDescriptor.getDescriptor())) + .setTypeProvider( + ProtoMessageTypeProvider.newBuilder() + .addFileDescriptors( + dev.cel.expr.conformance.proto2.TestAllTypes.getDescriptor().getFile(), + TestAllTypes.getDescriptor().getFile()) + .build()) .setContainer(CEL_CONTAINER) .build(); @@ -117,9 +118,9 @@ public void messageCreation_emptyMessage() throws Exception { @Test public void messageCreation_fieldsPopulated() throws Exception { CelAbstractSyntaxTree ast = CEL_COMPILER.compile("TestAllTypes{single_int32: 4}").getAst(); + Program program = CEL_RUNTIME.createProgram(ast); - CelEvaluationException e = - assertThrows(CelEvaluationException.class, () -> CEL_RUNTIME.createProgram(ast).eval()); + CelEvaluationException e = assertThrows(CelEvaluationException.class, program::eval); assertThat(e) .hasMessageThat() @@ -226,7 +227,7 @@ public void fieldSelection_repeatedStrings() throws Exception { } @Test - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // Program.eval returns untyped Object. public void fieldSelection_repeatedBoolWrappers() throws Exception { CelAbstractSyntaxTree ast = CEL_COMPILER.compile("msg.repeated_bool_wrapper").getAst(); TestAllTypes msg = @@ -245,7 +246,7 @@ public void fieldSelection_repeatedBoolWrappers() throws Exception { @Test @TestParameters("{expression: 'msg.map_string_int32'}") @TestParameters("{expression: 'msg.map_string_int64'}") - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // Program.eval returns untyped Object. public void fieldSelection_map(String expression) throws Exception { CelAbstractSyntaxTree ast = CEL_COMPILER.compile(expression).getAst(); TestAllTypes msg = @@ -340,7 +341,7 @@ public void fieldSelection_timestamp() throws Exception { } @Test - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // Program.eval returns untyped Object. public void fieldSelection_jsonStruct() throws Exception { String expression = "msg.single_struct"; CelAbstractSyntaxTree ast = CEL_COMPILER.compile(expression).getAst(); @@ -370,7 +371,7 @@ public void fieldSelection_jsonValue() throws Exception { } @Test - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // Program.eval returns untyped Object. public void fieldSelection_jsonListValue() throws Exception { String expression = "msg.list_value"; CelAbstractSyntaxTree ast = CEL_COMPILER.compile(expression).getAst(); @@ -727,4 +728,38 @@ public void eval_withEnumField() throws Exception { assertThat(result).isEqualTo(SimpleEnum.BAR.getNumber()); } + + @Test + @TestParameters("{expression: 'type(1) == int'}") + @TestParameters("{expression: 'type(TestAllTypes{}) == TestAllTypes'}") + @TestParameters("{expression: 'type(msg) == cel.expr.conformance.proto3.TestAllTypes'}") + public void eval_typeFunction(String expression) throws Exception { + CelAbstractSyntaxTree ast = CEL_COMPILER.compile(expression).getAst(); + + boolean result = + (boolean) + CEL_RUNTIME + .createProgram(ast) + .eval(ImmutableMap.of("msg", TestAllTypes.getDefaultInstance())); + + assertThat(result).isTrue(); + } + + @Test + public void eval_typeFunction_subsettable() throws Exception { + CelAbstractSyntaxTree ast = CEL_COMPILER.compile("type(1) == int").getAst(); + CelLiteRuntime runtimeWithType = + CelLiteRuntimeFactory.newLiteRuntimeBuilder() + .setStandardFunctions(EqualsOperator.create(), TypeFunction.create(TypeOverload.TYPE)) + .build(); + CelLiteRuntime runtimeWithoutType = + CelLiteRuntimeFactory.newLiteRuntimeBuilder() + .setStandardFunctions(EqualsOperator.create()) + .build(); + + assertThat(runtimeWithType.createProgram(ast).eval()).isEqualTo(true); + CelEvaluationException e = + assertThrows(CelEvaluationException.class, () -> runtimeWithoutType.createProgram(ast)); + assertThat(e).hasMessageThat().contains("No matching overload for function 'type'"); + } } diff --git a/runtime/src/test/java/dev/cel/runtime/DefaultInterpreterTest.java b/runtime/src/test/java/dev/cel/runtime/DefaultInterpreterTest.java index a23e3b2fb..e33a217c1 100644 --- a/runtime/src/test/java/dev/cel/runtime/DefaultInterpreterTest.java +++ b/runtime/src/test/java/dev/cel/runtime/DefaultInterpreterTest.java @@ -23,6 +23,7 @@ import dev.cel.common.CelFunctionDecl; import dev.cel.common.CelOptions; import dev.cel.common.CelOverloadDecl; +import dev.cel.common.types.DefaultTypeProvider; import dev.cel.common.types.SimpleType; import dev.cel.common.values.CelValueConverter; import dev.cel.compiler.CelCompiler; @@ -99,7 +100,8 @@ public Object adapt(String messageName, Object message) { notStrictlyFalseBinding.getDefinition()); DefaultInterpreter defaultInterpreter = new DefaultInterpreter( - TypeResolver.create(CelValueConverter.getDefaultInstance()), + TypeResolver.create( + DefaultTypeProvider.getInstance(), CelValueConverter.getDefaultInstance()), emptyProvider, dispatcherBuilder.build(), CelOptions.DEFAULT); diff --git a/runtime/src/test/java/dev/cel/runtime/TypeResolverTest.java b/runtime/src/test/java/dev/cel/runtime/TypeResolverTest.java index 4e289e1f6..bff9b1fb5 100644 --- a/runtime/src/test/java/dev/cel/runtime/TypeResolverTest.java +++ b/runtime/src/test/java/dev/cel/runtime/TypeResolverTest.java @@ -28,7 +28,6 @@ import dev.cel.common.types.OptionalType; import dev.cel.common.types.SimpleType; import dev.cel.common.types.TypeType; -import dev.cel.common.values.CelValueConverter; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; @@ -38,13 +37,11 @@ @RunWith(TestParameterInjector.class) public class TypeResolverTest { - private static final TypeResolver TYPE_RESOLVER = - TypeResolver.create(CelValueConverter.getDefaultInstance()); @Test public void resolveWellKnownObjectType_sentinelRuntimeType() { Optional resolvedType = - TYPE_RESOLVER.resolveWellKnownObjectType(TypeType.create(SimpleType.INT)); + TypeResolver.resolveWellKnownObjectType(TypeType.create(SimpleType.INT)); assertThat(resolvedType).hasValue(TypeResolver.RUNTIME_TYPE_TYPE); } @@ -52,14 +49,14 @@ public void resolveWellKnownObjectType_sentinelRuntimeType() { @Test public void resolveWellKnownObjectType_commonType( @TestParameter WellKnownObjectTestCase testCase) { - Optional resolvedType = TYPE_RESOLVER.resolveWellKnownObjectType(testCase.obj); + Optional resolvedType = TypeResolver.resolveWellKnownObjectType(testCase.obj); assertThat(resolvedType).hasValue(testCase.expectedTypeType); } @Test public void resolveWellKnownObjectType_unknownObjectType_returnsEmpty() { - Optional resolvedType = TYPE_RESOLVER.resolveWellKnownObjectType(new Object()); + Optional resolvedType = TypeResolver.resolveWellKnownObjectType(new Object()); assertThat(resolvedType).isEmpty(); }