use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testGraphCommandExecuteWithExistingColumn_InsertBefore.
@Test
public void testGraphCommandExecuteWithExistingColumn_InsertBefore() {
final InformationItem existingInformationItem = new InformationItem();
relation.getColumn().add(existingInformationItem);
final List row = new List();
relation.getRow().add(row);
final LiteralExpression existingLiteralExpression = new LiteralExpression();
row.getExpression().add(0, HasExpression.wrap(row, existingLiteralExpression));
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, relation.getColumn().size());
assertEquals(informationItem, relation.getColumn().get(0));
assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
assertEquals(existingInformationItem, relation.getColumn().get(1));
assertEquals(1, relation.getRow().size());
assertEquals(2, relation.getRow().get(0).getExpression().size());
assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
assertEquals(existingLiteralExpression, relation.getRow().get(0).getExpression().get(1).getExpression());
assertEquals(relation, informationItem.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 AddRelationColumnCommandTest method setup.
@Before
public void setup() {
this.relation = new Relation();
this.informationItem = new InformationItem();
this.uiModel = new BaseGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
makeCommand(1);
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiModelColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandUndoWithColumns.
@Test
public void testGraphCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getText().setValue(VALUE);
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Delete row and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertEquals(1, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(1, relation.getRow().get(0).getExpression().size());
assertEquals(VALUE, ((LiteralExpression) relation.getRow().get(0).getExpression().get(0).getExpression()).getText().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class DeleteRelationRowCommandTest method testGraphCommandExecuteWithColumns.
@Test
public void testGraphCommandExecuteWithColumns() {
relation.getColumn().add(new InformationItem());
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(0, relation.getRow().size());
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 AddRelationRowCommandTest method testCanvasCommandUndoWithColumns.
@Test
public void testCanvasCommandUndoWithColumns() {
relation.getColumn().add(new InformationItem());
relation.getRow().add(new org.kie.workbench.common.dmn.api.definition.model.List());
uiModel.appendColumn(uiModelColumn);
uiModel.appendRow(new BaseGridRow());
uiModelMapper.fromDMNModel(0, 0);
// Add Graph column first as RelationUIModelMapper relies on the model being first updated
command.newGraphCommand(handler).execute(gce);
// Add column 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());
verify(command).updateRowNumbers();
verify(command).updateParentInformation();
verify(canvasOperation).execute();
}
Aggregations