Search in sources :

Example 1 with ListType

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

the class PbTypeDescriptionTest method checkedType.

@Test
void checkedType() {
    Db pbdb = newDb();
    TestAllTypes msg = TestAllTypes.getDefaultInstance();
    String msgName = msg.getDescriptorForType().getFullName();
    pbdb.registerMessage(msg);
    PbTypeDescription td = pbdb.describeType(msgName);
    assertThat(td).isNotNull();
    FieldDescription field = td.fieldByName("map_string_string");
    assertThat(field).isNotNull();
    Type mapType = Decls.newMapType(Decls.String, Decls.String);
    assertThat(field.checkedType()).isEqualTo(mapType);
    field = td.fieldByName("repeated_nested_message");
    assertThat(field).isNotNull();
    Type listType = Decls.newListType(Decls.newObjectType("google.api.expr.test.v1.proto3.TestAllTypes.NestedMessage"));
    assertThat(field.checkedType()).isEqualTo(listType);
}
Also used : Type(com.google.api.expr.v1alpha1.Type) ByteString(com.google.protobuf.ByteString) TestAllTypes(com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes) NestedTestAllTypes(com.google.api.expr.test.v1.proto3.TestAllTypesProto.NestedTestAllTypes) Db.newDb(org.projectnessie.cel.common.types.pb.Db.newDb) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ListType

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

the class JacksonTypeDescriptionTest method checkListType.

private void checkListType(JacksonRegistry reg, String prop, Class<?> valueClass, com.google.api.expr.v1alpha1.Type valueType) {
    JacksonFieldType ft = (JacksonFieldType) reg.findFieldType(CollectionsObject.class.getName(), prop);
    assertThat(ft).isNotNull();
    JavaType javaType = ft.propertyWriter().getType();
    assertThat(javaType).extracting(JavaType::isCollectionLikeType).isEqualTo(true);
    assertThat(javaType.getContentType()).extracting(JavaType::getRawClass).isSameAs(valueClass);
    assertThat(ft.type).extracting(com.google.api.expr.v1alpha1.Type::getListType).extracting(ListType::getElemType).isSameAs(valueType);
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) ListType(com.google.api.expr.v1alpha1.Type.ListType) JavaType(com.fasterxml.jackson.databind.JavaType) MapType(com.google.api.expr.v1alpha1.Type.MapType) InnerType(org.projectnessie.cel.types.jackson.types.InnerType)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 NestedTestAllTypes (com.google.api.expr.test.v1.proto3.TestAllTypesProto.NestedTestAllTypes)1 TestAllTypes (com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes)1 Type (com.google.api.expr.v1alpha1.Type)1 ListType (com.google.api.expr.v1alpha1.Type.ListType)1 MapType (com.google.api.expr.v1alpha1.Type.MapType)1 ByteString (com.google.protobuf.ByteString)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Db.newDb (org.projectnessie.cel.common.types.pb.Db.newDb)1 InnerType (org.projectnessie.cel.types.jackson.types.InnerType)1