use of com.google.api.expr.test.v1.proto3.TestAllTypesProto.NestedTestAllTypes in project cel-java by projectnessie.
the class FieldDescriptionTest method fieldDescription.
@Test
void fieldDescription() {
Db pbdb = newDb();
NestedTestAllTypes msg = NestedTestAllTypes.getDefaultInstance();
String msgName = msg.getDescriptorForType().getFullName();
pbdb.registerMessage(msg);
PbTypeDescription td = pbdb.describeType(msgName);
assertThat(td).isNotNull();
FieldDescription fd = td.fieldByName("payload");
assertThat(fd).isNotNull();
assertThat(fd).extracting(FieldDescription::name).isEqualTo("payload");
assertThat(fd).extracting(FieldDescription::isOneof).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isMap).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isMessage).isEqualTo(true);
assertThat(fd).extracting(FieldDescription::isEnum).isEqualTo(false);
assertThat(fd).extracting(FieldDescription::isList).isEqualTo(false);
// Access the field by its Go struct name and check to see that it's index
// matches the one determined by the TypeDescription utils.
Type got = fd.checkedType();
Type wanted = Type.newBuilder().setMessageType("google.api.expr.test.v1.proto3.TestAllTypes").build();
assertThat(got).isEqualTo(wanted);
}
use of com.google.api.expr.test.v1.proto3.TestAllTypesProto.NestedTestAllTypes in project cel-java by projectnessie.
the class PbTypeDescriptionTest method fieldMap.
@Test
void fieldMap() {
Db pbdb = newDb();
NestedTestAllTypes msg = NestedTestAllTypes.getDefaultInstance();
pbdb.registerMessage(msg);
PbTypeDescription td = pbdb.describeType(msg.getDescriptorForType().getFullName());
assertThat(td).isNotNull();
assertThat(td.fieldMap()).hasSize(2);
}
Aggregations