Search in sources :

Example 1 with HasComponentWidths

use of org.kie.workbench.common.dmn.api.definition.HasComponentWidths in project kie-wb-common by kiegroup.

the class InvocationPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.Invocation dmn = new TInvocation();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(INVOCATION_UUID);
    dmn.setDescription(INVOCATION_DESCRIPTION);
    dmn.setTypeRef(new QName(INVOCATION_QNAME_LOCALPART));
    dmn.setExpression(literalExpression);
    final Invocation wb = InvocationPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(INVOCATION_UUID);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(INVOCATION_DESCRIPTION);
    assertThat(wb.getTypeRef()).isNotNull();
    assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : TInvocation(org.kie.dmn.model.v1_2.TInvocation) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) QName(javax.xml.namespace.QName) TInvocation(org.kie.dmn.model.v1_2.TInvocation) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Test(org.junit.Test)

Example 2 with HasComponentWidths

use of org.kie.workbench.common.dmn.api.definition.HasComponentWidths in project kie-wb-common by kiegroup.

the class ContextPropertyConverterTest method assertNoDefaultContextEntry.

private void assertNoDefaultContextEntry(final Context wb) {
    assertThat(wb).isNotNull();
    assertThat(wb.getContextEntry()).isNotNull();
    assertThat(wb.getContextEntry().size()).isEqualTo(1);
    assertThat(wb.getContextEntry().get(0)).isNotNull();
    assertThat(wb.getContextEntry().get(0).getExpression()).isInstanceOf(LiteralExpression.class);
    assertThat(wb.getContextEntry().get(0).getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getContextEntry().get(0).getExpression());
}
Also used : HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths)

Example 3 with HasComponentWidths

use of org.kie.workbench.common.dmn.api.definition.HasComponentWidths in project kie-wb-common by kiegroup.

the class FunctionDefinitionPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(FUNCTION_DEFINITION_UUID);
    dmn.setDescription(FUNCTION_DEFINITION_DESCRIPTION);
    dmn.setTypeRef(new QName(FUNCTION_DEFINITION_QNAME_LOCALPART));
    dmn.setKind(FunctionKind.JAVA);
    dmn.setExpression(literalExpression);
    final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(FUNCTION_DEFINITION_UUID);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(FUNCTION_DEFINITION_DESCRIPTION);
    assertThat(wb.getTypeRef()).isNotNull();
    assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(FUNCTION_DEFINITION_QNAME_LOCALPART);
    assertThat(wb.getKind()).isNotNull();
    assertThat(wb.getKind()).isEqualTo(FunctionDefinition.Kind.JAVA);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) QName(javax.xml.namespace.QName) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Test(org.junit.Test)

Example 4 with HasComponentWidths

use of org.kie.workbench.common.dmn.api.definition.HasComponentWidths in project kie-wb-common by kiegroup.

the class ContextPropertyConverterTest method assertDefaultContextEntry.

private void assertDefaultContextEntry(final Context wb) {
    assertThat(wb).isNotNull();
    assertThat(wb.getContextEntry()).isNotNull();
    assertThat(wb.getContextEntry().size()).isEqualTo(2);
    assertThat(wb.getContextEntry().get(0)).isNotNull();
    assertThat(wb.getContextEntry().get(0).getExpression()).isInstanceOf(LiteralExpression.class);
    assertThat(wb.getContextEntry().get(0).getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    assertThat(wb.getContextEntry().get(1)).isNotNull();
    assertThat(wb.getContextEntry().get(1).getExpression()).isNull();
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getContextEntry().get(0).getExpression());
}
Also used : HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths)

Example 5 with HasComponentWidths

use of org.kie.workbench.common.dmn.api.definition.HasComponentWidths in project kie-wb-common by kiegroup.

the class DecisionConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<Decision>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<Decision> view = new ViewImpl<>(new Decision(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(Decision.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.Decision dmn = new TDecision();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setId(DECISION_UUID);
    dmn.setName(DECISION_NAME);
    dmn.setDescription(DECISION_DESCRIPTION);
    dmn.setVariable(informationItem);
    dmn.setExpression(literalExpression);
    final Node<View<Decision>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final Decision wb = (Decision) DefinitionUtils.getElementDefinition(node);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(DECISION_UUID);
    assertThat(wb.getName()).isNotNull();
    assertThat(wb.getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_DESCRIPTION);
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_NAME);
    assertThat(wb.getExpression()).isNotNull();
    assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths).isNotNull();
    assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) TDecision(org.kie.dmn.model.v1_2.TDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) TDecision(org.kie.dmn.model.v1_2.TDecision) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Aggregations

HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)17 Test (org.junit.Test)10 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)9 QName (javax.xml.namespace.QName)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)7 List (java.util.List)5 BiConsumer (java.util.function.BiConsumer)5 Collectors (java.util.stream.Collectors)5 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)5 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Consumer (java.util.function.Consumer)4 TDecision (org.kie.dmn.model.v1_2.TDecision)4 DMNDefinitionSet (org.kie.workbench.common.dmn.api.DMNDefinitionSet)4 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)4 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)4 DMNModelInstrumentedBase (org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase)4