use of org.drools.template.parser.DecisionTableParseException in project drools by kiegroup.
the class RuleWorksheetParseTest method testDuplicatePackageAttribute.
/**
* Duplicate package level attribute
*/
@Test
public void testDuplicatePackageAttribute() {
try {
makeRuleSet();
// B3, C3
makeAttribute("agenda-group", "agroup");
// B3. B4
makeAttribute("agenda-group", "bgroup");
makeRuleTable();
makeRow(11, "C", "A", "P");
makeRow(12, "Foo", "Foo");
makeRow(13, "attr == $param", "x");
makeRow(15, "1", "show()", "10");
listener.finishSheet();
Package p = listener.getRuleSet();
DRLOutput dout = new DRLOutput();
p.renderDRL(dout);
String drl = dout.getDRL();
// System.out.println( drl );
fail("should have failed");
} catch (DecisionTableParseException e) {
System.err.println(e.getMessage());
assertTrue(e.getMessage().contains("C3, C4"));
}
}
use of org.drools.template.parser.DecisionTableParseException in project drools-wb by kiegroup.
the class GuidedDecisionTableLHSBuilder method getValueBuilder.
private ParameterizedValueBuilder getValueBuilder(final String content) {
// Work out the type of "template":-
// age ---> SnippetType.SINGLE
// age == ---> SnippetType.SINGLE
// age == $param ---> SnippetType.PARAM
// age == $1 || age == $2 ---> SnippetType.INDEXED
// forall{age < $}{,} ---> SnippetType.FORALL
String template = content.trim();
SnippetType type = SnippetBuilder.getType(template);
if (type == SnippetType.SINGLE) {
type = SnippetType.PARAM;
boolean hasExplicitOperator = false;
for (String op : operators) {
if (template.endsWith(op)) {
hasExplicitOperator = true;
break;
}
}
if (!hasExplicitOperator) {
template = template + " ==";
}
template = template + " \"";
template = template + SnippetBuilder.PARAM_STRING + "\"";
}
// Make a ValueBuilder for the template
switch(type) {
case INDEXED:
return new IndexedParametersValueBuilder(template, parameterUtilities, ParameterizedValueBuilder.Part.LHS);
case PARAM:
return new SingleParameterValueBuilder(template, parameterUtilities, ParameterizedValueBuilder.Part.LHS);
case SINGLE:
return new LiteralValueBuilder(template);
}
throw new DecisionTableParseException("SnippetBuilder.SnippetType '" + type.toString() + "' is not supported. The column will not be added.");
}
use of org.drools.template.parser.DecisionTableParseException in project drools-wb by kiegroup.
the class DecisionTableXLSServiceImplTest method testInvalidTable.
private void testInvalidTable(Consumer<DecisionTableXLSServiceImpl> serviceConsumer) throws IOException {
this.service = getServiceWithValidationOverride((tempFile) -> {
// mock an invalid file
Throwable t = new Throwable("testing invalid xls dt creation");
throw new DecisionTableParseException("DecisionTableParseException: " + t.getMessage(), t);
});
mockStatic(IOUtils.class);
when(IOUtils.copy(any(InputStream.class), any(OutputStream.class))).thenReturn(0);
try {
serviceConsumer.accept(service);
} catch (RuntimeException e) {
// this is expected correct behavior
}
verify(ioService, never()).newOutputStream(any(org.uberfire.java.nio.file.Path.class), any(CommentedOption.class));
verifyStatic(never());
}
Aggregations