Search in sources :

Example 1 with DMNElementReference

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

the class DecisionServiceConverter method nodeFromDMN.

@Override
public Node<View<DecisionService>, ?> nodeFromDMN(final org.kie.dmn.model.api.DecisionService dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<DecisionService>, ?> node = (Node<View<DecisionService>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(DecisionService.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
    final List<DMNElementReference> outputDecision = dmn.getOutputDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
    final List<DMNElementReference> encapsulatedDecision = dmn.getEncapsulatedDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
    final List<DMNElementReference> inputDecision = dmn.getInputDecision().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
    final List<DMNElementReference> inputData = dmn.getInputData().stream().map(DMNElementReferenceConverter::wbFromDMN).collect(Collectors.toList());
    final DecisionService decisionService = new DecisionService(id, description, name, informationItem, outputDecision, encapsulatedDecision, inputDecision, inputData, new StylingSet(), new DecisionServiceRectangleDimensionsSet(), new DecisionServiceDividerLineY());
    node.getContent().setDefinition(decisionService);
    if (informationItem != null) {
        informationItem.setParent(decisionService);
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decisionService);
    return node;
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) View(org.kie.workbench.common.stunner.core.graph.content.view.View) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) DecisionServiceRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.DecisionServiceRectangleDimensionsSet)

Example 2 with DMNElementReference

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

the class DMNElementReferenceConverter method wbFromDMN.

public static DMNElementReference wbFromDMN(final org.kie.dmn.model.api.DMNElementReference dmn) {
    final DMNElementReference result = new DMNElementReference();
    result.setHref(dmn.getHref());
    return result;
}
Also used : DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference)

Example 3 with DMNElementReference

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

the class DMNElementReferenceConverter method wbFromDMN.

public static DMNElementReference wbFromDMN(final JSITDMNElementReference dmn) {
    final DMNElementReference result = new DMNElementReference();
    result.setHref(dmn.getHref());
    return result;
}
Also used : DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) JSITDMNElementReference(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElementReference)

Example 4 with DMNElementReference

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

the class DecisionServiceParametersListWidgetTest method testGetCurrentItems.

@Test
public void testGetCurrentItems() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> sorted = widget.getCurrentItems(unsortedInputs);
    assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) DecisionServiceParameters_Outputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Outputs) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Mockito.doReturn(org.mockito.Mockito.doReturn) DecisionServiceParameters_EncapsulatedDecisions(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_EncapsulatedDecisions) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) Stream(java.util.stream.Stream) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) DecisionServiceParameters_Inputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Inputs) Mockito.spy(org.mockito.Mockito.spy) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Before(org.junit.Before) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Mockito.never(org.mockito.Mockito.never) HTMLDivElement(elemental2.dom.HTMLDivElement) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Assert.assertEquals(org.junit.Assert.assertEquals) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 5 with DMNElementReference

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

the class DecisionServiceParametersListWidgetTest method testGetNewItems.

@Test
public void testGetNewItems() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final String newItem1 = "aaa";
    final String newItem2 = "bbb";
    final String newItem3 = "ccc";
    final String newItem4 = "ddd";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> currentItems = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(id1));
    final List<InputData> inputs = Arrays.asList(createInputDataWithId(newItem3), createInputDataWithId(newItem2), createInputDataWithId(newItem4), createInputDataWithId(newItem1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> result = widget.getNewItems(inputs, currentItems);
    assertThat(result).extracting(inputData -> inputData.getId().getValue()).containsExactly(newItem1, newItem2, newItem3, newItem4);
}
Also used : Arrays(java.util.Arrays) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) DecisionServiceParameters_Outputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Outputs) HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) ClientTranslationService(org.kie.workbench.common.stunner.core.client.i18n.ClientTranslationService) Mockito.doReturn(org.mockito.Mockito.doReturn) DecisionServiceParameters_EncapsulatedDecisions(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_EncapsulatedDecisions) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Mockito.doNothing(org.mockito.Mockito.doNothing) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) Stream(java.util.stream.Stream) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) Mockito.mock(org.mockito.Mockito.mock) GwtMockitoTestRunner(com.google.gwtmockito.GwtMockitoTestRunner) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) DecisionServiceParameters_Inputs(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionServiceParameters_Inputs) Mockito.spy(org.mockito.Mockito.spy) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ArrayList(java.util.ArrayList) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Elemental2DomUtil(org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Before(org.junit.Before) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) Mockito.verify(org.mockito.Mockito.verify) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Mockito.never(org.mockito.Mockito.never) HTMLDivElement(elemental2.dom.HTMLDivElement) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Assert.assertEquals(org.junit.Assert.assertEquals) DMNElementReference(org.kie.workbench.common.dmn.api.definition.model.DMNElementReference) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Aggregations

DMNElementReference (org.kie.workbench.common.dmn.api.definition.model.DMNElementReference)8 ArrayList (java.util.ArrayList)5 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)5 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)5 DecisionServiceDividerLineY (org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 Node (org.kie.workbench.common.stunner.core.graph.Node)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 GwtMockitoTestRunner (com.google.gwtmockito.GwtMockitoTestRunner)3 HTMLDivElement (elemental2.dom.HTMLDivElement)3 Arrays (java.util.Arrays)3 List (java.util.List)3 Optional (java.util.Optional)3 Stream (java.util.stream.Stream)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 HTMLElement (org.jboss.errai.common.client.dom.HTMLElement)3 Elemental2DomUtil (org.jboss.errai.common.client.dom.elemental2.Elemental2DomUtil)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3