use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testCanvasCommandUndoWithRows.
@Test
public void testCanvasCommandUndoWithRows() {
final List rowList = new List();
relation.getRow().add(rowList);
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getText().setValue(VALUE);
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, literalExpression));
uiModel.appendRow(new BaseGridRow());
uiModelMapper.fromDMNModel(0, 1);
makeCommand();
// Delete column and then undo
final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
reset(command);
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.getRows().get(0).getCells().size());
assertEquals(VALUE, uiModel.getCell(0, 1).getValue().getValue());
verify(command).updateParentInformation();
verify(undoCanvasOperation).execute();
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteRelationColumnCommandTest method testGraphCommandExecuteWithRows.
@Test
public void testGraphCommandExecuteWithRows() {
final List rowList = new List();
relation.getRow().add(rowList);
relation.getRow().get(0).getExpression().add(HasExpression.wrap(rowList, new LiteralExpression()));
makeCommand();
final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler);
assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce));
assertEquals(0, relation.getColumn().size());
assertEquals(1, relation.getRow().size());
assertEquals(0, relation.getRow().get(0).getExpression().size());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class RegisterNodeCommandTest method makeLiteralExpression.
private LiteralExpression makeLiteralExpression(final String text) {
final LiteralExpression expression = new LiteralExpression();
expression.setId(new Id("0"));
expression.setText(new Text(text));
return expression;
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class JavaFunctionEditorDefinitionTest method testModelEnrichment.
@Test
public void testModelEnrichment() {
final Optional<Context> oModel = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, oModel);
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertEquals(JavaFunctionEditorDefinition.VARIABLE_CLASS, model.getContextEntry().get(0).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
assertEquals(model, model.getContextEntry().get(0).getParent());
assertEquals(JavaFunctionEditorDefinition.VARIABLE_METHOD_SIGNATURE, model.getContextEntry().get(1).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
assertEquals(model, model.getContextEntry().get(1).getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationEditorDefinitionTest method testModelEnrichment.
@Test
public void testModelEnrichment() {
final Optional<Invocation> oModel = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, oModel);
final Invocation model = oModel.get();
assertNotNull(model.getExpression());
assertTrue(model.getExpression() instanceof LiteralExpression);
assertEquals(1, model.getBinding().size());
assertNotNull(model.getBinding().get(0).getParameter());
assertEquals(InvocationDefaultValueUtilities.PREFIX + "1", model.getBinding().get(0).getParameter().getName().getValue());
assertNull(model.getBinding().get(0).getExpression());
assertNotNull(model.getId());
assertEquals(model, model.getExpression().getParent());
assertEquals(model, model.getBinding().get(0).getParent());
assertEquals(model.getBinding().get(0), model.getBinding().get(0).getParameter().getParent());
}
Aggregations