7272import dev .cel .common .ast .CelExpr .CelList ;
7373import dev .cel .common .testing .RepeatedTestProvider ;
7474import dev .cel .common .types .CelKind ;
75+ import dev .cel .common .types .CelProtoTypes ;
7576import dev .cel .common .types .CelType ;
76- import dev .cel .common .types .CelTypes ;
7777import dev .cel .common .types .EnumType ;
7878import dev .cel .common .types .ListType ;
7979import dev .cel .common .types .MapType ;
@@ -157,10 +157,10 @@ public final class CelImplTest {
157157 private static final CheckedExpr CHECKED_EXPR =
158158 CheckedExpr .newBuilder ()
159159 .setExpr (EXPR )
160- .putTypeMap (1L , CelTypes .BOOL )
161- .putTypeMap (2L , CelTypes .BOOL )
162- .putTypeMap (3L , CelTypes .BOOL )
163- .putTypeMap (4L , CelTypes .BOOL )
160+ .putTypeMap (1L , CelProtoTypes .BOOL )
161+ .putTypeMap (2L , CelProtoTypes .BOOL )
162+ .putTypeMap (3L , CelProtoTypes .BOOL )
163+ .putTypeMap (4L , CelProtoTypes .BOOL )
164164 .putReferenceMap (2L , Reference .newBuilder ().addOverloadId ("logical_and" ).build ())
165165 .putReferenceMap (3L , Reference .newBuilder ().addOverloadId ("logical_not" ).build ())
166166 .build ();
@@ -194,7 +194,7 @@ public void build_badFileDescriptorSet() {
194194 .addFile (AttributeContext .getDescriptor ().getFile ().toProto ())
195195 .build ())
196196 .setProtoResultType (
197- CelTypes .createMessage ("google.rpc.context.AttributeContext.Resource" ))
197+ CelProtoTypes .createMessage ("google.rpc.context.AttributeContext.Resource" ))
198198 .build ());
199199 assertThat (e ).hasMessageThat ().contains ("file descriptor set with unresolved proto file" );
200200 }
@@ -220,7 +220,7 @@ public void check() throws Exception {
220220 public void compile (boolean useProtoResultType ) throws Exception {
221221 CelBuilder celBuilder = standardCelBuilderWithMacros ();
222222 if (useProtoResultType ) {
223- celBuilder .setProtoResultType (CelTypes .BOOL );
223+ celBuilder .setProtoResultType (CelProtoTypes .BOOL );
224224 } else {
225225 celBuilder .setResultType (SimpleType .BOOL );
226226 }
@@ -234,7 +234,7 @@ public void compile(boolean useProtoResultType) throws Exception {
234234 public void compile_resultTypeCheckFailure (boolean useProtoResultType ) {
235235 CelBuilder celBuilder = standardCelBuilderWithMacros ();
236236 if (useProtoResultType ) {
237- celBuilder .setProtoResultType (CelTypes .STRING );
237+ celBuilder .setProtoResultType (CelProtoTypes .STRING );
238238 } else {
239239 celBuilder .setResultType (SimpleType .STRING );
240240 }
@@ -258,7 +258,7 @@ public void compile_combinedTypeProvider() {
258258 .addProtoTypeMasks (
259259 ImmutableList .of (ProtoTypeMask .ofAllFields ("google.rpc.context.AttributeContext" )))
260260 .addVar ("condition" , StructTypeReference .create ("google.type.Expr" ))
261- .setProtoResultType (CelTypes .BOOL )
261+ .setProtoResultType (CelProtoTypes .BOOL )
262262 .build ();
263263 CelValidationResult result =
264264 cel .compile ("type.Expr{expression: \" 'hello'\" }.expression == condition.expression" );
@@ -290,7 +290,8 @@ public void compile_customTypesWithAliasingCombinedProviders() throws Exception
290290 // However, the first type resolution from the alias to the qualified type name won't be
291291 // sufficient as future checks will expect the resolved alias to also be a type.
292292 TypeProvider customTypeProvider =
293- aliasingProvider (ImmutableMap .of ("Condition" , CelTypes .createMessage ("google.type.Expr" )));
293+ aliasingProvider (
294+ ImmutableMap .of ("Condition" , CelProtoTypes .createMessage ("google.type.Expr" )));
294295
295296 // The registration of the aliasing TypeProvider and the google.type.Expr descriptor
296297 // ensures that once the alias is resolved, the additional details about the Expr type
@@ -322,9 +323,9 @@ public void compile_customTypesWithAliasingSelfContainedProvider() throws Except
322323 aliasingProvider (
323324 ImmutableMap .of (
324325 "Condition" ,
325- CelTypes .createMessage ("google.type.Expr" ),
326+ CelProtoTypes .createMessage ("google.type.Expr" ),
326327 "google.type.Expr" ,
327- CelTypes .createMessage ("google.type.Expr" )));
328+ CelProtoTypes .createMessage ("google.type.Expr" )));
328329
329330 // The registration of the aliasing TypeProvider and the google.type.Expr descriptor
330331 // ensures that once the alias is resolved, the additional details about the Expr type
@@ -500,12 +501,14 @@ public void compile_overlappingVarsFailure() {
500501 .addDeclarations (
501502 Decl .newBuilder ()
502503 .setName ("variable" )
503- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .STRING ))
504+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .STRING ))
504505 .build ())
505506 .addDeclarations (
506507 Decl .newBuilder ()
507508 .setName ("variable" )
508- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .createList (CelTypes .STRING )))
509+ .setIdent (
510+ IdentDecl .newBuilder ()
511+ .setType (CelProtoTypes .createList (CelProtoTypes .STRING )))
509512 .build ())
510513 .setResultType (SimpleType .BOOL )
511514 .build ();
@@ -529,7 +532,7 @@ public void program_withVars() throws Exception {
529532 .addDeclarations (
530533 Decl .newBuilder ()
531534 .setName ("variable" )
532- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .STRING ))
535+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .STRING ))
533536 .build ())
534537 .setResultType (SimpleType .BOOL )
535538 .build ();
@@ -545,7 +548,7 @@ public void program_withCelValue() throws Exception {
545548 .addDeclarations (
546549 Decl .newBuilder ()
547550 .setName ("variable" )
548- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .STRING ))
551+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .STRING ))
549552 .build ())
550553 .setResultType (SimpleType .BOOL )
551554 .build ();
@@ -655,11 +658,11 @@ public void program_withFunctions() throws Exception {
655658 ImmutableList .of (
656659 Decl .newBuilder ()
657660 .setName ("one" )
658- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .BOOL ))
661+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .BOOL ))
659662 .build (),
660663 Decl .newBuilder ()
661664 .setName ("two" )
662- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .BOOL ))
665+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .BOOL ))
663666 .build (),
664667 Decl .newBuilder ()
665668 .setName ("any" )
@@ -668,21 +671,21 @@ public void program_withFunctions() throws Exception {
668671 .addOverloads (
669672 Overload .newBuilder ()
670673 .setOverloadId ("any_bool" )
671- .addParams (CelTypes .BOOL )
672- .setResultType (CelTypes .BOOL ))
674+ .addParams (CelProtoTypes .BOOL )
675+ .setResultType (CelProtoTypes .BOOL ))
673676 .addOverloads (
674677 Overload .newBuilder ()
675678 .setOverloadId ("any_bool_bool" )
676- .addParams (CelTypes .BOOL )
677- .addParams (CelTypes .BOOL )
678- .setResultType (CelTypes .BOOL ))
679+ .addParams (CelProtoTypes .BOOL )
680+ .addParams (CelProtoTypes .BOOL )
681+ .setResultType (CelProtoTypes .BOOL ))
679682 .addOverloads (
680683 Overload .newBuilder ()
681684 .setOverloadId ("any_bool_bool_bool" )
682- .addParams (CelTypes .BOOL )
683- .addParams (CelTypes .BOOL )
684- .addParams (CelTypes .BOOL )
685- .setResultType (CelTypes .BOOL )))
685+ .addParams (CelProtoTypes .BOOL )
686+ .addParams (CelProtoTypes .BOOL )
687+ .addParams (CelProtoTypes .BOOL )
688+ .setResultType (CelProtoTypes .BOOL )))
686689 .build ()))
687690 .addFunctionBindings (CelFunctionBinding .from ("any_bool" , Boolean .class , (arg ) -> arg ))
688691 .addFunctionBindings (
@@ -716,7 +719,7 @@ public void program_withThrowingFunction() throws Exception {
716719 .addOverloads (
717720 Overload .newBuilder ()
718721 .setOverloadId ("throws" )
719- .setResultType (CelTypes .BOOL )))
722+ .setResultType (CelProtoTypes .BOOL )))
720723 .build ())
721724 .addFunctionBindings (
722725 CelFunctionBinding .from (
@@ -744,7 +747,7 @@ public void program_withThrowingFunctionShortcircuited() throws Exception {
744747 .addOverloads (
745748 Overload .newBuilder ()
746749 .setOverloadId ("throws" )
747- .setResultType (CelTypes .BOOL )))
750+ .setResultType (CelProtoTypes .BOOL )))
748751 .build ())
749752 .addFunctionBindings (
750753 CelFunctionBinding .from (
@@ -960,7 +963,7 @@ public void program_protoActivation() throws Exception {
960963 .setIdent (
961964 IdentDecl .newBuilder ()
962965 .setType (
963- CelTypes .createMessage (
966+ CelProtoTypes .createMessage (
964967 "google.rpc.context.AttributeContext.Resource" )))
965968 .build ())
966969 .setResultType (SimpleType .STRING )
@@ -1107,7 +1110,7 @@ public void program_customVarResolver() throws Exception {
11071110 .addDeclarations (
11081111 Decl .newBuilder ()
11091112 .setName ("variable" )
1110- .setIdent (IdentDecl .newBuilder ().setType (CelTypes .STRING ))
1113+ .setIdent (IdentDecl .newBuilder ().setType (CelProtoTypes .STRING ))
11111114 .build ())
11121115 .setResultType (SimpleType .BOOL )
11131116 .build ();
@@ -1150,7 +1153,7 @@ public void program_messageTypeAddedAsVarWithoutDescriptor_throwsHumanReadableEr
11501153 String packageName = CheckedExpr .getDescriptor ().getFile ().getPackage ();
11511154 Cel cel =
11521155 standardCelBuilderWithMacros ()
1153- .addVar ("parsedExprVar" , CelTypes .createMessage (ParsedExpr .getDescriptor ()))
1156+ .addVar ("parsedExprVar" , CelProtoTypes .createMessage (ParsedExpr .getDescriptor ()))
11541157 .build ();
11551158 CelValidationException exception =
11561159 assertThrows (
@@ -2056,7 +2059,7 @@ private static TypeProvider aliasingProvider(ImmutableMap<String, Type> typeAlia
20562059 public @ Nullable Type lookupType (String typeName ) {
20572060 Type alias = typeAliases .get (typeName );
20582061 if (alias != null ) {
2059- return CelTypes .create (alias );
2062+ return CelProtoTypes .create (alias );
20602063 }
20612064 return null ;
20622065 }
@@ -2069,7 +2072,7 @@ private static TypeProvider aliasingProvider(ImmutableMap<String, Type> typeAlia
20692072 @ Override
20702073 public TypeProvider .@ Nullable FieldType lookupFieldType (Type type , String fieldName ) {
20712074 if (typeAliases .containsKey (type .getMessageType ())) {
2072- return TypeProvider .FieldType .of (CelTypes .STRING );
2075+ return TypeProvider .FieldType .of (CelProtoTypes .STRING );
20732076 }
20742077 return null ;
20752078 }
0 commit comments