use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinition method getModelClass.
@Override
public Optional<DecisionTable> getModelClass() {
final DecisionTable dtable = new DecisionTable();
dtable.setHitPolicy(HitPolicy.ANY);
dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW);
final InputClause ic = new InputClause();
final LiteralExpression le = new LiteralExpression();
le.setText(INPUT_CLAUSE_EXPRESSION_TEXT);
ic.setInputExpression(le);
dtable.getInput().add(ic);
final OutputClause oc = new OutputClause();
oc.setName(OUTPUT_CLAUSE_NAME);
dtable.getOutput().add(oc);
final DecisionRule dr = new DecisionRule();
final UnaryTests drut = new UnaryTests();
drut.setText(INPUT_CLAUSE_UNARY_TEST_TEXT);
dr.getInputEntry().add(drut);
final LiteralExpression drle = new LiteralExpression();
drle.setText(OUTPUT_CLAUSE_EXPRESSION_TEXT);
dr.getOutputEntry().add(drle);
final Description d = new Description();
d.setValue(RULE_DESCRIPTION);
dr.setDescription(d);
dtable.getRule().add(dr);
return Optional.of(dtable);
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionTest method testModelDefinition.
@Test
public void testModelDefinition() {
final Optional<DecisionTable> oModel = definition.getModelClass();
assertThat(oModel).isPresent();
final DecisionTable model = oModel.get();
assertThat(model.getHitPolicy()).isEqualTo(HitPolicy.ANY);
assertThat(model.getPreferredOrientation()).isEqualTo(DecisionTableOrientation.RULE_AS_ROW);
final List<InputClause> input = model.getInput();
assertThat(input.size()).isEqualTo(1);
assertThat(input.get(0).getInputExpression()).isInstanceOf(LiteralExpression.class);
final List<OutputClause> output = model.getOutput();
assertThat(output.size()).isEqualTo(1);
final List<DecisionRule> rules = model.getRule();
assertThat(rules.size()).isEqualTo(1);
final DecisionRule rule = rules.get(0);
assertThat(rule.getInputEntry().size()).isEqualTo(1);
assertThat(rule.getInputEntry().get(0)).isInstanceOf(UnaryTests.class);
assertThat(rule.getOutputEntry().size()).isEqualTo(1);
assertThat(rule.getOutputEntry().get(0)).isInstanceOf(LiteralExpression.class);
assertThat(rule.getDescription()).isNotNull();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable 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 DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiInputClauseColumn);
this.uiModel.appendColumn(uiOutputClauseColumn);
this.uiModel.appendColumn(uiDescriptionColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
doReturn(3).when(uiDescriptionColumn).getIndex();
this.dtable = new DecisionTable();
this.dtable.getInput().add(new InputClause());
this.dtable.getOutput().add(new OutputClause());
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i1");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o1");
}
});
setDescription(new Description("desc1"));
}
});
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i2");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o2");
}
});
setDescription(new Description("desc2"));
}
});
this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.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);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.outputClause = new OutputClause();
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiOutputClauseColumn).getIndex();
}
Aggregations