use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class ProviderTest method unsupportedConversion.
@Test
void unsupportedConversion() {
TypeRegistry reg = newEmptyRegistry();
Val val = reg.nativeToValue(new nonConvertible());
assertThat(val).matches(Err::isError);
}
use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class ProviderTest method expectNativeToValue.
static void expectNativeToValue(Object in, Val out) {
TypeRegistry reg = newRegistry(ParsedExpr.getDefaultInstance());
Val val = reg.nativeToValue(in);
assertThat(val).matches(v -> !Err.isError(v));
assertThat(val.equal(out)).isSameAs(True);
}
use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class AttributesTest method attributesAbsoluteAttr.
@Test
void attributesAbsoluteAttr() {
TypeRegistry reg = newRegistry();
Container cont = newContainer(Container.name("acme.ns"));
AttributeFactory attrs = newAttributeFactory(cont, reg, reg);
Activation vars = newActivation(mapOf("acme.a", mapOf("b", mapOf(4L, mapOf(false, "success")))));
// acme.a.b[4][false]
NamespacedAttribute attr = attrs.absoluteAttribute(1, "acme.a");
Qualifier qualB = attrs.newQualifier(null, 2, "b");
Qualifier qual4 = attrs.newQualifier(null, 3, 4L);
Qualifier qualFalse = attrs.newQualifier(null, 4, false);
attr.addQualifier(qualB);
attr.addQualifier(qual4);
attr.addQualifier(qualFalse);
Object out = attr.resolve(vars);
assertThat(out).isEqualTo("success");
assertThat(estimateCost(attr)).extracting("min", "max").containsExactly(1L, 1L);
}
use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class JacksonRegistryTest method copy.
@Test
void copy() {
TypeRegistry reg = JacksonRegistry.newRegistry();
assertThat(reg).extracting(TypeRegistry::copy).isSameAs(reg);
}
use of org.projectnessie.cel.common.types.ref.TypeRegistry in project cel-java by projectnessie.
the class JacksonRegistryTest method registerType.
@Test
void registerType() {
TypeRegistry reg = JacksonRegistry.newRegistry();
assertThatThrownBy(() -> reg.registerType(IntT.IntType)).isInstanceOf(UnsupportedOperationException.class);
}
Aggregations