use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationRowCommandTest method testCanvasCommandExecuteWithColumns.
@Test
public void testCanvasCommandExecuteWithColumns() {
relation.getRow().add(new List());
relation.getRow().add(new List());
relation.getColumn().add(new InformationItem());
uiModel.appendColumn(uiModelColumn);
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
makeCommand(1);
// Add Graph row 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(3, uiModel.getRowCount());
assertEquals(uiModelRow, uiModel.getRows().get(1));
assertEquals(2, uiModel.getColumnCount());
assertEquals(uiRowNumberColumn, uiModel.getColumns().get(0));
// checking just the row added by command
assertEquals(uiModelColumn, uiModel.getColumns().get(1));
assertEquals(2, uiModel.getRows().get(1).getCells().size());
assertEquals(2, uiModel.getCell(1, 0).getValue().getValue());
assertEquals("", uiModel.getCell(1, 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 AddRelationRowCommandTest method testGraphCommandExecuteWithColumns.
@Test
public void testGraphCommandExecuteWithColumns() {
relation.getColumn().add(new InformationItem());
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(1, relation.getRow().size());
assertEquals(row, relation.getRow().get(0));
assertEquals(1, relation.getColumn().size());
assertEquals(1, relation.getRow().get(0).getExpression().size());
assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
assertEquals(relation, row.getParent());
assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(0).getExpression().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationRowCommandTest method testGraphCommandExecuteInsertMiddleWithColumns.
@Test
public void testGraphCommandExecuteInsertMiddleWithColumns() {
relation.getRow().add(new List());
relation.getRow().add(new List());
relation.getColumn().add(new InformationItem());
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(3, relation.getRow().size());
assertEquals(row, relation.getRow().get(1));
assertEquals(1, relation.getColumn().size());
assertEquals(1, relation.getRow().get(1).getExpression().size());
assertTrue(relation.getRow().get(1).getExpression().get(0).getExpression() instanceof LiteralExpression);
assertEquals(relation, row.getParent());
assertEquals(relation.getRow().get(1), relation.getRow().get(1).getExpression().get(0).getExpression().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationRowCommandTest method testGraphCommandUndoWithColumns.
@Test
public void testGraphCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Add column and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertEquals(1, relation.getColumn().size());
assertEquals(0, relation.getRow().size());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testGraphCommandExecuteDeleteMiddleWithRows.
@Test
public void testGraphCommandExecuteDeleteMiddleWithRows() {
final List rowList = new List();
uiModel.appendColumn(mock(RelationColumn.class));
uiModel.appendColumn(mock(RelationColumn.class));
relation.getColumn().add(new InformationItem());
relation.getColumn().add(new InformationItem());
relation.getRow().add(rowList);
final LiteralExpression firstExpression = new LiteralExpression();
final LiteralExpression lastExpression = new LiteralExpression();
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, firstExpression));
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, lastExpression));
makeCommand(2);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(2, relation.getRow().get(0).getExpression().size());
assertEquals(firstExpression, relation.getRow().get(0).getExpression().get(0).getExpression());
assertEquals(lastExpression, relation.getRow().get(0).getExpression().get(1).getExpression());
}
Aggregations