use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinition method getModelClass.
@Override
public Optional<DecisionTable> getModelClass() {
final DecisionTable dtable = new DecisionTable();
dtable.setHitPolicy(HitPolicy.ANY);
dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW);
final InputClause ic = new InputClause();
final LiteralExpression le = new LiteralExpression();
le.setText(INPUT_CLAUSE_EXPRESSION_TEXT);
ic.setInputExpression(le);
dtable.getInput().add(ic);
final OutputClause oc = new OutputClause();
oc.setName(OUTPUT_CLAUSE_NAME);
dtable.getOutput().add(oc);
final DecisionRule dr = new DecisionRule();
final UnaryTests drut = new UnaryTests();
drut.setText(INPUT_CLAUSE_UNARY_TEST_TEXT);
dr.getInputEntry().add(drut);
final LiteralExpression drle = new LiteralExpression();
drle.setText(OUTPUT_CLAUSE_EXPRESSION_TEXT);
dr.getOutputEntry().add(drle);
final Description d = new Description();
d.setValue(RULE_DESCRIPTION);
dr.setDescription(d);
dtable.getRule().add(dr);
return Optional.of(dtable);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<DecisionTable> oModel = definition.getModelClass();
assertThat(oModel).isPresent();
final DecisionTable model = oModel.get();
assertThat(model.getHitPolicy()).isEqualTo(HitPolicy.ANY);
assertThat(model.getPreferredOrientation()).isEqualTo(DecisionTableOrientation.RULE_AS_ROW);
final List<InputClause> input = model.getInput();
assertThat(input.size()).isEqualTo(1);
assertThat(input.get(0).getInputExpression()).isInstanceOf(LiteralExpression.class);
final List<OutputClause> output = model.getOutput();
assertThat(output.size()).isEqualTo(1);
final List<DecisionRule> rules = model.getRule();
assertThat(rules.size()).isEqualTo(1);
final DecisionRule rule = rules.get(0);
assertThat(rule.getInputEntry().size()).isEqualTo(1);
assertThat(rule.getInputEntry().get(0)).isInstanceOf(UnaryTests.class);
assertThat(rule.getOutputEntry().size()).isEqualTo(1);
assertThat(rule.getOutputEntry().get(0)).isInstanceOf(LiteralExpression.class);
assertThat(rule.getDescription()).isNotNull();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiInputClauseColumn);
this.uiModel.appendColumn(uiOutputClauseColumn);
this.uiModel.appendColumn(uiDescriptionColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
doReturn(3).when(uiDescriptionColumn).getIndex();
this.dtable = new DecisionTable();
this.dtable.getInput().add(new InputClause());
this.dtable.getOutput().add(new OutputClause());
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i1");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o1");
}
});
setDescription(new Description("desc1"));
}
});
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i2");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o2");
}
});
setDescription(new Description("desc2"));
}
});
this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testGraphCommandExecuteConstructedRuleOutputs.
@Test
public void testGraphCommandExecuteConstructedRuleOutputs() {
makeCommand(0);
assertEquals(0, dtable.getRule().size());
final int outputsCount = 2;
for (int i = 0; i < outputsCount; i++) {
dtable.getOutput().add(new OutputClause());
}
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(1, dtable.getRule().size());
assertEquals(rule, dtable.getRule().get(0));
assertEquals(0, rule.getInputEntry().size());
assertEquals(outputsCount, rule.getOutputEntry().size());
for (int outputIndex = 0; outputIndex < outputsCount; outputIndex++) {
assertTrue(rule.getOutputEntry().get(outputIndex).getText() != null);
assertFalse(rule.getOutputEntry().get(outputIndex).getText().isEmpty());
}
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testCanvasCommandExecuteInsertBelow.
@Test
public void testCanvasCommandExecuteInsertBelow() {
// The default behaviour of tests in this class is to "insert above"
final DecisionRule existingRule = new DecisionRule();
final DMNGridRow existingUiRow = new DMNGridRow();
dtable.getRule().add(existingRule);
uiModel.appendRow(existingUiRow);
dtable.getInput().add(new InputClause());
dtable.getOutput().add(new OutputClause());
makeCommand(1);
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendColumn(uiOutputClauseColumn);
uiModel.appendColumn(uiDescriptionColumn);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
final Command<AbstractCanvasHandler, CanvasViolation> canvasCommand = command.newCanvasCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
canvasCommand.execute(canvasHandler);
assertEquals(2, uiModel.getRowCount());
assertEquals(existingUiRow, uiModel.getRow(0));
assertEquals(uiModelRow, uiModel.getRow(1));
assertDefaultUiRowValues(1);
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
}
Aggregations