use of org.projectnessie.cel.types.jackson.types.RefVariantB in project cel-java by projectnessie.
the class JacksonRegistryTest method nessieBranch.
@Test
void nessieBranch() {
TypeRegistry reg = JacksonRegistry.newRegistry();
RefVariantB refVariantB = RefVariantB.of("main", "cafebabe123412341234123412341234");
Val branchVal = reg.nativeToValue(refVariantB);
assertThat(branchVal).isInstanceOf(ObjectT.class);
assertThat(branchVal.type().typeEnum()).isSameAs(TypeEnum.Object);
assertThat(branchVal.type().typeName()).isEqualTo(refVariantB.getClass().getName());
ObjectT branchObj = (ObjectT) branchVal;
assertThat(branchObj.isSet(stringOf("foo"))).isInstanceOf(Err.class).asString().isEqualTo("no such field 'foo'");
assertThat(branchObj.isSet(stringOf("name"))).isEqualTo(True);
assertThat(branchObj.isSet(stringOf("hash"))).isEqualTo(True);
assertThat(branchObj.get(stringOf("foo"))).isInstanceOf(Err.class).asString().isEqualTo("no such field 'foo'");
assertThat(branchObj.get(stringOf("name"))).isEqualTo(stringOf("main"));
assertThat(branchObj.get(stringOf("hash"))).isEqualTo(stringOf("cafebabe123412341234123412341234"));
}
Aggregations