Search in sources :

Example 1 with RefVariantB

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"));
}
Also used : Val(org.projectnessie.cel.common.types.ref.Val) ObjectT(org.projectnessie.cel.common.types.ObjectT) TypeRegistry(org.projectnessie.cel.common.types.ref.TypeRegistry) RefVariantB(org.projectnessie.cel.types.jackson.types.RefVariantB) MetaTest(org.projectnessie.cel.types.jackson.types.MetaTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 ObjectT (org.projectnessie.cel.common.types.ObjectT)1 TypeRegistry (org.projectnessie.cel.common.types.ref.TypeRegistry)1 Val (org.projectnessie.cel.common.types.ref.Val)1 MetaTest (org.projectnessie.cel.types.jackson.types.MetaTest)1 RefVariantB (org.projectnessie.cel.types.jackson.types.RefVariantB)1