use of com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes in project cel-java by projectnessie.
the class ProviderTest method typeRegistryNewValue_WrapperFields.
@Test
void typeRegistryNewValue_WrapperFields() {
TypeRegistry reg = newRegistry(TestAllTypes.getDefaultInstance());
Val exp = reg.newValue("google.api.expr.test.v1.proto3.TestAllTypes", mapOf("single_int32_wrapper", intOf(123)));
assertThat(exp).matches(v -> !Err.isError(v));
TestAllTypes ce = exp.convertToNative(TestAllTypes.class);
assertThat(ce).extracting(TestAllTypes::getSingleInt32Wrapper).extracting(Int32Value::getValue).isEqualTo(123);
}
use of com.google.api.expr.test.v1.proto2.TestAllTypesProto.TestAllTypes in project cel-java by projectnessie.
the class FieldDescriptionTest method getFrom.
@ParameterizedTest
@MethodSource("getFromTestCases")
void getFrom(GetFromTestCase tc) {
Db pbdb = newDb();
TestAllTypes msg = TestAllTypes.newBuilder().setSingleUint64(12).setSingleDuration(Duration.newBuilder().setSeconds(1234)).setSingleTimestamp(Timestamp.newBuilder().setSeconds(12345).setNanos(0)).setSingleBoolWrapper(BoolValue.of(false)).setSingleInt32Wrapper(Int32Value.of(42)).setStandaloneEnum(NestedEnum.BAR).setSingleNestedMessage(NestedMessage.newBuilder().setBb(123)).setSingleValue(Value.newBuilder().setStringValue("hello world")).setSingleStruct(Struct.newBuilder().putFields("null", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build())).build();
String msgName = msg.getDescriptorForType().getFullName();
pbdb.registerMessage(msg);
PbTypeDescription td = pbdb.describeType(msgName);
assertThat(td).isNotNull();
FieldDescription f = td.fieldByName(tc.field);
assertThat(f).isNotNull();
Object got = f.getFrom(pbdb, msg);
assertThat(got).isEqualTo(tc.want);
}
Aggregations