use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddDecisionRuleCommandTest method testCanvasCommandAddRuleAndThenUndo.
@Test
public void testCanvasCommandAddRuleAndThenUndo() throws Exception {
makeCommand(0);
dtable.getInput().add(new InputClause());
dtable.getOutput().add(new OutputClause());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendColumn(uiOutputClauseColumn);
uiModel.appendColumn(uiDescriptionColumn);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddRuleCommand = command.newCanvasCommand(canvasHandler);
canvasAddRuleCommand.execute(canvasHandler);
assertEquals(1, uiModel.getRowCount());
assertDefaultUiRowValues(0);
canvasAddRuleCommand.undo(canvasHandler);
assertEquals(0, uiModel.getRowCount());
// one time in execute(), one time in undo()
verify(canvasOperation, times(2)).execute();
verify(command, times(2)).updateRowNumbers();
verify(command, times(2)).updateParentInformation();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandExecuteExistingNotAffected.
@Test
public void testGraphCommandExecuteExistingNotAffected() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldOutput = "old rule 1";
final String ruleTwoOldOutput = "old rule 2";
dtable.getOutput().add(new OutputClause());
addRuleWithOutputClauseValues(ruleOneOldOutput);
addRuleWithOutputClauseValues(ruleTwoOldOutput);
assertEquals(1, dtable.getOutput().size());
// Graph command will insert new OutputClause at index 0 of the OutputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getOutput().size());
// first rule
assertEquals(2, dtable.getRule().get(0).getOutputEntry().size());
assertEquals(ruleOneOldOutput, dtable.getRule().get(0).getOutputEntry().get(1).getText());
assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(0).getOutputEntry().get(0).getText());
// second rule
assertEquals(2, dtable.getRule().get(1).getOutputEntry().size());
assertEquals(ruleTwoOldOutput, dtable.getRule().get(1).getOutputEntry().get(1).getText());
assertEquals(AddOutputClauseCommand.OUTPUT_CLAUSE_DEFAULT_VALUE, dtable.getRule().get(1).getOutputEntry().get(0).getText());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandUndoJustLastOutputClauseColumn.
@Test
public void testGraphCommandUndoJustLastOutputClauseColumn() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldOutput = "old rule 1";
final String ruleTwoOldOutput = "old rule 2";
dtable.getOutput().add(new OutputClause());
addRuleWithOutputClauseValues(ruleOneOldOutput);
addRuleWithOutputClauseValues(ruleTwoOldOutput);
assertEquals(1, dtable.getOutput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.undo(graphCommandExecutionContext));
assertEquals(1, dtable.getOutput().size());
// first rule
assertEquals(1, dtable.getRule().get(0).getOutputEntry().size());
assertEquals(ruleOneOldOutput, dtable.getRule().get(0).getOutputEntry().get(0).getText());
// second rule
assertEquals(1, dtable.getRule().get(1).getOutputEntry().size());
assertEquals(ruleTwoOldOutput, dtable.getRule().get(1).getOutputEntry().get(0).getText());
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.outputClause = new OutputClause();
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiOutputClauseColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverter method dmnFromWB.
public static org.kie.dmn.model.v1_1.DecisionTable dmnFromWB(final DecisionTable wb) {
org.kie.dmn.model.v1_1.DecisionTable result = new org.kie.dmn.model.v1_1.DecisionTable();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (InputClause input : wb.getInput()) {
result.getInput().add(InputClausePropertyConverter.dmnFromWB(input));
}
for (OutputClause input : wb.getOutput()) {
result.getOutput().add(OutputClausePropertyConverter.dmnFromWB(input));
}
for (DecisionRule dr : wb.getRule()) {
result.getRule().add(DecisionRulePropertyConverter.dmnFromWB(dr));
}
if (wb.getHitPolicy() != null) {
result.setHitPolicy(org.kie.dmn.model.v1_1.HitPolicy.fromValue(wb.getHitPolicy().value()));
}
if (wb.getAggregation() != null) {
result.setAggregation(org.kie.dmn.model.v1_1.BuiltinAggregator.fromValue(wb.getAggregation().value()));
}
if (wb.getPreferredOrientation() != null) {
result.setPreferredOrientation(org.kie.dmn.model.v1_1.DecisionTableOrientation.fromValue(wb.getPreferredOrientation().value()));
}
result.setOutputLabel(wb.getOutputLabel());
return result;
}
Aggregations