use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method wbFromDMN.
public static UnaryTests wbFromDMN(final org.kie.dmn.model.api.UnaryTests dmn) {
if (dmn == null) {
return null;
}
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
final ConstraintType constraintTypeField;
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
if (dmn.getAdditionalAttributes().containsKey(key)) {
constraintTypeField = ConstraintTypeFieldPropertyConverter.wbFromDMN(dmn.getAdditionalAttributes().get(key));
} else {
constraintTypeField = NONE;
}
final UnaryTests result = new UnaryTests(id, description, new Text(dmn.getText()), expressionLanguage, constraintTypeField);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method setUp.
@Before
public void setUp() {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClauseOne);
dtable.getInput().add(inputClauseTwo);
dtable.getInput().add(inputClauseThree);
dtable.getOutput().add(outputClauseOne);
dtable.getOutput().add(outputClauseTwo);
dtable.getOutput().add(outputClauseThree);
dtable.getAnnotations().add(annotationClauseOne);
dtable.getAnnotations().add(annotationClauseTwo);
dtable.getAnnotations().add(annotationClauseThree);
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumnOne);
uiModel.appendColumn(uiInputClauseColumnTwo);
uiModel.appendColumn(uiInputClauseColumnThree);
uiModel.appendColumn(uiOutputClauseColumnOne);
uiModel.appendColumn(uiOutputClauseColumnTwo);
uiModel.appendColumn(uiOutputClauseColumnThree);
uiModel.appendColumn(uiRuleAnnotationClauseColumnOne);
uiModel.appendColumn(uiRuleAnnotationClauseColumnTwo);
uiModel.appendColumn(uiRuleAnnotationClauseColumnThree);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumnOne).getIndex();
doReturn(2).when(uiInputClauseColumnTwo).getIndex();
doReturn(3).when(uiInputClauseColumnThree).getIndex();
doReturn(4).when(uiOutputClauseColumnOne).getIndex();
doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
doReturn(6).when(uiOutputClauseColumnThree).getIndex();
doReturn(7).when(uiRuleAnnotationClauseColumnOne).getIndex();
doReturn(8).when(uiRuleAnnotationClauseColumnTwo).getIndex();
doReturn(9).when(uiRuleAnnotationClauseColumnThree).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandExecuteExistingNotAffected.
@Test
public void testGraphCommandExecuteExistingNotAffected() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOldInput = "old rule 1";
final String ruleTwoOldInput = "old rule 2";
dtable.getInput().add(new InputClause());
addRuleWithInputClauseValues(ruleOneOldInput);
addRuleWithInputClauseValues(ruleTwoOldInput);
assertEquals(1, dtable.getInput().size());
// Graph command will insert new InputClause at index 0 of the InputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getInput().size());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "1", dtable.getInput().get(0).getInputExpression().getText().getValue());
assertNotNull(dtable.getInput().get(1).getInputExpression());
// first rule
final List<UnaryTests> inputEntriesRuleOne = dtable.getRule().get(0).getInputEntry();
assertEquals(2, inputEntriesRuleOne.size());
assertEquals(ruleOneOldInput, inputEntriesRuleOne.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT, inputEntriesRuleOne.get(0).getText().getValue());
assertEquals(dtable.getRule().get(0), inputEntriesRuleOne.get(0).getParent());
// second rule
final List<UnaryTests> inputEntriesRuleTwo = dtable.getRule().get(1).getInputEntry();
assertEquals(2, inputEntriesRuleTwo.size());
assertEquals(ruleTwoOldInput, inputEntriesRuleTwo.get(1).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT, inputEntriesRuleTwo.get(0).getText().getValue());
assertEquals(dtable.getRule().get(1), inputEntriesRuleTwo.get(0).getParent());
assertEquals(dtable, inputClause.getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class DeleteInputClauseCommandTest method testGraphCommandExecuteRemoveMiddle.
@Test
public void testGraphCommandExecuteRemoveMiddle() {
final InputClause firstInput = mock(InputClause.class);
final InputClause lastInput = mock(InputClause.class);
dtable.getInput().add(0, firstInput);
dtable.getInput().add(lastInput);
final UnaryTests inputOneValue = mock(UnaryTests.class);
final UnaryTests inputTwoValue = mock(UnaryTests.class);
final UnaryTests inputThreeValue = mock(UnaryTests.class);
final DecisionRule rule = new DecisionRule();
rule.getInputEntry().add(inputOneValue);
rule.getInputEntry().add(inputTwoValue);
rule.getInputEntry().add(inputThreeValue);
dtable.getRule().add(rule);
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(2, dtable.getInput().size());
assertEquals(firstInput, dtable.getInput().get(0));
assertEquals(lastInput, dtable.getInput().get(1));
assertEquals(2, dtable.getRule().get(0).getInputEntry().size());
assertEquals(inputOneValue, dtable.getRule().get(0).getInputEntry().get(0));
assertEquals(inputThreeValue, dtable.getRule().get(0).getInputEntry().get(1));
}
use of org.kie.workbench.common.dmn.api.definition.model.UnaryTests in project kie-wb-common by kiegroup.
the class ItemDefinitionPropertyConverterTest method testSetUnaryTestsWhenUnaryTestsIsNull.
@Test
public void testSetUnaryTestsWhenUnaryTestsIsNull() {
final ItemDefinition wb = mock(ItemDefinition.class);
final UnaryTests wbAllowedValues = mock(UnaryTests.class);
final org.kie.dmn.model.api.ItemDefinition dmn = mock(org.kie.dmn.model.api.ItemDefinition.class);
final org.kie.dmn.model.api.UnaryTests dmnAllowedValues = null;
when(dmn.getAllowedValues()).thenReturn(dmnAllowedValues);
setUnaryTests(wb, dmn);
verify(wb, never()).setAllowedValues(wbAllowedValues);
verify(wbAllowedValues, never()).setParent(wb);
}
Aggregations