use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testCanvasCommandExecuteWithRowsAddColumnMiddle.
@Test
public void testCanvasCommandExecuteWithRowsAddColumnMiddle() {
makeCommand(2);
final InformationItem existingInformationItemFirst = new InformationItem();
relation.getColumn().add(existingInformationItemFirst);
final InformationItem existingInformationItemLast = new InformationItem();
relation.getColumn().add(existingInformationItemLast);
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendRow(new BaseGridRow());
// Add Graph column first as RelationUIModelMapper relies on the model being first updated
command.newGraphCommand(handler).execute(gce);
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
assertEquals(4, uiModel.getColumnCount());
assertEquals(uiModelColumn, uiModel.getColumns().get(2));
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandExecuteRemoveMiddleWithColumns.
@Test
public void testGraphCommandExecuteRemoveMiddleWithColumns() {
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
final List firstRow = new List();
final List lastRow = new List();
relation.getRow().add(0, firstRow);
relation.getRow().add(lastRow);
relation.getColumn().add(new InformationItem());
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, relation.getRow().size());
assertEquals(firstRow, relation.getRow().get(0));
assertEquals(lastRow, relation.getRow().get(1));
assertEquals(1, relation.getColumn().size());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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.InformationItem in project kie-wb-common by kiegroup.
the class BindingPropertyConverter method wbFromDMN.
public static Binding wbFromDMN(final JSITBinding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (Objects.isNull(dmn)) {
return null;
}
final InformationItem parameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
Expression expression = null;
final JSITExpression jsiWrapped = dmn.getExpression();
if (Objects.nonNull(jsiWrapped)) {
final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
}
final Binding result = new Binding();
if (Objects.nonNull(parameter)) {
parameter.setParent(result);
}
result.setParameter(parameter);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
result.setExpression(expression);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method testSelectHeaderMultipleOutputClauseColumnNestedContextEntry.
@Test
@SuppressWarnings("unchecked")
public void testSelectHeaderMultipleOutputClauseColumnNestedContextEntry() {
// Mock nesting of DecisionTable in a ContextEntry
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
final InformationItem variable = new InformationItem();
contextEntry.setVariable(variable);
context.getContextEntry().add(contextEntry);
contextEntry.setExpression(expression.get());
this.hasExpression.setExpression(context);
this.grid = spy((DecisionTableGrid) definition.getEditor(parent, Optional.empty(), contextEntry, makeHasNameForDecision(), false, 1).get());
addOutputClause(2);
reset(domainObjectSelectionEvent);
grid.selectHeaderCell(0, DEFAULT_OUTPUT_CLAUSE_COLUMN_INDEX, false, false);
assertDomainObjectSelection(variable);
reset(domainObjectSelectionEvent);
grid.selectHeaderCell(1, DEFAULT_OUTPUT_CLAUSE_COLUMN_INDEX, false, false);
assertDomainObjectSelection(expression.get().getOutput().get(0));
}
Aggregations