use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor in project drools-wb by kiegroup.
the class ConditionColumnPlugin method getPatterns.
@Override
public Set<PatternWrapper> getPatterns() {
final Set<PatternWrapper> patterns = new HashSet<>();
final BRLRuleModel brlRuleModel = makeBRLRuleModel();
final List<String> variables = brlRuleModel.getLHSPatternVariables();
variables.forEach(var -> {
final Pattern52 pattern = getPresenter().getModel().getConditionPattern(var);
if (!(pattern instanceof FactPatternPattern52Adaptor)) {
final String factType = brlRuleModel.getLHSBoundFact(var).getFactType();
final boolean isNegated = brlRuleModel.getLHSBoundFact(var).isNegated();
patterns.add(new PatternWrapper(factType, var, isNegated));
}
});
return patterns;
}
use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor in project drools-wb by kiegroup.
the class ConditionColumnPluginTest method testGetPatternsWithBRLCondition.
@Test
public void testGetPatternsWithBRLCondition() throws Exception {
final Pattern52 pattern = new Pattern52() {
{
setFactType("FactType");
setBoundName("$fact");
}
};
final BRLConditionColumn brlColumn = new BRLConditionColumn();
final FactPattern fp = new FactPattern("AnotherFact") {
{
setBoundName("$another");
}
};
brlColumn.setDefinition(Collections.singletonList(fp));
doReturn(Arrays.asList(pattern, brlColumn)).when(model).getConditions();
doReturn(pattern).when(model).getConditionPattern(eq("$fact"));
doReturn(new FactPatternPattern52Adaptor(fp)).when(model).getConditionPattern(eq("$another"));
final Set<PatternWrapper> patterns = plugin.getPatterns();
assertEquals(1, patterns.size());
assertTrue(patterns.contains(new PatternWrapper("FactType", "$fact", false)));
}
Aggregations