use of org.kie.workbench.common.dmn.api.definition.model.OutputClause in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandExecuteInsertMiddle.
@Test
public void testGraphCommandExecuteInsertMiddle() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final String ruleOutputOne = "rule out 1";
final String ruleOutputTwo = "rule out 2";
dtable.getOutput().add(new OutputClause());
dtable.getOutput().add(new OutputClause());
addRuleWithOutputClauseValues(ruleOutputOne, ruleOutputTwo);
assertEquals(2, dtable.getOutput().size());
// Graph command will insert new OutputClause at index 1 of the OutputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(3, dtable.getOutput().size());
assertNull(dtable.getOutput().get(0).getName());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_PREFIX + "1", dtable.getOutput().get(1).getName());
assertNull(dtable.getOutput().get(2).getName());
final List<LiteralExpression> ruleOutputs = dtable.getRule().get(0).getOutputEntry();
// first rule
assertEquals(3, ruleOutputs.size());
assertEquals(ruleOutputOne, ruleOutputs.get(0).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, ruleOutputs.get(1).getText().getValue());
assertEquals(dtable.getRule().get(0), ruleOutputs.get(1).getParent());
assertEquals(ruleOutputTwo, ruleOutputs.get(2).getText().getValue());
assertEquals(dtable, outputClause.getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClause 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, DEFAULT_HEIGHT);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiOutputClauseColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenParentIsContextEntryDefaultResult.
@Test
public void testModelEnrichmentWhenParentIsContextEntryDefaultResult() {
final String name = "decision";
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
context.getContextEntry().add(contextEntry);
contextEntry.setParent(context);
context.setParent(decision);
decision.setName(new Name(name));
decision.getVariable().setTypeRef(OUTPUT_DATA_QNAME);
final Optional<DecisionTable> oModel = definition.getModelClass();
oModel.get().setParent(contextEntry);
definition.enrich(Optional.empty(), decision, oModel);
final DecisionTable model = oModel.get();
assertBasicEnrichment(model);
assertStandardInputClauseEnrichment(model);
final List<OutputClause> output = model.getOutput();
assertThat(output.size()).isEqualTo(1);
assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME);
assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME);
assertStandardDecisionRuleEnrichment(model);
assertParentHierarchyEnrichment(model);
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricherTest method testModelEnrichmentWhenParentIsNestedContextEntryDefaultResult.
@Test
public void testModelEnrichmentWhenParentIsNestedContextEntryDefaultResult() {
final Decision decision = mock(Decision.class);
final String name = "context-entry";
final Context innerContext = new Context();
final ContextEntry innerContextEntry = new ContextEntry();
innerContext.getContextEntry().add(innerContextEntry);
innerContextEntry.setParent(innerContext);
final Context outerContext = new Context();
final ContextEntry outerContextEntry = new ContextEntry();
outerContext.getContextEntry().add(outerContextEntry);
outerContextEntry.setParent(outerContext);
innerContext.setParent(outerContextEntry);
outerContext.setParent(decision);
outerContextEntry.setVariable(new InformationItem(new Id(), new Description(), new Name(name), OUTPUT_DATA_QNAME));
when(decision.asDMNModelInstrumentedBase()).thenReturn(outerContextEntry);
final Optional<DecisionTable> oModel = definition.getModelClass();
oModel.get().setParent(innerContextEntry);
definition.enrich(Optional.empty(), decision, oModel);
final DecisionTable model = oModel.get();
assertBasicEnrichment(model);
assertStandardInputClauseEnrichment(model);
final List<OutputClause> output = model.getOutput();
assertThat(output.size()).isEqualTo(1);
assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME);
assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME);
assertStandardDecisionRuleEnrichment(model);
assertParentHierarchyEnrichment(model);
}
use of org.kie.workbench.common.dmn.api.definition.model.OutputClause 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);
}
Aggregations