Skip to content

Commit

Permalink
Migrate dev/cel/extensions tests to use canonical conformance protos.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702442070
  • Loading branch information
jnthntatum authored and copybara-github committed Dec 3, 2024
1 parent 68c37b9 commit 9413a1e
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion common/src/test/java/dev/cel/common/ast/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ java_library(
"//parser:macro",
"//parser:operator",
"@cel_spec//proto/cel/expr:expr_java_proto",
"@cel_spec//proto/test/v1/proto3:test_all_types_java_proto",
"@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
"@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import dev.cel.common.CelAbstractSyntaxTree;
Expand All @@ -26,6 +25,7 @@
import dev.cel.common.types.StructTypeReference;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.extensions.CelOptionalLibrary;
import dev.cel.parser.CelStandardMacro;
import org.junit.Test;
Expand Down Expand Up @@ -173,7 +173,7 @@ public void list() throws Exception {
public void struct() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.addMessageTypes(TestAllTypes.getDescriptor())
.addLibraries(CelOptionalLibrary.INSTANCE)
.build();
Expand Down Expand Up @@ -223,7 +223,7 @@ public void struct() throws Exception {
public void map() throws Exception {
CelCompiler celCompiler =
CelCompilerFactory.standardCelCompilerBuilder()
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.addMessageTypes(TestAllTypes.getDescriptor())
.addLibraries(CelOptionalLibrary.INSTANCE)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import dev.cel.common.CelAbstractSyntaxTree;
Expand All @@ -32,6 +31,7 @@
import dev.cel.common.types.SimpleType;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.parser.CelStandardMacro;
import dev.cel.parser.Operator;
import java.util.Optional;
Expand Down
2 changes: 1 addition & 1 deletion common/src/test/java/dev/cel/common/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ java_library(
"//common/src/test/resources:service_conflicting_name_java_proto",
"//common/src/test/resources:single_file_java_proto",
"//common/testing",
"@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
"@cel_spec//proto/test/v1/proto2:test_all_types_java_proto",
"@cel_spec//proto/test/v1/proto3:test_all_types_java_proto",
"@com_google_googleapis//google/type:type_java_proto",
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.stream;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.Descriptors.Descriptor;
Expand All @@ -32,6 +31,7 @@
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
import dev.cel.common.testdata.ProtoJavaApiVersion1.Proto2JavaVersion1Message;
import dev.cel.common.testing.RepeatedTestProvider;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes;
import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand All @@ -30,6 +29,7 @@
import dev.cel.common.CelDescriptorUtil;
import dev.cel.common.CelDescriptors;
import dev.cel.common.internal.ProtoMessageFactory.CombinedMessageFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -59,7 +59,7 @@ public void newBuilder_withDescriptor_producesNewMessageBuilder() {

TestAllTypes.Builder builder =
(TestAllTypes.Builder)
messageFactory.newBuilder("google.api.expr.test.v1.proto2.TestAllTypes").get();
messageFactory.newBuilder("cel.expr.conformance.proto3.TestAllTypes").get();

assertThat(builder.setSingleInt64(5L).build())
.isEqualTo(TestAllTypes.newBuilder().setSingleInt64(5L).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedEnum;
import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage;
import com.google.protobuf.Any;
import com.google.protobuf.DynamicMessage;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.Struct;
import com.google.protobuf.Value;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.expr.conformance.proto3.TestAllTypes.NestedEnum;
import dev.cel.expr.conformance.proto3.TestAllTypes.NestedMessage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
2 changes: 1 addition & 1 deletion common/src/test/java/dev/cel/common/navigation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ java_library(
"//compiler:compiler_builder",
"//parser:macro",
"//parser:operator",
"@cel_spec//proto/test/v1/proto3:test_all_types_java_proto",
"@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
"@maven//:com_google_guava_guava",
"@maven//:com_google_testparameterinjector_test_parameter_injector",
"@maven//:junit_junit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static dev.cel.common.CelOverloadDecl.newMemberOverload;
import static org.junit.Assert.assertThrows;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.UnsignedLong;
import com.google.testing.junit.testparameterinjector.TestParameter;
Expand All @@ -37,6 +36,7 @@
import dev.cel.common.types.StructTypeReference;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.parser.CelStandardMacro;
import dev.cel.parser.Operator;
import java.util.Optional;
Expand Down Expand Up @@ -580,7 +580,7 @@ public void messageConstruction_allNodesReturned() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -603,7 +603,7 @@ public void messageConstruction_filterStruct_allNodesReturned() throws Exception
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand Down Expand Up @@ -631,7 +631,7 @@ public void messageConstruction_preOrder_heightSet() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -651,7 +651,7 @@ public void messageConstruction_postOrder_heightSet() throws Exception {
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand All @@ -672,7 +672,7 @@ public void messageConstruction_maxIdsSet(@TestParameter TraversalOrder traversa
CelCompiler compiler =
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.build();
CelAbstractSyntaxTree ast = compiler.compile("TestAllTypes{single_int64: 1}").getAst();
CelNavigableAst navigableAst = CelNavigableAst.fromAst(ast);
Expand Down
2 changes: 1 addition & 1 deletion extensions/src/test/java/dev/cel/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ java_library(
"//runtime",
"//runtime:interpreter_util",
"@cel_spec//proto/cel/expr:expr_java_proto",
"@cel_spec//proto/cel/expr/conformance/proto3:test_all_types_java_proto",
"@cel_spec//proto/test/v1/proto2:test_all_types_java_proto",
"@cel_spec//proto/test/v1/proto3:test_all_types_java_proto",
"@maven//:com_google_guava_guava",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.testing.junit.testparameterinjector.TestParameter;
Expand All @@ -31,6 +30,7 @@
import dev.cel.common.types.StructTypeReference;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.parser.CelStandardMacro;
import dev.cel.runtime.CelRuntime;
import dev.cel.runtime.CelRuntime.CelFunctionBinding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import static org.junit.Assert.assertThrows;

import dev.cel.expr.Value;
import com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes;
import com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes.NestedMessage;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.UnsignedLong;
Expand All @@ -45,6 +43,8 @@
import dev.cel.common.types.OptionalType;
import dev.cel.common.types.SimpleType;
import dev.cel.common.types.StructTypeReference;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.expr.conformance.proto3.TestAllTypes.NestedMessage;
import dev.cel.parser.CelStandardMacro;
import dev.cel.runtime.CelEvaluationException;
import dev.cel.runtime.CelRuntime;
Expand Down Expand Up @@ -94,7 +94,7 @@ private static CelBuilder newCelBuilder() {
.setOptions(
CelOptions.current().enableUnsignedLongs(true).enableTimestampEpoch(true).build())
.setStandardMacros(CelStandardMacro.STANDARD_MACROS)
.setContainer("google.api.expr.test.v1.proto2")
.setContainer("cel.expr.conformance.proto3")
.addMessageTypes(TestAllTypes.getDescriptor())
.addRuntimeLibraries(CelOptionalLibrary.INSTANCE)
.addCompilerLibraries(CelOptionalLibrary.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
Expand All @@ -32,6 +31,7 @@
import dev.cel.common.types.SimpleType;
import dev.cel.compiler.CelCompiler;
import dev.cel.compiler.CelCompilerFactory;
import dev.cel.expr.conformance.proto3.TestAllTypes;
import dev.cel.extensions.CelSetsExtensions.Function;
import dev.cel.runtime.CelEvaluationException;
import dev.cel.runtime.CelRuntime;
Expand All @@ -49,7 +49,7 @@ public final class CelSetsExtensionsTest {
CelCompilerFactory.standardCelCompilerBuilder()
.addMessageTypes(TestAllTypes.getDescriptor())
.setOptions(CEL_OPTIONS)
.setContainer("google.api.expr.test.v1.proto3")
.setContainer("cel.expr.conformance.proto3")
.addLibraries(CelExtensions.sets(CEL_OPTIONS))
.addVar("list", ListType.create(SimpleType.INT))
.addVar("subList", ListType.create(SimpleType.INT))
Expand Down

0 comments on commit 9413a1e

Please sign in to comment.