use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class JavaFunctionEditorDefinition method getModelClass.
@Override
public Optional<Context> getModelClass() {
final Context context = new Context();
final ContextEntry classEntry = new ContextEntry();
final InformationItem classEntryVariable = new InformationItem();
classEntryVariable.setName(new Name(VARIABLE_CLASS));
classEntry.setVariable(classEntryVariable);
classEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(classEntry);
final ContextEntry methodSignatureEntry = new ContextEntry();
final InformationItem methodSignatureEntryVariable = new InformationItem();
methodSignatureEntryVariable.setName(new Name(VARIABLE_METHOD_SIGNATURE));
methodSignatureEntry.setVariable(methodSignatureEntryVariable);
methodSignatureEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(methodSignatureEntry);
return Optional.of(context);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationEditorDefinition method getModelClass.
@Override
public Optional<Invocation> getModelClass() {
final Invocation invocation = new Invocation();
invocation.setExpression(new LiteralExpression());
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p0"));
final Binding binding = new Binding();
binding.setParameter(parameter);
invocation.getBinding().add(binding);
return Optional.of(invocation);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithInputs.
@Test
public void testCanvasCommandAddOutputClauseToRuleWithInputs() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final String ruleInputValue = "in value";
final String ruleOutputValue = "out value";
dtable.getInput().add(new InputClause());
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText(ruleInputValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText(ruleOutputValue);
}
});
}
});
// Graph command populates OutputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getOutputEntry().get(0).setText(ruleOutputValue);
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendRow(new BaseGridRow());
uiModelMapper.fromDMNModel(0, 1);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddOutputClauseCommand.execute(canvasHandler);
assertEquals(ruleInputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
assertEquals(ruleOutputValue, uiModel.getRow(0).getCells().get(2).getValue().getValue());
assertEquals(3, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
assertEquals(2, uiModel.getColumnCount());
// one time in execute(), one time in undo()
verify(canvasOperation, times(2)).execute();
verify(command, times(2)).updateParentInformation();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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() {
{
setText(inValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText(outValue);
}
});
}
});
final DMNGridRow uiRow = new DMNGridRow();
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.v1_1.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(existingLiteralExpressionFirst);
row.getExpression().add(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(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));
assertTrue(relation.getRow().get(0).getExpression().get(1) instanceof LiteralExpression);
assertEquals(existingLiteralExpressionLast, relation.getRow().get(0).getExpression().get(2));
}
Aggregations