use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class ItemDefinitionUpdateHandlerTest method testMakeAllowedValuesWhenDataTypeConstraintIsNull.
@Test
public void testMakeAllowedValuesWhenDataTypeConstraintIsNull() {
final DataType dataType = mock(DataType.class);
final ItemDefinition itemDefinition = mock(ItemDefinition.class);
when(dataType.getConstraint()).thenReturn(null);
when(dataType.getConstraintType()).thenReturn(null);
final UnaryTests actualAllowedValues = handler.makeAllowedValues(dataType, itemDefinition);
assertNull(actualAllowedValues);
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method appendRow.
private void appendRow(final int rowIndex, final String rowIdentifier) {
final String inValue = "in " + rowIdentifier;
final String outValue = "out " + rowIdentifier;
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue(inValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue(outValue);
}
});
}
});
final GridRow uiRow = new BaseGridRow();
uiModel.appendRow(uiRow);
uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>(inValue));
uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>(outValue));
rowsUnderTest.add(uiRow);
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class BaseDecisionTableEditorDefinitionTest method assertParentHierarchyEnrichment.
protected void assertParentHierarchyEnrichment(final DecisionTable model) {
final List<DecisionRule> rules = model.getRule();
final DecisionRule rule = rules.get(0);
final int inputClauseCount = model.getInput().size();
final List<InputClause> inputClauses = model.getInput();
assertThat(inputClauses.size()).isEqualTo(inputClauseCount);
inputClauses.forEach(inputClause -> {
assertThat(inputClause.getParent()).isEqualTo(model);
assertThat(inputClause.getInputExpression().getParent()).isEqualTo(inputClause);
});
final int outputClauseCount = model.getOutput().size();
final List<OutputClause> outputClauses = model.getOutput();
assertThat(outputClauses.size()).isEqualTo(outputClauseCount);
outputClauses.forEach(outputClause -> assertThat(outputClause.getParent()).isEqualTo(model));
assertThat(rule.getParent()).isEqualTo(model);
final List<UnaryTests> inputEntries = rule.getInputEntry();
assertThat(inputEntries.size()).isEqualTo(inputClauseCount);
inputEntries.forEach(inputEntry -> assertThat(inputEntry.getParent()).isEqualTo(rule));
final List<LiteralExpression> outputEntries = rule.getOutputEntry();
assertThat(outputEntries.size()).isEqualTo(outputClauseCount);
outputEntries.forEach(outputEntry -> assertThat(outputEntry.getParent()).isEqualTo(rule));
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithInputs.
@Test
public void testCanvasCommandAddOutputClauseToRuleWithInputs() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final String ruleInputValue = "in value";
final String ruleOutputValue = "out value";
dtable.getInput().add(new InputClause());
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue(ruleInputValue);
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue(ruleOutputValue);
}
});
}
});
// Graph command populates OutputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getOutputEntry().get(0).getText().setValue(ruleOutputValue);
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendRow(new BaseGridRow());
uiModelMapper.fromDMNModel(0, 1);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddOutputClauseCommand.execute(canvasHandler);
assertEquals(ruleInputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
assertEquals(ruleOutputValue, uiModel.getRow(0).getCells().get(2).getValue().getValue());
assertEquals(3, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
assertEquals(2, uiModel.getColumnCount());
verify(executeCanvasOperation).execute();
verify(undoCanvasOperation).execute();
verify(command, times(2)).updateParentInformation();
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests 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