Search in sources :

Example 31 with UnaryTests

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

the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeConstraintIsNull.

@Test
public void testMakeAllowedValuesWhenDataTypeConstraintIsNull() {
    final DataType dataType = mock(DataType.class);
    final ItemDefinition itemDefinition = mock(ItemDefinition.class);
    when(dataType.getConstraint()).thenReturn(null);
    when(dataType.getConstraintType()).thenReturn(null);
    final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
    assertNull(actualAllowedValues);
}
Also used : ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) Test(org.junit.Test)

Example 32 with UnaryTests

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

the class MoveRowsCommandTest method appendRow.

private void appendRow(final int rowIndex, final String rowIdentifier) {
    final String inValue = "in " + rowIdentifier;
    final String outValue = "out " + rowIdentifier;
    dtable.getRule().add(new DecisionRule() {

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

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

                {
                    getText().setValue(outValue);
                }
            });
        }
    });
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
    rowsUnderTest.add(uiRow);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 33 with UnaryTests

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

the class BaseDecisionTableEditorDefinitionTest method assertParentHierarchyEnrichment.

protected void assertParentHierarchyEnrichment(final DecisionTable model) {
    final List<DecisionRule> rules = model.getRule();
    final DecisionRule rule = rules.get(0);
    final int inputClauseCount = model.getInput().size();
    final List<InputClause> inputClauses = model.getInput();
    assertThat(inputClauses.size()).isEqualTo(inputClauseCount);
    inputClauses.forEach(inputClause -> {
        assertThat(inputClause.getParent()).isEqualTo(model);
        assertThat(inputClause.getInputExpression().getParent()).isEqualTo(inputClause);
    });
    final int outputClauseCount = model.getOutput().size();
    final List<OutputClause> outputClauses = model.getOutput();
    assertThat(outputClauses.size()).isEqualTo(outputClauseCount);
    outputClauses.forEach(outputClause -> assertThat(outputClause.getParent()).isEqualTo(model));
    assertThat(rule.getParent()).isEqualTo(model);
    final List<UnaryTests> inputEntries = rule.getInputEntry();
    assertThat(inputEntries.size()).isEqualTo(inputClauseCount);
    inputEntries.forEach(inputEntry -> assertThat(inputEntry.getParent()).isEqualTo(rule));
    final List<LiteralExpression> outputEntries = rule.getOutputEntry();
    assertThat(outputEntries.size()).isEqualTo(outputClauseCount);
    outputEntries.forEach(outputEntry -> assertThat(outputEntry.getParent()).isEqualTo(rule));
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause)

Example 34 with UnaryTests

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

the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithInputs.

@Test
public void testCanvasCommandAddOutputClauseToRuleWithInputs() throws Exception {
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
    final String ruleInputValue = "in value";
    final String ruleOutputValue = "out value";
    dtable.getInput().add(new InputClause());
    dtable.getRule().add(new DecisionRule() {

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

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

                {
                    getText().setValue(ruleOutputValue);
                }
            });
        }
    });
    // Graph command populates OutputEntries so overwrite with test values
    final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
    graphCommand.execute(graphCommandExecutionContext);
    dtable.getRule().get(0).getOutputEntry().get(0).getText().setValue(ruleOutputValue);
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    uiModel.appendColumn(uiInputClauseColumn);
    uiModel.appendRow(new BaseGridRow());
    uiModelMapper.fromDMNModel(0, 1);
    final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
    canvasAddOutputClauseCommand.execute(canvasHandler);
    assertEquals(ruleInputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
    assertEquals(ruleOutputValue, uiModel.getRow(0).getCells().get(2).getValue().getValue());
    assertEquals(3, uiModel.getColumnCount());
    assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
    assertEquals(2, uiModel.getColumnCount());
    verify(executeCanvasOperation).execute();
    verify(undoCanvasOperation).execute();
    verify(command, times(2)).updateParentInformation();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) 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) Test(org.junit.Test)

Example 35 with UnaryTests

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

Aggregations

UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)36 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)16 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)16 Test (org.junit.Test)15 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)13 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)10 InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)9 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)6 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)6 ConstraintType (org.kie.workbench.common.dmn.api.definition.model.ConstraintType)5 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)5 InputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression)4 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)4 JSITUnaryTests (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests)4 List (java.util.List)3 Before (org.junit.Before)3