use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DeleteOutputClauseCommandTest method testGraphCommandExecuteRemoveMiddle.
@Test
public void testGraphCommandExecuteRemoveMiddle() {
final OutputClause firstOutput = mock(OutputClause.class);
final OutputClause lastOutput = mock(OutputClause.class);
dtable.getOutput().add(0, firstOutput);
dtable.getOutput().add(lastOutput);
final LiteralExpression outputOneValue = mock(LiteralExpression.class);
final LiteralExpression outputTwoValue = mock(LiteralExpression.class);
final LiteralExpression outputThreeValue = mock(LiteralExpression.class);
final DecisionRule rule = new DecisionRule();
rule.getOutputEntry().add(outputOneValue);
rule.getOutputEntry().add(outputTwoValue);
rule.getOutputEntry().add(outputThreeValue);
dtable.getRule().add(rule);
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size() + 1);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getOutput().size());
assertEquals(firstOutput, dtable.getOutput().get(0));
assertEquals(lastOutput, dtable.getOutput().get(1));
assertEquals(2, dtable.getRule().get(0).getOutputEntry().size());
assertEquals(outputOneValue, dtable.getRule().get(0).getOutputEntry().get(0));
assertEquals(outputThreeValue, dtable.getRule().get(0).getOutputEntry().get(1));
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method setUp.
@Before
public void setUp() {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClauseOne);
dtable.getInput().add(inputClauseTwo);
dtable.getInput().add(inputClauseThree);
dtable.getOutput().add(outputClauseOne);
dtable.getOutput().add(outputClauseTwo);
dtable.getOutput().add(outputClauseThree);
dtable.getAnnotations().add(annotationClauseOne);
dtable.getAnnotations().add(annotationClauseTwo);
dtable.getAnnotations().add(annotationClauseThree);
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumnOne);
uiModel.appendColumn(uiInputClauseColumnTwo);
uiModel.appendColumn(uiInputClauseColumnThree);
uiModel.appendColumn(uiOutputClauseColumnOne);
uiModel.appendColumn(uiOutputClauseColumnTwo);
uiModel.appendColumn(uiOutputClauseColumnThree);
uiModel.appendColumn(uiRuleAnnotationClauseColumnOne);
uiModel.appendColumn(uiRuleAnnotationClauseColumnTwo);
uiModel.appendColumn(uiRuleAnnotationClauseColumnThree);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumnOne).getIndex();
doReturn(2).when(uiInputClauseColumnTwo).getIndex();
doReturn(3).when(uiInputClauseColumnThree).getIndex();
doReturn(4).when(uiOutputClauseColumnOne).getIndex();
doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
doReturn(6).when(uiOutputClauseColumnThree).getIndex();
doReturn(7).when(uiRuleAnnotationClauseColumnOne).getIndex();
doReturn(8).when(uiRuleAnnotationClauseColumnTwo).getIndex();
doReturn(9).when(uiRuleAnnotationClauseColumnThree).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class HasExpressionTest method testWrapNonNull.
@Test
public void testWrapNonNull() {
final LiteralExpression le = new LiteralExpression();
final HasExpression hasExpression = HasExpression.wrap(parent, le);
assertNotNull(hasExpression.getExpression());
assertEquals(le, hasExpression.getExpression());
assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
final Context context = new Context();
hasExpression.setExpression(context);
assertNotNull(hasExpression.getExpression());
assertEquals(context, hasExpression.getExpression());
assertEquals(parent, hasExpression.asDMNModelInstrumentedBase());
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ListEditorDefinition method enrich.
@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<List> expression) {
expression.ifPresent(list -> {
final LiteralExpression literalExpression = new LiteralExpression();
list.getExpression().add(HasExpression.wrap(list, literalExpression));
literalExpression.setParent(list);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ListGrid method addRow.
void addRow(final int index) {
getExpression().get().ifPresent(list -> {
final GridRow listRow = new ExpressionEditorGridRow();
final HasExpression hasExpression = HasExpression.wrap(list, new LiteralExpression());
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddListRowCommand(list, hasExpression, model, listRow, index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
});
}
Aggregations