Search in sources :

Example 1 with BeforeEvaluatorDefinition

use of org.drools.core.base.evaluators.BeforeEvaluatorDefinition in project drools by kiegroup.

the class KnowledgeBuilderConfigurationTest method testEvaluatorConfiguration.

@Test
public void testEvaluatorConfiguration() {
    // in this use case, the application already has the instance of the evaluator definition
    EvaluatorDefinition afterDef = new AfterEvaluatorDefinition();
    assertNotNull(afterDef);
    // creating the option and storing in a local var just to make test easier
    EvaluatorOption option = EvaluatorOption.get("after", afterDef);
    // wiring the evaluator definition using the type safe method
    config.setOption(option);
    // checking the type safe getOption() method
    assertEquals(option, config.getOption(EvaluatorOption.class, "after"));
    // checking string conversion
    assertEquals("after", config.getOption(EvaluatorOption.class, "after").getName());
    assertEquals(afterDef, config.getOption(EvaluatorOption.class, "after").getEvaluatorDefinition());
    // checking the string based getProperty() method
    assertEquals(AfterEvaluatorDefinition.class.getName(), config.getProperty(EvaluatorOption.PROPERTY_NAME + "after"));
    // wiring the evaluator definition using the string based setProperty() method
    config.setProperty(EvaluatorOption.PROPERTY_NAME + "before", BeforeEvaluatorDefinition.class.getName());
    BeforeEvaluatorDefinition beforeDef = new BeforeEvaluatorDefinition();
    // checking the type safe getOption() method
    assertEquals(EvaluatorOption.get("before", beforeDef), config.getOption(EvaluatorOption.class, "before"));
    // checking string conversion
    assertEquals("before", config.getOption(EvaluatorOption.class, "before").getName());
    assertEquals(beforeDef.getClass().getName(), config.getOption(EvaluatorOption.class, "before").getEvaluatorDefinition().getClass().getName());
    // checking the string based getProperty() method
    assertEquals(beforeDef.getClass().getName(), config.getProperty(EvaluatorOption.PROPERTY_NAME + "before"));
}
Also used : BeforeEvaluatorDefinition(org.drools.core.base.evaluators.BeforeEvaluatorDefinition) AfterEvaluatorDefinition(org.drools.core.base.evaluators.AfterEvaluatorDefinition) BeforeEvaluatorDefinition(org.drools.core.base.evaluators.BeforeEvaluatorDefinition) AfterEvaluatorDefinition(org.drools.core.base.evaluators.AfterEvaluatorDefinition) EvaluatorDefinition(org.drools.core.base.evaluators.EvaluatorDefinition) EvaluatorOption(org.kie.internal.builder.conf.EvaluatorOption) Test(org.junit.Test)

Aggregations

AfterEvaluatorDefinition (org.drools.core.base.evaluators.AfterEvaluatorDefinition)1 BeforeEvaluatorDefinition (org.drools.core.base.evaluators.BeforeEvaluatorDefinition)1 EvaluatorDefinition (org.drools.core.base.evaluators.EvaluatorDefinition)1 Test (org.junit.Test)1 EvaluatorOption (org.kie.internal.builder.conf.EvaluatorOption)1