use of org.drools.decisiontable.parser.DefaultRuleSheetListener in project drools by kiegroup.
the class SpreadsheetCompilerUnitTest method testPropertiesXLS.
@Test
public void testPropertiesXLS() {
final List<DataListener> listeners = new ArrayList<DataListener>();
final DefaultRuleSheetListener listener = new DefaultRuleSheetListener();
listeners.add(listener);
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("Properties.xls");
parser.parseFile(is);
listener.getProperties();
final String rulesetName = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.RULESET_TAG);
assertNotNull(rulesetName);
assertEquals("Properties", rulesetName);
final List<Import> importList = RuleSheetParserUtil.getImportList(listener.getProperties().getProperty(DefaultRuleSheetListener.IMPORT_TAG));
assertNotNull(importList);
assertEquals(1, importList.size());
assertEquals("java.util.List", importList.get(0).getClassName());
final List<Global> variableList = RuleSheetParserUtil.getVariableList(listener.getProperties().getProperty(DefaultRuleSheetListener.VARIABLES_TAG));
assertNotNull(variableList);
assertEquals(1, variableList.size());
assertEquals("java.util.List", variableList.get(0).getClassName());
assertEquals("list", variableList.get(0).getIdentifier());
final List<String> functions = listener.getProperties().getProperty(DefaultRuleSheetListener.FUNCTIONS_TAG);
assertNotNull(functions);
assertEquals(1, functions.size());
assertEquals("A function", functions.get(0));
final List<String> queries = listener.getProperties().getProperty(DefaultRuleSheetListener.QUERIES_TAG);
assertNotNull(queries);
assertEquals(1, queries.size());
assertEquals("A query", queries.get(0));
final List<String> declarations = listener.getProperties().getProperty(DefaultRuleSheetListener.DECLARES_TAG);
assertNotNull(declarations);
assertEquals(1, declarations.size());
assertEquals("A declared type", declarations.get(0));
final String sequentialFlag = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.SEQUENTIAL_FLAG);
assertNotNull(sequentialFlag);
assertEquals("false", sequentialFlag);
final String escapeQuotesFlag = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.ESCAPE_QUOTES_FLAG);
assertNotNull(escapeQuotesFlag);
assertEquals("false", escapeQuotesFlag);
}
use of org.drools.decisiontable.parser.DefaultRuleSheetListener in project drools by kiegroup.
the class SpreadsheetCompiler method getRuleSheetListener.
private RuleSheetListener getRuleSheetListener(final Resource resource, final String worksheetName) {
final DefaultRuleSheetListener listener = new DefaultRuleSheetListener();
listener.setWorksheetName(worksheetName);
final Map<String, List<DataListener>> sheetListeners = new HashMap<String, List<DataListener>>();
final List<DataListener> listeners = new ArrayList<DataListener>();
listeners.add(listener);
sheetListeners.put(worksheetName, listeners);
parseResource(new ExcelParser(sheetListeners), resource);
return listener;
}
use of org.drools.decisiontable.parser.DefaultRuleSheetListener in project drools by kiegroup.
the class SpreadsheetCompilerUnitTest method testPropertiesWithWhiteSpaceXLS.
@Test
public void testPropertiesWithWhiteSpaceXLS() {
final List<DataListener> listeners = new ArrayList<DataListener>();
final DefaultRuleSheetListener listener = new DefaultRuleSheetListener();
listeners.add(listener);
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("PropertiesWithWhiteSpace.xls");
parser.parseFile(is);
listener.getProperties();
final String rulesetName = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.RULESET_TAG);
assertNotNull(rulesetName);
assertEquals("Properties", rulesetName);
final List<Import> importList = RuleSheetParserUtil.getImportList(listener.getProperties().getProperty(DefaultRuleSheetListener.IMPORT_TAG));
assertNotNull(importList);
assertEquals(1, importList.size());
assertEquals("java.util.List", importList.get(0).getClassName());
final List<Global> variableList = RuleSheetParserUtil.getVariableList(listener.getProperties().getProperty(DefaultRuleSheetListener.VARIABLES_TAG));
assertNotNull(variableList);
assertEquals(1, variableList.size());
assertEquals("java.util.List", variableList.get(0).getClassName());
assertEquals("list", variableList.get(0).getIdentifier());
final List<String> functions = listener.getProperties().getProperty(DefaultRuleSheetListener.FUNCTIONS_TAG);
assertNotNull(functions);
assertEquals(1, functions.size());
assertEquals("A function", functions.get(0));
final List<String> queries = listener.getProperties().getProperty(DefaultRuleSheetListener.QUERIES_TAG);
assertNotNull(queries);
assertEquals(1, queries.size());
assertEquals("A query", queries.get(0));
final List<String> declarations = listener.getProperties().getProperty(DefaultRuleSheetListener.DECLARES_TAG);
assertNotNull(declarations);
assertEquals(1, declarations.size());
assertEquals("A declared type", declarations.get(0));
final String sequentialFlag = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.SEQUENTIAL_FLAG);
assertNotNull(sequentialFlag);
assertEquals("false", sequentialFlag);
final String escapeQuotesFlag = listener.getProperties().getSingleProperty(DefaultRuleSheetListener.ESCAPE_QUOTES_FLAG);
assertNotNull(escapeQuotesFlag);
assertEquals("false", escapeQuotesFlag);
}
Aggregations