Search in sources :

Example 16 with DecisionTable

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

the class DecisionTablePropertyConverterTest method testDMNFromWBMultipleOutputClauseTypeRef.

@Test
public void testDMNFromWBMultipleOutputClauseTypeRef() {
    final DecisionTable wb = new DecisionTable();
    final OutputClause wbOutputClause1 = new OutputClause();
    final OutputClause wbOutputClause2 = new OutputClause();
    wb.getId().setValue(UUID);
    wb.getDescription().setValue(DESCRIPTION);
    wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(NULL_NS_URI, QNAME_LOCALPART));
    wbOutputClause1.setName(NAME + "-oc1");
    wbOutputClause2.setName(NAME + "-oc2");
    wbOutputClause1.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(NULL_NS_URI, QNAME_LOCALPART + "-oc1"));
    wbOutputClause2.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(NULL_NS_URI, QNAME_LOCALPART + "-oc2"));
    wb.getOutput().add(wbOutputClause1);
    wb.getOutput().add(wbOutputClause2);
    final org.kie.dmn.model.api.DecisionTable dmn = DecisionTablePropertyConverter.dmnFromWB(wb);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(UUID);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(DESCRIPTION);
    assertThat(dmn.getTypeRef()).isNotNull();
    assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART);
    assertThat(dmn.getOutput()).hasSize(2);
    final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = dmn.getOutput().get(0);
    final org.kie.dmn.model.api.OutputClause dmnOutputClause2 = dmn.getOutput().get(1);
    assertThat(dmnOutputClause1.getName()).isEqualTo(NAME + "-oc1");
    assertThat(dmnOutputClause2.getName()).isEqualTo(NAME + "-oc2");
    assertThat(dmnOutputClause1.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc1");
    assertThat(dmnOutputClause2.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc2");
}
Also used : TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) Test(org.junit.Test)

Example 17 with DecisionTable

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

the class ExpressionPropertyConverterTest method testDMNFromWB_DecisionTableConversion.

@Test
public void testDMNFromWB_DecisionTableConversion() {
    final DecisionTable wb = new DecisionTable();
    final List<Double> wbComponentWidths = wb.getComponentWidths();
    wbComponentWidths.set(0, 100.0);
    wb.getId().setValue(EXPRESSION_UUID);
    assertDMNFromWBConversion(wb, TDecisionTable.class, 100.0);
}
Also used : TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Test(org.junit.Test)

Example 18 with DecisionTable

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

the class AddDecisionRuleCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModelRow = new BaseGridRow();
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    doReturn(3).when(uiRuleAnnotationClauseColumn).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) 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 19 with DecisionTable

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

the class DeleteDecisionRuleCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.rule = new DecisionRule();
    this.dtable.getRule().add(rule);
    this.uiModel = new DMNGridData();
    this.uiModelRow = new BaseGridRow();
    this.uiModel.appendRow(uiModelRow);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Before(org.junit.Before)

Example 20 with DecisionTable

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

the class DeleteOutputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.outputClause = new OutputClause();
    this.dtable.getOutput().add(outputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiRuleAnnotationClauseColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
    makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size());
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiOutputClauseColumn).getIndex();
    doReturn(2).when(uiRuleAnnotationClauseColumn).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)

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