use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testCanvasCommandUndoWithColumns.
@Test
public void testCanvasCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getText().setValue(VALUE);
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
uiModel.appendColumn(uiModelColumn);
uiModelMapper.fromDMNModel(0, 0);
uiModelMapper.fromDMNModel(0, 1);
// Delete row and then undo
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
reset(command, canvasOperation);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(1, uiModel.getRowCount());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerGridTest method testSelectCellWithPoint.
@Test
public void testSelectCellWithPoint() {
final Point2D point = mock(Point2D.class);
final LiteralExpression domainObject = mock(LiteralExpression.class);
when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(domainObject);
grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
grid.selectCell(point, false, true);
verify(gridLayer).select(eq(grid));
verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
assertThat(domainObjectSelectionEvent.getCanvasHandler()).isEqualTo(canvasHandler);
assertThat(domainObjectSelectionEvent.getDomainObject()).isEqualTo(domainObject);
verify(cellSelectionManager).selectCell(eq(point), eq(false), eq(true));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class BaseDecisionTableEditorDefinitionTest method assertParentHierarchyEnrichment.
protected void assertParentHierarchyEnrichment(final DecisionTable model) {
final List<DecisionRule> rules = model.getRule();
final DecisionRule rule = rules.get(0);
final int inputClauseCount = model.getInput().size();
final List<InputClause> inputClauses = model.getInput();
assertThat(inputClauses.size()).isEqualTo(inputClauseCount);
inputClauses.forEach(inputClause -> {
assertThat(inputClause.getParent()).isEqualTo(model);
assertThat(inputClause.getInputExpression().getParent()).isEqualTo(inputClause);
});
final int outputClauseCount = model.getOutput().size();
final List<OutputClause> outputClauses = model.getOutput();
assertThat(outputClauses.size()).isEqualTo(outputClauseCount);
outputClauses.forEach(outputClause -> assertThat(outputClause.getParent()).isEqualTo(model));
assertThat(rule.getParent()).isEqualTo(model);
final List<UnaryTests> inputEntries = rule.getInputEntry();
assertThat(inputEntries.size()).isEqualTo(inputClauseCount);
inputEntries.forEach(inputEntry -> assertThat(inputEntry.getParent()).isEqualTo(rule));
final List<LiteralExpression> outputEntries = rule.getOutputEntry();
assertThat(outputEntries.size()).isEqualTo(outputClauseCount);
outputEntries.forEach(outputEntry -> assertThat(outputEntry.getParent()).isEqualTo(rule));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression 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());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_PREFIX + "1", dtable.getOutput().get(0).getName());
assertNull(dtable.getOutput().get(1).getName());
// first rule
final List<LiteralExpression> outputEntriesRuleOne = dtable.getRule().get(0).getOutputEntry();
assertEquals(2, outputEntriesRuleOne.size());
assertEquals(ruleOneOldOutput, outputEntriesRuleOne.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleOne.get(0).getText().getValue());
assertEquals(dtable.getRule().get(0), outputEntriesRuleOne.get(0).getParent());
// second rule
final List<LiteralExpression> outputEntriesRuleTwo = dtable.getRule().get(1).getOutputEntry();
assertEquals(2, outputEntriesRuleTwo.size());
assertEquals(ruleTwoOldOutput, outputEntriesRuleTwo.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleTwo.get(0).getText().getValue());
assertEquals(dtable.getRule().get(1), outputEntriesRuleTwo.get(0).getParent());
assertEquals(dtable, outputClause.getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithInputs.
@Test
public void testCanvasCommandAddOutputClauseToRuleWithInputs() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final String ruleInputValue = "in value";
final String ruleOutputValue = "out value";
dtable.getInput().add(new InputClause());
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue(ruleInputValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue(ruleOutputValue);
}
});
}
});
// Graph command populates OutputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getOutputEntry().get(0).getText().setValue(ruleOutputValue);
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendRow(new BaseGridRow());
uiModelMapper.fromDMNModel(0, 1);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddOutputClauseCommand.execute(canvasHandler);
assertEquals(ruleInputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
assertEquals(ruleOutputValue, uiModel.getRow(0).getCells().get(2).getValue().getValue());
assertEquals(3, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
assertEquals(2, uiModel.getColumnCount());
verify(executeCanvasOperation).execute();
verify(undoCanvasOperation).execute();
verify(command, times(2)).updateParentInformation();
}
Aggregations