Search in sources :

Example 41 with DecisionTable

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);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Test(org.junit.Test)

Example 42 with DecisionTable

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);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) AbstractCanvasGraphCommand(org.kie.workbench.common.stunner.core.client.canvas.command.AbstractCanvasGraphCommand) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 43 with DecisionTable

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);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Before(org.junit.Before)

Example 44 with DecisionTable

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();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 45 with DecisionTable

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));
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) RuleAnnotationClauseColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.RuleAnnotationClauseColumn) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Aggregations

DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)56 Test (org.junit.Test)32 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)22 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)17 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)15 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)12 Before (org.junit.Before)11 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)10 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)9 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)8 Context (org.kie.workbench.common.dmn.api.definition.model.Context)7 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)7 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)7 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6 TDecisionTable (org.kie.dmn.model.v1_2.TDecisionTable)5 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)5