Search in sources :

Example 1 with NestedMessage

use of com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage in project cel-java by projectnessie.

the class AttributesTest method benchmarkResolverCustomQualifier.

@Test
void benchmarkResolverCustomQualifier() {
    TypeRegistry reg = newRegistry();
    AttributeFactory attrs = new CustAttrFactory(newAttributeFactory(Container.defaultContainer, reg, reg));
    NestedMessage msg = NestedMessage.newBuilder().setBb(123).build();
    Activation vars = newActivation(mapOf("msg", msg));
    NamespacedAttribute attr = attrs.absoluteAttribute(1, "msg");
    Qualifier qualBB = attrs.newQualifier(Type.newBuilder().setMessageType("google.api.expr.test.v1.proto3.TestAllTypes.NestedMessage").build(), 2, "bb");
    attr.addQualifier(qualBB);
// Note: Migrated to JMH
}
Also used : NamespacedAttribute(org.projectnessie.cel.interpreter.AttributeFactory.NamespacedAttribute) AttributePattern.newPartialAttributeFactory(org.projectnessie.cel.interpreter.AttributePattern.newPartialAttributeFactory) AttributeFactory.newAttributeFactory(org.projectnessie.cel.interpreter.AttributeFactory.newAttributeFactory) Activation.emptyActivation(org.projectnessie.cel.interpreter.Activation.emptyActivation) Activation.newPartialActivation(org.projectnessie.cel.interpreter.Activation.newPartialActivation) Activation.newActivation(org.projectnessie.cel.interpreter.Activation.newActivation) Qualifier(org.projectnessie.cel.interpreter.AttributeFactory.Qualifier) TypeRegistry(org.projectnessie.cel.common.types.ref.TypeRegistry) NestedMessage(com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with NestedMessage

use of com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage in project cel-java by projectnessie.

the class AttributesTest method resolverCustomQualifier.

@Test
void resolverCustomQualifier() {
    TypeRegistry reg = newRegistry();
    AttributeFactory attrs = new CustAttrFactory(newAttributeFactory(Container.defaultContainer, reg, reg));
    NestedMessage msg = NestedMessage.newBuilder().setBb(123).build();
    Activation vars = newActivation(mapOf("msg", msg));
    NamespacedAttribute attr = attrs.absoluteAttribute(1, "msg");
    Qualifier qualBB = attrs.newQualifier(Type.newBuilder().setMessageType("google.api.expr.test.v1.proto3.TestAllTypes.NestedMessage").build(), 2, "bb");
    attr.addQualifier(qualBB);
    Object out = attr.resolve(vars);
    assertThat(out).isEqualTo(123);
    assertThat(estimateCost(attr)).extracting("min", "max").containsExactly(1L, 1L);
}
Also used : NamespacedAttribute(org.projectnessie.cel.interpreter.AttributeFactory.NamespacedAttribute) AttributePattern.newPartialAttributeFactory(org.projectnessie.cel.interpreter.AttributePattern.newPartialAttributeFactory) AttributeFactory.newAttributeFactory(org.projectnessie.cel.interpreter.AttributeFactory.newAttributeFactory) Activation.emptyActivation(org.projectnessie.cel.interpreter.Activation.emptyActivation) Activation.newPartialActivation(org.projectnessie.cel.interpreter.Activation.newPartialActivation) Activation.newActivation(org.projectnessie.cel.interpreter.Activation.newActivation) Qualifier(org.projectnessie.cel.interpreter.AttributeFactory.Qualifier) TypeRegistry(org.projectnessie.cel.common.types.ref.TypeRegistry) NestedMessage(com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

NestedMessage (com.google.api.expr.test.v1.proto3.TestAllTypesProto.TestAllTypes.NestedMessage)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 TypeRegistry (org.projectnessie.cel.common.types.ref.TypeRegistry)2 Activation.emptyActivation (org.projectnessie.cel.interpreter.Activation.emptyActivation)2 Activation.newActivation (org.projectnessie.cel.interpreter.Activation.newActivation)2 Activation.newPartialActivation (org.projectnessie.cel.interpreter.Activation.newPartialActivation)2 NamespacedAttribute (org.projectnessie.cel.interpreter.AttributeFactory.NamespacedAttribute)2 Qualifier (org.projectnessie.cel.interpreter.AttributeFactory.Qualifier)2 AttributeFactory.newAttributeFactory (org.projectnessie.cel.interpreter.AttributeFactory.newAttributeFactory)2 AttributePattern.newPartialAttributeFactory (org.projectnessie.cel.interpreter.AttributePattern.newPartialAttributeFactory)2