Search in sources :

Example 31 with InputClause

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

the class DecisionTableDefaultValueUtilitiesTest method testGetNewInputClauseNameWithDeletion.

@Test
public void testGetNewInputClauseNameWithDeletion() {
    final InputClause inputClause1 = new InputClause() {

        {
            setInputExpression(new InputClauseLiteralExpression());
        }
    };
    dtable.getInput().add(inputClause1);
    inputClause1.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
    assertThat(inputClause1.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "1");
    final InputClause inputClause2 = new InputClause() {

        {
            setInputExpression(new InputClauseLiteralExpression());
        }
    };
    dtable.getInput().add(inputClause2);
    inputClause2.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
    assertThat(inputClause2.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "2");
    dtable.getInput().remove(inputClause1);
    final InputClause inputClause3 = new InputClause() {

        {
            setInputExpression(new InputClauseLiteralExpression());
        }
    };
    dtable.getInput().add(inputClause3);
    inputClause3.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
    assertThat(inputClause3.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "3");
}
Also used : InputClauseLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Test(org.junit.Test)

Example 32 with InputClause

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

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenTopLevelDecisionTableWithDecision.

@Test
@SuppressWarnings("unchecked")
public void testModelEnrichmentWhenTopLevelDecisionTableWithDecision() {
    setupGraphWithDiagram();
    setupGraphWithDecision();
    final Optional<DecisionTable> oModel = definition.getModelClass();
    definition.enrich(Optional.of(NODE_UUID), decision, oModel);
    final DecisionTable model = oModel.get();
    assertBasicEnrichment(model);
    final List<InputClause> input = model.getInput();
    assertThat(input.size()).isEqualTo(1);
    assertThat(input.get(0).getInputExpression()).isInstanceOf(InputClauseLiteralExpression.class);
    assertThat(input.get(0).getInputExpression().getText().getValue()).isEqualTo(DECISION_NAME_1);
    assertThat(input.get(0).getInputExpression().getTypeRef()).isEqualTo(DECISION_QNAME_1);
    assertStandardOutputClauseEnrichment(model);
    assertStandardDecisionRuleEnrichment(model);
    assertParentHierarchyEnrichment(model);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Test(org.junit.Test)

Example 33 with InputClause

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

the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenTopLevelDecisionTableWithDecisionAndInputData.

@Test
@SuppressWarnings("unchecked")
public void testModelEnrichmentWhenTopLevelDecisionTableWithDecisionAndInputData() {
    setupGraphWithDiagram();
    setupGraphWithDecision();
    setupGraphWithInputData();
    final Optional<DecisionTable> oModel = definition.getModelClass();
    definition.enrich(Optional.of(NODE_UUID), decision, oModel);
    final DecisionTable model = oModel.get();
    assertBasicEnrichment(model);
    final List<InputClause> input = model.getInput();
    assertThat(input.size()).isEqualTo(3);
    assertThat(input.get(0).getInputExpression()).isInstanceOf(InputClauseLiteralExpression.class);
    assertThat(input.get(0).getInputExpression().getText().getValue()).isEqualTo(INPUT_DATA_NAME_2);
    assertThat(input.get(0).getInputExpression().getTypeRef()).isEqualTo(INPUT_DATA_QNAME_2);
    assertThat(input.get(1).getInputExpression()).isInstanceOf(InputClauseLiteralExpression.class);
    assertThat(input.get(1).getInputExpression().getText().getValue()).isEqualTo(DECISION_NAME_1);
    assertThat(input.get(1).getInputExpression().getTypeRef()).isEqualTo(DECISION_QNAME_1);
    assertThat(input.get(2).getInputExpression()).isInstanceOf(InputClauseLiteralExpression.class);
    assertThat(input.get(2).getInputExpression().getText().getValue()).isEqualTo(INPUT_DATA_NAME_1);
    assertThat(input.get(2).getInputExpression().getTypeRef()).isEqualTo(INPUT_DATA_QNAME_1);
    assertStandardOutputClauseEnrichment(model);
    assertStandardDecisionRuleEnrichment(model);
    assertParentHierarchyEnrichment(model);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) Test(org.junit.Test)

Aggregations

InputClause (org.kie.workbench.common.dmn.api.definition.model.InputClause)33 Test (org.junit.Test)18 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)14 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)11 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)10 RuleAnnotationClause (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause)10 InputClauseLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression)8 UnaryTests (org.kie.workbench.common.dmn.api.definition.model.UnaryTests)8 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)7 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)5 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 Before (org.junit.Before)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)3 RuleAnnotationClauseText (org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText)3 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)3