use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class AddListRowCommandTest method testGraphCommandUndoMultipleEntriesPresent.
@Test
public void testGraphCommandUndoMultipleEntriesPresent() {
final HasExpression firstEntry = HasExpression.wrap(list, new LiteralExpression());
list.getExpression().add(0, firstEntry);
makeCommand();
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
// Add row and then undo
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(GraphCommandResultBuilder.SUCCESS, c.undo(gce));
assertEquals(1, list.getExpression().size());
assertEquals(firstEntry, list.getExpression().get(0));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteListRowCommandTest method setup.
@Before
public void setup() {
this.list = new List();
this.uiModel = new BaseGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
this.uiModel.appendRow(new BaseGridRow());
this.list.getExpression().add(HasExpression.wrap(list, new LiteralExpression()));
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiExpressionEditorColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteListRowCommandTest method testGraphCommandUndo.
@Test
public void testGraphCommandUndo() {
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getText().setValue(VALUE);
list.getExpression().add(HasExpression.wrap(list, literalExpression));
makeCommand(0);
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(2, list.getExpression().size());
assertEquals(VALUE, ((LiteralExpression) list.getExpression().get(1).getExpression()).getText().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression 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.LiteralExpression in project kie-wb-common by kiegroup.
the class AddRelationColumnCommandTest method testGraphCommandExecuteWithRows.
@Test
public void testGraphCommandExecuteWithRows() {
relation.getRow().add(new List());
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(1, relation.getColumn().size());
assertEquals(informationItem, relation.getColumn().get(0));
assertEquals(RelationDefaultValueUtilities.PREFIX + "1", informationItem.getName().getValue());
assertEquals(1, relation.getRow().size());
assertEquals(1, relation.getRow().get(0).getExpression().size());
assertTrue(relation.getRow().get(0).getExpression().get(0).getExpression() instanceof LiteralExpression);
assertEquals(relation, informationItem.getParent());
assertEquals(relation.getRow().get(0), relation.getRow().get(0).getExpression().get(0).getExpression().getParent());
}
Aggregations