use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class PbObjectTest method protoObjectGet.
@Test
void protoObjectGet() {
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;
assertThat(objVal.get(stringOf("source_info")).equal(reg.nativeToValue(msg.getSourceInfo()))).isSameAs(True);
assertThat(objVal.get(stringOf("expr")).equal(reg.nativeToValue(Expr.getDefaultInstance()))).isSameAs(True);
assertThat(objVal.get(stringOf("bad_field"))).matches(Err::isError);
assertThat(objVal.get(IntZero)).matches(Err::isError);
}
Aggregations