Search in sources :

Example 11 with ParsedExpr

use of com.google.api.expr.v1alpha1.ParsedExpr in project cel-java by projectnessie.

the class PbObjectTest method newProtoObject.

@Test
void newProtoObject() {
    ProtoTypeRegistry reg = newRegistry();
    ParsedExpr parsedExpr = ParsedExpr.newBuilder().setSourceInfo(SourceInfo.newBuilder().addAllLineOffsets(Arrays.asList(1, 2, 3)).build()).build();
    reg.registerMessage(parsedExpr);
    Indexer obj = (Indexer) reg.nativeToValue(parsedExpr);
    Indexer si = (Indexer) obj.get(stringOf("source_info"));
    Indexer lo = (Indexer) si.get(stringOf("line_offsets"));
    assertThat(lo.get(intOf(2)).equal(intOf(3))).isSameAs(True);
    Indexer expr = (Indexer) obj.get(stringOf("expr"));
    Indexer call = (Indexer) expr.get(stringOf("call_expr"));
    assertThat(call.get(stringOf("function")).equal(stringOf(""))).isSameAs(True);
}
Also used : Indexer(org.projectnessie.cel.common.types.traits.Indexer) ParsedExpr(com.google.api.expr.v1alpha1.ParsedExpr) Test(org.junit.jupiter.api.Test)

Aggregations

ParsedExpr (com.google.api.expr.v1alpha1.ParsedExpr)10 Test (org.junit.jupiter.api.Test)8 CheckedExpr (com.google.api.expr.v1alpha1.CheckedExpr)5 TypeRegistry (org.projectnessie.cel.common.types.ref.TypeRegistry)5 Val (org.projectnessie.cel.common.types.ref.Val)5 ObjectT (org.projectnessie.cel.common.types.ObjectT)3 CheckRequest (com.google.api.expr.v1alpha1.CheckRequest)2 CheckResponse (com.google.api.expr.v1alpha1.CheckResponse)2 EvalRequest (com.google.api.expr.v1alpha1.EvalRequest)2 EvalResponse (com.google.api.expr.v1alpha1.EvalResponse)2 ParseRequest (com.google.api.expr.v1alpha1.ParseRequest)2 ParseResponse (com.google.api.expr.v1alpha1.ParseResponse)2 Type (com.google.api.expr.v1alpha1.Type)2 CEL.astToParsedExpr (org.projectnessie.cel.CEL.astToParsedExpr)2 CEL.parsedExprToAst (org.projectnessie.cel.CEL.parsedExprToAst)2 Err (org.projectnessie.cel.common.types.Err)2 Expr (com.google.api.expr.v1alpha1.Expr)1 MapType (com.google.api.expr.v1alpha1.Type.MapType)1 PrimitiveType (com.google.api.expr.v1alpha1.Type.PrimitiveType)1 Any (com.google.protobuf.Any)1