use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method testAddDecisionRule.
@Test
public void testAddDecisionRule() {
setupGrid(makeHasNameForDecision(), 0);
final DecisionTable dtable = grid.getExpression().get().get();
assertThat(dtable.getRule().size()).isEqualTo(1);
assertThat(dtable.getRule().get(0).getInputEntry().size()).isEqualTo(1);
assertThat(dtable.getRule().get(0).getOutputEntry().size()).isEqualTo(1);
addDecisionRule(0);
assertThat(dtable.getRule().size()).isEqualTo(2);
assertThat(dtable.getRule().get(1).getInputEntry().size()).isEqualTo(1);
assertThat(dtable.getRule().get(1).getOutputEntry().size()).isEqualTo(1);
verifyCommandExecuteOperation(BaseExpressionGrid.RESIZE_EXISTING);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableGridTest method testOutputClauseHasNameWrapperForHeaderMetaData.
@Test
@SuppressWarnings("unchecked")
public void testOutputClauseHasNameWrapperForHeaderMetaData() {
setupGrid(makeHasNameForDecision(), 0);
// More than one OutputClause column is required before the tested wrapper is instantiated.
addOutputClause(3);
final DecisionTable dtable = expression.get();
final OutputClause outputClause = dtable.getOutput().get(0);
final GridColumn.HeaderMetaData outputClauseHeaderMetaData = grid.getModel().getColumns().get(2).getHeaderMetaData().get(1);
assertThat(outputClause.getName()).isEqualTo(outputClauseHeaderMetaData.getTitle());
reset(sessionCommandManager);
extractHeaderMetaData(1, 2).setValue(new Name(NAME_NEW));
verify(sessionCommandManager).execute(eq(canvasHandler), compositeCommandCaptor.capture());
((AbstractCanvasGraphCommand) compositeCommandCaptor.getValue().getCommands().get(0)).execute(canvasHandler);
assertThat(outputClause.getName()).isEqualTo(NAME_NEW);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
factory = spy(new DecisionNavigatorNestedItemFactory(sessionManager, editExpressionEvent, dmnGraphUtils, expressionEditorDefinitionsSupplier, canvasSelectionEvent, boxedExpressionHelper, readOnlyProvider));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(decisionTableEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(decisionTableEditorDefinition.getModelClass()).thenReturn(Optional.of(new DecisionTable()));
when(decisionTableEditorDefinition.getName()).thenReturn(DECISION_TABLE_DEFINITION_NAME);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.outputClause = new OutputClause();
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiOutputClauseColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method testMoveSingleAnnotationColumnWithDuplicatedTitle.
@Test
public void testMoveSingleAnnotationColumnWithDuplicatedTitle() {
final DecisionTable decisionTable = new DecisionTable();
final DMNGridData model = new DMNGridData();
final RuleAnnotationClause clauseOne = new RuleAnnotationClause();
final RuleAnnotationClause clauseTwo = new RuleAnnotationClause();
final RuleAnnotationClause clauseThree = new RuleAnnotationClause();
decisionTable.getAnnotations().add(clauseOne);
decisionTable.getAnnotations().add(clauseTwo);
decisionTable.getAnnotations().add(clauseThree);
decisionTable.getRule().add(new DecisionRule() {
{
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
final RuleAnnotationClauseColumn columnOne = mock(RuleAnnotationClauseColumn.class);
final RuleAnnotationClauseColumn columnTwo = mock(RuleAnnotationClauseColumn.class);
final RuleAnnotationClauseColumn columnThree = mock(RuleAnnotationClauseColumn.class);
model.appendColumn(uiRowNumberColumn);
model.appendColumn(columnOne);
model.appendColumn(columnTwo);
model.appendColumn(columnThree);
when(columnOne.getIndex()).thenReturn(1);
when(columnOne.getIndex()).thenReturn(2);
when(columnOne.getIndex()).thenReturn(3);
command = new MoveColumnsCommand(decisionTable, model, 2, Arrays.asList(columnOne), canvasOperation);
graphCommand = command.newGraphCommand(canvasHandler);
canvasCommand = command.newCanvasCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasCommand.execute(canvasHandler));
}
Aggregations