Search in sources :

Example 16 with RuleAnnotationClause

use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause 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)

Example 17 with RuleAnnotationClause

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

the class DecisionTableUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiAnnotationClauseColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    doReturn(3).when(uiAnnotationClauseColumn).getIndex();
    this.dtable = new DecisionTable();
    this.dtable.getInput().add(new InputClause());
    this.dtable.getOutput().add(new OutputClause());
    this.dtable.getAnnotations().add(new RuleAnnotationClause());
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    getText().setValue("i1");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue("o1");
                }
            });
            getAnnotationEntry().add(new RuleAnnotationClauseText() {

                {
                    getText().setValue("a1");
                }
            });
        }
    });
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    getText().setValue("i2");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue("o2");
                }
            });
            getAnnotationEntry().add(new RuleAnnotationClauseText() {

                {
                    getText().setValue("a2");
                }
            });
        }
    });
    this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Before(org.junit.Before)

Example 18 with RuleAnnotationClause

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

the class DecisionTableDefaultValueUtilitiesTest method testGetNewRuleAnnotationClauseName.

@Test
public void testGetNewRuleAnnotationClauseName() {
    final RuleAnnotationClause ruleAnnotationClause1 = new RuleAnnotationClause();
    dtable.getAnnotations().add(ruleAnnotationClause1);
    ruleAnnotationClause1.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable));
    assertThat(ruleAnnotationClause1.getName().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_PREFIX + "1");
    final RuleAnnotationClause ruleAnnotationClause2 = new RuleAnnotationClause();
    dtable.getAnnotations().add(ruleAnnotationClause2);
    ruleAnnotationClause2.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable));
    assertThat(ruleAnnotationClause2.getName().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_PREFIX + "2");
}
Also used : RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) Test(org.junit.Test)

Aggregations

RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)18 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)9 Test (org.junit.Test)8 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)5 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)4 JSITRuleAnnotationClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRuleAnnotationClause)3 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)3 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)3 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)3 Before (org.junit.Before)2 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 JSITDecisionRule (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionRule)2 JSITDecisionTable (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable)2 JSITInputClause (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause)2