use of org.drools.template.objects.ArrayDataProvider in project drools by kiegroup.
the class TemplatesTest method loadingFromDLRArrayCorrectnessCheck.
@Test
public void loadingFromDLRArrayCorrectnessCheck() throws Exception {
final String[][] rows = new String[3][6];
rows[0] = new String[] { "tomato", "weight", "200", "1000", "6", "== Taste.GOOD || == Taste.EXCELENT" };
rows[1] = new String[] { "cucumber", "length", "20", "40", "15", "== Taste.EXCELENT" };
rows[2] = new String[] { "carrot", "weight", "0", "1000", "2", "== Taste.HORRIBLE" };
final ArrayDataProvider adp = new ArrayDataProvider(rows);
final DataProviderCompiler converter = new DataProviderCompiler();
try (InputStream resourceStream = KieServices.Factory.get().getResources().newClassPathResource("template_1.drl", getClass()).getInputStream()) {
final String drl = converter.compile(adp, resourceStream);
// prints rules generated from template
LOGGER.debug(drl);
assertEqualsIgnoreWhitespace(EXPECTED_RULES.toString(), drl);
testCorrectnessCheck(drl);
}
}
use of org.drools.template.objects.ArrayDataProvider in project drools by kiegroup.
the class RuleTemplateModelDRLPersistenceImpl method chooseDataProvider.
private DataProvider chooseDataProvider(final RuleModel model) {
DataProvider dataProvider;
TemplateModel tplModel = (TemplateModel) model;
if (tplModel.getRowsCount() > 0) {
dataProvider = new ArrayDataProvider(tplModel.getTableAsArray());
} else {
dataProvider = generateEmptyIterator();
}
return dataProvider;
}
Aggregations