Search in sources :

Example 1 with TypeType

use of org.projectnessie.cel.common.types.TypeT.TypeType in project cel-java by projectnessie.

the class TypeTest method typeConvertToType.

@Test
void typeConvertToType() {
    Type[] stdTypes = new Type[] { BoolType, BytesType, DoubleType, DurationType, IntType, ListType, MapType, NullType, StringType, TimestampType, TypeType, UintType };
    for (Type stdType : stdTypes) {
        Val cnv = stdType.convertToType(TypeType);
        assertThat(cnv).isEqualTo(TypeType);
    }
}
Also used : Val(org.projectnessie.cel.common.types.ref.Val) TypeType(org.projectnessie.cel.common.types.TypeT.TypeType) BytesType(org.projectnessie.cel.common.types.BytesT.BytesType) DoubleType(org.projectnessie.cel.common.types.DoubleT.DoubleType) DurationType(org.projectnessie.cel.common.types.DurationT.DurationType) IntType(org.projectnessie.cel.common.types.IntT.IntType) ListType(org.projectnessie.cel.common.types.ListT.ListType) StringType(org.projectnessie.cel.common.types.StringT.StringType) MapType(org.projectnessie.cel.common.types.MapT.MapType) NullType(org.projectnessie.cel.common.types.NullT.NullType) BoolType(org.projectnessie.cel.common.types.BoolT.BoolType) Type(org.projectnessie.cel.common.types.ref.Type) TimestampType(org.projectnessie.cel.common.types.TimestampT.TimestampType) UintType(org.projectnessie.cel.common.types.UintT.UintType) Test(org.junit.jupiter.api.Test)

Example 2 with TypeType

use of org.projectnessie.cel.common.types.TypeT.TypeType in project cel-java by projectnessie.

the class PbObjectTest method protoObjectConvertToType.

@Test
void protoObjectConvertToType() {
    TypeRegistry reg = newRegistry(Expr.getDefaultInstance());
    ParsedExpr msg = ParsedExpr.newBuilder().setSourceInfo(SourceInfo.newBuilder().addAllLineOffsets(Arrays.asList(1, 2, 3)).build()).build();
    Val obj = reg.nativeToValue(msg);
    assertThat(obj).isInstanceOf(ObjectT.class);
    ObjectT objVal = (ObjectT) obj;
    Type tv = objVal.type();
    assertThat(objVal.convertToType(TypeType).equal(tv)).isSameAs(True);
    assertThat(objVal.convertToType(objVal.type())).isSameAs(objVal);
}
Also used : Val(org.projectnessie.cel.common.types.ref.Val) TypeType(org.projectnessie.cel.common.types.TypeT.TypeType) Type(org.projectnessie.cel.common.types.ref.Type) ParsedExpr(com.google.api.expr.v1alpha1.ParsedExpr) ObjectT(org.projectnessie.cel.common.types.ObjectT) TypeRegistry(org.projectnessie.cel.common.types.ref.TypeRegistry) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 TypeType (org.projectnessie.cel.common.types.TypeT.TypeType)2 Type (org.projectnessie.cel.common.types.ref.Type)2 Val (org.projectnessie.cel.common.types.ref.Val)2 ParsedExpr (com.google.api.expr.v1alpha1.ParsedExpr)1 BoolType (org.projectnessie.cel.common.types.BoolT.BoolType)1 BytesType (org.projectnessie.cel.common.types.BytesT.BytesType)1 DoubleType (org.projectnessie.cel.common.types.DoubleT.DoubleType)1 DurationType (org.projectnessie.cel.common.types.DurationT.DurationType)1 IntType (org.projectnessie.cel.common.types.IntT.IntType)1 ListType (org.projectnessie.cel.common.types.ListT.ListType)1 MapType (org.projectnessie.cel.common.types.MapT.MapType)1 NullType (org.projectnessie.cel.common.types.NullT.NullType)1 ObjectT (org.projectnessie.cel.common.types.ObjectT)1 StringType (org.projectnessie.cel.common.types.StringT.StringType)1 TimestampType (org.projectnessie.cel.common.types.TimestampT.TimestampType)1 UintType (org.projectnessie.cel.common.types.UintT.UintType)1 TypeRegistry (org.projectnessie.cel.common.types.ref.TypeRegistry)1