Search in sources :

Example 6 with TInformationItem

use of org.kie.dmn.model.v1_3.TInformationItem in project kie-wb-common by kiegroup.

the class FunctionDefinitionPropertyConverterTest method doTestWBFromDMNWithContextEntry.

private void doTestWBFromDMNWithContextEntry(final FunctionKind kind, final String variableName, final Class<? extends IsLiteralExpression> literalExpressionClass) {
    final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition();
    final org.kie.dmn.model.api.Context contextExpression = new TContext();
    final org.kie.dmn.model.api.ContextEntry contextEntry = new TContextEntry();
    final org.kie.dmn.model.api.InformationItem variable = new TInformationItem();
    variable.setName(variableName);
    contextEntry.setVariable(variable);
    contextEntry.setExpression(new TLiteralExpression());
    contextExpression.getContextEntry().add(contextEntry);
    dmn.setKind(kind);
    dmn.setExpression(contextExpression);
    final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
    assertThat(wb.getExpression()).isInstanceOf(Context.class);
    assertThat(((Context) wb.getExpression()).getContextEntry().get(0).getExpression()).isInstanceOf(literalExpressionClass);
}
Also used : TContext(org.kie.dmn.model.v1_2.TContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) TContext(org.kie.dmn.model.v1_2.TContext) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) TFunctionDefinition(org.kie.dmn.model.v1_2.TFunctionDefinition) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry)

Example 7 with TInformationItem

use of org.kie.dmn.model.v1_3.TInformationItem in project kie-wb-common by kiegroup.

the class InformationItemPrimaryPropertyConverterTest method testDmnFromWBWhenWBIsNotNull.

@Test
public void testDmnFromWBWhenWBIsNotNull() {
    final String expectedId = "id";
    final String expectedName = "name";
    final Id id = new Id(expectedId);
    final Name name = new Name(expectedName);
    final String qNameNamespaceURI = "qName namespaceURI";
    final String qNameLocalPart = "qName local part";
    final String qNamePrefix = "qName prefix";
    final InformationItemPrimary wb = mock(InformationItemPrimary.class);
    final QName qName = mock(QName.class);
    final javax.xml.namespace.QName expectedQName = new javax.xml.namespace.QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
    final NamedElement parentElement = mock(NamedElement.class);
    when(wb.getId()).thenReturn(id);
    when(wb.getName()).thenReturn(name);
    when(wb.getTypeRef()).thenReturn(qName);
    when(wb.getParent()).thenReturn(parentElement);
    when(parentElement.getName()).thenReturn(name);
    when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
    when(qName.getLocalPart()).thenReturn(qNameLocalPart);
    when(qName.getPrefix()).thenReturn(qNamePrefix);
    final TInformationItem informationItem = InformationItemPrimaryPropertyConverter.dmnFromWB(wb, wb);
    final String actualId = informationItem.getId();
    final String actualName = informationItem.getName();
    final javax.xml.namespace.QName actualQName = informationItem.getTypeRef();
    assertEquals(expectedId, actualId);
    assertEquals(expectedName, actualName);
    assertEquals(expectedQName, actualQName);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 8 with TInformationItem

use of org.kie.dmn.model.v1_3.TInformationItem in project kie-wb-common by kiegroup.

the class InputDataConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<InputData>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<InputData> view = new ViewImpl<>(new InputData(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(InputData.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.InputData dmn = new TInputData();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    dmn.setId(INPUT_DATA_UUID);
    dmn.setName(INPUT_DATA_NAME);
    dmn.setDescription(INPUT_DATA_DESCRIPTION);
    dmn.setVariable(informationItem);
    final Node<View<InputData>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final InputData wb = (InputData) DefinitionUtils.getElementDefinition(node);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(INPUT_DATA_UUID);
    assertThat(wb.getName()).isNotNull();
    assertThat(wb.getName().getValue()).isEqualTo(INPUT_DATA_NAME);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(INPUT_DATA_DESCRIPTION);
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getVariable().getName().getValue()).isEqualTo(INPUT_DATA_NAME);
    verifyNoMoreInteractions(hasComponentWidthsConsumer);
}
Also used : TInputData(org.kie.dmn.model.v1_2.TInputData) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TInputData(org.kie.dmn.model.v1_2.TInputData) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Test(org.junit.Test)

Example 9 with TInformationItem

use of org.kie.dmn.model.v1_3.TInformationItem in project kie-wb-common by kiegroup.

the class DecisionServiceConverterTest method testWBFromDMN.

@Test
@SuppressWarnings("unchecked")
public void testWBFromDMN() {
    final Node<View<DecisionService>, ?> factoryNode = new NodeImpl<>(UUID.uuid());
    final View<DecisionService> view = new ViewImpl<>(new DecisionService(), Bounds.create());
    factoryNode.setContent(view);
    when(factoryManager.newElement(Mockito.<String>any(), eq(getDefinitionId(DecisionService.class)))).thenReturn(element);
    when(element.asNode()).thenReturn(factoryNode);
    final org.kie.dmn.model.api.DecisionService dmn = new TDecisionService();
    final org.kie.dmn.model.api.InformationItem informationItem = new TInformationItem();
    dmn.setId(DECISION_SERVICE_UUID);
    dmn.setName(DECISION_SERVICE_NAME);
    dmn.setDescription(DECISION_SERVICE_DESCRIPTION);
    dmn.setVariable(informationItem);
    final Node<View<DecisionService>, ?> node = converter.nodeFromDMN(dmn, hasComponentWidthsConsumer);
    final DecisionService wb = (DecisionService) DefinitionUtils.getElementDefinition(node);
    assertThat(wb).isNotNull();
    assertThat(wb.getId()).isNotNull();
    assertThat(wb.getId().getValue()).isEqualTo(DECISION_SERVICE_UUID);
    assertThat(wb.getName()).isNotNull();
    assertThat(wb.getName().getValue()).isEqualTo(DECISION_SERVICE_NAME);
    assertThat(wb.getDescription()).isNotNull();
    assertThat(wb.getDescription().getValue()).isEqualTo(DECISION_SERVICE_DESCRIPTION);
    assertThat(wb.getVariable()).isNotNull();
    assertThat(wb.getVariable().getName().getValue()).isEqualTo(DECISION_SERVICE_NAME);
    verifyNoMoreInteractions(hasComponentWidthsConsumer);
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TDecisionService(org.kie.dmn.model.v1_2.TDecisionService) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) TDecisionService(org.kie.dmn.model.v1_2.TDecisionService) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) Test(org.junit.Test)

Example 10 with TInformationItem

use of org.kie.dmn.model.v1_3.TInformationItem 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)

Aggregations

TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)14 Test (org.junit.Test)9 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)7 QName (javax.xml.namespace.QName)5 InformationItem (org.kie.dmn.model.api.InformationItem)5 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)4 TDecision (org.kie.dmn.model.v1_2.TDecision)3 TInputData (org.kie.dmn.model.v1_2.TInputData)3 DRGElement (org.kie.dmn.model.api.DRGElement)2 TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)2 TDecisionService (org.kie.dmn.model.v1_2.TDecisionService)2 TFunctionDefinition (org.kie.dmn.model.v1_2.TFunctionDefinition)2 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)2 LinkedHashSet (java.util.LinkedHashSet)1 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)1 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)1 DecisionServiceNode (org.kie.dmn.api.core.ast.DecisionServiceNode)1