use of org.drools.mvel.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"));
}
Aggregations