Search in sources :

Example 1 with ProtoTypeRegistry

use of org.projectnessie.cel.common.types.pb.ProtoTypeRegistry in project cel-java by projectnessie.

the class ProviderTest method typeRegistryEnumValue.

@Test
void typeRegistryEnumValue() {
    ProtoTypeRegistry reg = newEmptyRegistry();
    reg.registerDescriptor(GlobalEnum.getDescriptor().getFile());
    Val enumVal = reg.enumValue("google.api.expr.test.v1.proto3.GlobalEnum.GOO");
    assertThat(enumVal).extracting(Val::intValue).isEqualTo((long) GlobalEnum.GOO.ordinal());
    Val enumVal2 = reg.findIdent("google.api.expr.test.v1.proto3.GlobalEnum.GOO");
    assertThat(enumVal2.equal(enumVal)).isSameAs(True);
}
Also used : Val(org.projectnessie.cel.common.types.ref.Val) ProtoTypeRegistry(org.projectnessie.cel.common.types.pb.ProtoTypeRegistry) Test(org.junit.jupiter.api.Test)

Example 2 with ProtoTypeRegistry

use of org.projectnessie.cel.common.types.pb.ProtoTypeRegistry in project cel-java by projectnessie.

the class ProviderTest method typeRegistryFindType.

@Test
void typeRegistryFindType() {
    ProtoTypeRegistry reg = newEmptyRegistry();
    reg.registerDescriptor(GlobalEnum.getDescriptor().getFile());
    String msgTypeName = "google.api.expr.test.v1.proto3.TestAllTypes";
    assertThat(reg.findType(msgTypeName)).isNotNull();
    // assertThat(reg.findType(msgTypeName + "Undefined")).isNotNull(); ... this doesn't exist in
    // protobuf-java
    assertThat(reg.findFieldType(msgTypeName, "single_bool")).isNotNull();
    assertThat(reg.findFieldType(msgTypeName, "double_bool")).isNull();
}
Also used : ProtoTypeRegistry(org.projectnessie.cel.common.types.pb.ProtoTypeRegistry) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 ProtoTypeRegistry (org.projectnessie.cel.common.types.pb.ProtoTypeRegistry)2 ByteString (com.google.protobuf.ByteString)1 Val (org.projectnessie.cel.common.types.ref.Val)1