use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method testMoveSingleAnnotationColumnWithDuplicatedTitle.
@Test
public void testMoveSingleAnnotationColumnWithDuplicatedTitle() {
final DecisionTable decisionTable = new DecisionTable();
final DMNGridData model = new DMNGridData();
final RuleAnnotationClause clauseOne = new RuleAnnotationClause();
final RuleAnnotationClause clauseTwo = new RuleAnnotationClause();
final RuleAnnotationClause clauseThree = new RuleAnnotationClause();
decisionTable.getAnnotations().add(clauseOne);
decisionTable.getAnnotations().add(clauseTwo);
decisionTable.getAnnotations().add(clauseThree);
decisionTable.getRule().add(new DecisionRule() {
{
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
final RuleAnnotationClauseColumn columnOne = mock(RuleAnnotationClauseColumn.class);
final RuleAnnotationClauseColumn columnTwo = mock(RuleAnnotationClauseColumn.class);
final RuleAnnotationClauseColumn columnThree = mock(RuleAnnotationClauseColumn.class);
model.appendColumn(uiRowNumberColumn);
model.appendColumn(columnOne);
model.appendColumn(columnTwo);
model.appendColumn(columnThree);
when(columnOne.getIndex()).thenReturn(1);
when(columnOne.getIndex()).thenReturn(2);
when(columnOne.getIndex()).thenReturn(3);
command = new MoveColumnsCommand(decisionTable, model, 2, Arrays.asList(columnOne), canvasOperation);
graphCommand = command.newGraphCommand(canvasHandler);
canvasCommand = command.newCanvasCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasCommand.execute(canvasHandler));
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause 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);
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class DecisionTableDefaultValueUtilitiesTest method testGetNewRuleAnnotationClauseName.
@Test
public void testGetNewRuleAnnotationClauseName() {
final RuleAnnotationClause ruleAnnotationClause1 = new RuleAnnotationClause();
dtable.getAnnotations().add(ruleAnnotationClause1);
ruleAnnotationClause1.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable));
assertThat(ruleAnnotationClause1.getName().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_PREFIX + "1");
final RuleAnnotationClause ruleAnnotationClause2 = new RuleAnnotationClause();
dtable.getAnnotations().add(ruleAnnotationClause2);
ruleAnnotationClause2.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable));
assertThat(ruleAnnotationClause2.getName().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.RULE_ANNOTATION_CLAUSE_PREFIX + "2");
}
Aggregations