Search in sources :

Example 36 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.

the class DecisionTableGridTest method testDuplicateDecisionRule.

@Test
@SuppressWarnings("unchecked")
public void testDuplicateDecisionRule() {
    setupGrid(makeHasNameForDecision(), 0);
    final DecisionTable dtable = grid.getExpression().get().get();
    assertThat(dtable.getRule().size()).isEqualTo(1);
    final DecisionRule rule0 = dtable.getRule().get(0);
    assertThat(rule0.getInputEntry().size()).isEqualTo(1);
    assertThat(rule0.getOutputEntry().size()).isEqualTo(1);
    rule0.getInputEntry().get(0).getText().setValue("input");
    rule0.getOutputEntry().get(0).getText().setValue("output");
    rule0.getDescription().setValue("description");
    grid.duplicateDecisionRule(0);
    verify(sessionCommandManager).execute(eq(canvasHandler), addDecisionRuleCommandCaptor.capture());
    final AddDecisionRuleCommand addDecisionRuleCommand = addDecisionRuleCommandCaptor.getValue();
    addDecisionRuleCommand.execute(canvasHandler);
    assertThat(dtable.getRule().size()).isEqualTo(2);
    final DecisionRule rule1 = dtable.getRule().get(1);
    assertThat(rule1.getInputEntry().size()).isEqualTo(1);
    assertThat(rule1.getOutputEntry().size()).isEqualTo(1);
    assertThat(rule0.getInputEntry().get(0).getText().getValue()).isEqualTo("input");
    assertThat(rule0.getOutputEntry().get(0).getText().getValue()).isEqualTo("output");
    assertThat(rule0.getDescription().getValue()).isEqualTo("description");
    assertThat(rule1.getInputEntry().get(0).getText().getValue()).isEqualTo("input");
    assertThat(rule1.getOutputEntry().get(0).getText().getValue()).isEqualTo("output");
    assertThat(rule1.getDescription().getValue()).isEqualTo("description");
    verifyCommandExecuteOperation(BaseExpressionGrid.RESIZE_EXISTING);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Example 37 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.

the class AddInputClauseCommandTest method setUp.

@Before
public void setUp() throws Exception {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.inputClause = new InputClause();
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
}
Also used : 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) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Before(org.junit.Before)

Example 38 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.

the class DeleteInputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.inputClause = new InputClause();
    this.dtable.getInput().add(inputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiAnnotationClauseColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiAnnotationClauseColumn).getIndex();
}
Also used : 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) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Before(org.junit.Before)

Example 39 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.

the class DMNEditBusinessKnowledgeModelToolboxActionTest method testActionSetExpression.

@Test
public void testActionSetExpression() {
    tested.onMouseClick(canvasHandler, E_UUID, mouseClickEvent);
    final ArgumentCaptor<EditExpressionEvent> eventCaptor = ArgumentCaptor.forClass(EditExpressionEvent.class);
    verify(editExpressionEvent, times(1)).fire(eventCaptor.capture());
    final EditExpressionEvent editExprEvent = eventCaptor.getValue();
    final HasExpression hasExpression = editExprEvent.getHasExpression();
    Assertions.assertThatThrownBy(() -> hasExpression.setExpression(new DecisionTable())).isInstanceOf(UnsupportedOperationException.class).hasMessage("It is not possible to set the EncapsulatedLogic of a BusinessKnowledgeModel.");
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) EditExpressionEvent(org.kie.workbench.common.dmn.client.events.EditExpressionEvent) Test(org.junit.Test)

Example 40 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.

the class SetBuiltinAggregatorCommandTest method makeCommand.

private void makeCommand(final BuiltinAggregator aggregator) {
    this.dtable = new DecisionTable();
    this.dtable.setAggregation(aggregator);
    this.command = new SetBuiltinAggregatorCommand(dtable, NEW_AGGREGATOR, canvasOperation);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable)

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