use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method appendRow.
private void appendRow(final int rowIndex, final String rowIdentifier) {
final String inValue = "in " + rowIdentifier;
final String outValue = "out " + rowIdentifier;
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue(inValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue(outValue);
}
});
}
});
final GridRow uiRow = new BaseGridRow();
uiModel.appendRow(uiRow);
uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
rowsUnderTest.add(uiRow);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteListRowCommandTest method testGraphCommandExecuteRemoveMiddle.
@Test
public void testGraphCommandExecuteRemoveMiddle() {
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
final HasExpression firstRow = HasExpression.wrap(list, new LiteralExpression());
final HasExpression lastRow = HasExpression.wrap(list, new LiteralExpression());
list.getExpression().add(0, firstRow);
list.getExpression().add(lastRow);
makeCommand(1);
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(2, list.getExpression().size());
assertEquals(firstRow, list.getExpression().get(0));
assertEquals(lastRow, list.getExpression().get(1));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testGraphCommandExecuteWithExistingColumn_InsertMiddle.
@Test
public void testGraphCommandExecuteWithExistingColumn_InsertMiddle() {
makeCommand(2);
final InformationItem existingInformationItemFirst = new InformationItem();
relation.getColumn().add(existingInformationItemFirst);
final InformationItem existingInformationItemLast = new InformationItem();
relation.getColumn().add(existingInformationItemLast);
final List row = new List();
relation.getRow().add(row);
final LiteralExpression existingLiteralExpressionFirst = new LiteralExpression();
final LiteralExpression existingLiteralExpressionLast = new LiteralExpression();
row.getExpression().add(HasExpression.wrap(row, existingLiteralExpressionFirst));
row.getExpression().add(HasExpression.wrap(row, existingLiteralExpressionLast));
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(3, relation.getColumn().size());
assertEquals(existingInformationItemFirst, relation.getColumn().get(0));
assertEquals(informationItem, relation.getColumn().get(1));
assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
assertEquals(existingInformationItemLast, relation.getColumn().get(2));
assertEquals(1, relation.getRow().size());
assertEquals(3, relation.getRow().get(0).getExpression().size());
assertEquals(existingLiteralExpressionFirst, relation.getRow().get(0).getExpression().get(0).getExpression());
assertTrue(relation.getRow().get(0).getExpression().get(1).getExpression() instanceof LiteralExpression);
assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2).getExpression());
assertEquals(relation, informationItem.getParent());
assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(1).getExpression().getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class BaseMoveCommandsTest method addRelationRow.
protected void addRelationRow(final String identifier) {
final List row = new List();
for (int index = 0; index < relation.getColumn().size(); index++) {
final String ii = makeIdentifier(identifier, index);
row.getExpression().add(HasExpression.wrap(row, new LiteralExpression() {
{
setId(new Id(ii));
}
}));
}
relation.getRow().add(row);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression 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());
}
Aggregations