use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final FunctionDefinition wb = new FunctionDefinition();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(FUNCTION_DEFINITION_UUID);
wb.getDescription().setValue(FUNCTION_DEFINITION_DESCRIPTION);
wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, FUNCTION_DEFINITION_QNAME_LOCALPART));
wb.setKind(FunctionDefinition.Kind.JAVA);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.FunctionDefinition dmn = FunctionDefinitionPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(FUNCTION_DEFINITION_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(FUNCTION_DEFINITION_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(FUNCTION_DEFINITION_QNAME_LOCALPART);
assertThat(dmn.getKind()).isNotNull();
assertThat(dmn.getKind()).isEqualTo(FunctionKind.JAVA);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final Invocation wb = new Invocation();
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(INVOCATION_UUID);
wb.getDescription().setValue(INVOCATION_DESCRIPTION);
wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, INVOCATION_QNAME_LOCALPART));
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.Invocation dmn = InvocationPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(INVOCATION_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(INVOCATION_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final ContextEntry wb = new ContextEntry();
final InformationItem informationItem = new InformationItem();
wb.setVariable(informationItem);
final LiteralExpression literalExpression = new LiteralExpression();
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.setExpression(literalExpression);
final org.kie.dmn.model.api.ContextEntry dmn = ContextEntryPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getVariable()).isNotNull();
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverterTest method testDMNFromWB_LiteralExpressionConversion.
@Test
public void testDMNFromWB_LiteralExpressionConversion() {
final LiteralExpression wb = new LiteralExpression();
final List<Double> wbComponentWidths = wb.getComponentWidths();
wbComponentWidths.set(0, 200.0);
wb.getId().setValue(EXPRESSION_UUID);
assertDMNFromWBConversion(wb, TLiteralExpression.class, 200.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testGraphCommandExecute.
@Test
public void testGraphCommandExecute() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
dtable.getRule().add(new DecisionRule());
dtable.getRule().add(new DecisionRule());
assertEquals(0, dtable.getOutput().size());
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
// one new output column
assertEquals(1, dtable.getOutput().size());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_PREFIX + "1", dtable.getOutput().get(0).getName());
// first rule
final List<LiteralExpression> outputEntriesRuleOne = dtable.getRule().get(0).getOutputEntry();
assertEquals(1, outputEntriesRuleOne.size());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleOne.get(0).getText().getValue());
assertEquals(dtable.getRule().get(0), outputEntriesRuleOne.get(0).getParent());
// second rule
final List<LiteralExpression> outputEntriesRuleTwo = dtable.getRule().get(1).getOutputEntry();
assertEquals(1, outputEntriesRuleTwo.size());
assertEquals(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT, outputEntriesRuleTwo.get(0).getText().getValue());
assertEquals(dtable.getRule().get(1), outputEntriesRuleTwo.get(0).getParent());
assertEquals(dtable, outputClause.getParent());
}
Aggregations