Search in sources :

Example 6 with TLiteralExpression

use of org.kie.dmn.model.v1_2.TLiteralExpression 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 7 with TLiteralExpression

use of org.kie.dmn.model.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.

the class BindingPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.Binding dmn = new TBinding();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    dmn.setParameter(informationItem);
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setExpression(literalExpression);
    final Binding wb = BindingPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getParameter()).isNotNull();
    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 : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) TBinding(org.kie.dmn.model.v1_2.TBinding) TBinding(org.kie.dmn.model.v1_2.TBinding) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Test(org.junit.Test)

Example 8 with TLiteralExpression

use of org.kie.dmn.model.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.

the class ContextEntryPropertyConverterTest method testWBFromDMN.

@Test
public void testWBFromDMN() {
    final org.kie.dmn.model.api.ContextEntry dmn = new TContextEntry();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    dmn.setVariable(informationItem);
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    literalExpression.setId(EXPRESSION_UUID);
    dmn.setExpression(literalExpression);
    final ContextEntry wb = ContextEntryPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb).isNotNull();
    assertThat(wb.getVariable()).isNotNull();
    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 : TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) Test(org.junit.Test)

Example 9 with TLiteralExpression

use of org.kie.dmn.model.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.

the class DecisionRulePropertyConverterTest method testWbFromDMN.

@Test
public void testWbFromDMN() {
    final UnaryTests inputEntry = new TUnaryTests();
    final LiteralExpression outputEntry = new TLiteralExpression();
    final org.kie.dmn.model.api.DecisionRule dmn = new TDecisionRule();
    dmn.setId(ID);
    dmn.setDescription(DESCRIPTION);
    dmn.getInputEntry().add(inputEntry);
    dmn.getOutputEntry().add(outputEntry);
    final org.kie.workbench.common.dmn.api.definition.model.DecisionRule wb = DecisionRulePropertyConverter.wbFromDMN(dmn);
    assertEquals(ID, wb.getId().getValue());
    assertEquals("", wb.getDescription().getValue());
    assertEquals(wb, wb.getInputEntry().get(0).getParent());
    assertEquals(wb, wb.getOutputEntry().get(0).getParent());
    assertEquals(1, wb.getAnnotationEntry().size());
    assertEquals(DESCRIPTION, wb.getAnnotationEntry().get(0).getText().getValue());
}
Also used : TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.dmn.model.api.LiteralExpression) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) TUnaryTests(org.kie.dmn.model.v1_2.TUnaryTests) TDecisionRule(org.kie.dmn.model.v1_2.TDecisionRule) TUnaryTests(org.kie.dmn.model.v1_2.TUnaryTests) UnaryTests(org.kie.dmn.model.api.UnaryTests) Test(org.junit.Test)

Example 10 with TLiteralExpression

use of org.kie.dmn.model.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.

the class BusinessKnowledgeModelConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<BusinessKnowledgeModel>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<BusinessKnowledgeModel> view = new ViewImpl<>(new BusinessKnowledgeModel(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(BusinessKnowledgeModel.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.BusinessKnowledgeModel dmn = new TBusinessKnowledgeModel();
    final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    final org.kie.dmn.model.api.FunctionDefinition functionDefinition = new TFunctionDefinition();
    literalExpression.setId(EXPRESSION_UUID);
    functionDefinition.setExpression(literalExpression);
    functionDefinition.setId(FUNCTION_DEFINITION_UUID);
    dmn.setId(DECISION_UUID);
    dmn.setName(DECISION_NAME);
    dmn.setDescription(DECISION_DESCRIPTION);
    dmn.setVariable(informationItem);
    dmn.setEncapsulatedLogic(functionDefinition);
    final Node<View<BusinessKnowledgeModel>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final BusinessKnowledgeModel wb = (BusinessKnowledgeModel) 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.getEncapsulatedLogic()).isNotNull();
    assertThat(wb.getEncapsulatedLogic().getExpression()).isNotNull();
    assertThat(wb.getEncapsulatedLogic().getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
    verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths0 = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths0).isNotNull();
    assertThat(hasComponentWidths0).isEqualTo(wb.getEncapsulatedLogic().getExpression());
    verify(hasComponentWidthsConsumer).accept(eq(FUNCTION_DEFINITION_UUID), hasComponentWidthsCaptor.capture());
    final HasComponentWidths hasComponentWidths1 = hasComponentWidthsCaptor.getValue();
    assertThat(hasComponentWidths1).isNotNull();
    assertThat(hasComponentWidths1).isEqualTo(wb.getEncapsulatedLogic());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) 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) TBusinessKnowledgeModel(org.kie.dmn.model.v1_2.TBusinessKnowledgeModel) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TBusinessKnowledgeModel(org.kie.dmn.model.v1_2.TBusinessKnowledgeModel) Test(org.junit.Test)

Aggregations

TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)13 Test (org.junit.Test)10 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)8 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)7 QName (javax.xml.namespace.QName)6 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)4 TFunctionDefinition (org.kie.dmn.model.v1_2.TFunctionDefinition)3 UnaryTests (org.kie.dmn.model.api.UnaryTests)2 TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)2 TDecision (org.kie.dmn.model.v1_2.TDecision)2 TList (org.kie.dmn.model.v1_2.TList)2 TUnaryTests (org.kie.dmn.model.v1_2.TUnaryTests)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)2 View (org.kie.workbench.common.stunner.core.graph.content.view.View)2 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)1 Decision (org.kie.dmn.model.api.Decision)1 DecisionTable (org.kie.dmn.model.api.DecisionTable)1 ImportedValues (org.kie.dmn.model.api.ImportedValues)1