Search in sources :

Example 1 with DecisionServiceParametersList

use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testSetValue.

@Test
public void testSetValue() {
    doNothing().when(widget).refresh();
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    widget.setValue(value, false);
    verify(widget).refresh();
}
Also used : DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) Test(org.junit.Test)

Example 2 with DecisionServiceParametersList

use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList 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 3 with DecisionServiceParametersList

use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList 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)

Example 4 with DecisionServiceParametersList

use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testGetSortedInputs.

@Test
public void testGetSortedInputs() {
    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 newId1 = "newId1";
    final String newId2 = "newId2";
    final List<DMNElementReference> list = createListOfDMNElementReferenceWithIds(id1, id2, id3);
    final List<InputData> unsortedInputs = Arrays.asList(createInputDataWithId(id2), createInputDataWithId(id3), createInputDataWithId(newId2), createInputDataWithId(id1), createInputDataWithId(newId1));
    doReturn(value).when(widget).getValue();
    when(value.getDecisionService()).thenReturn(decisionService);
    when(decisionService.getInputData()).thenReturn(list);
    final List<InputData> sorted = widget.getSortedInputs(unsortedInputs);
    assertThat(sorted).extracting(inputData -> inputData.getId().getValue()).containsExactly(id1, id2, id3, newId1, newId2);
}
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 DecisionServiceParametersList

use of org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testRefresh.

@Test
public void testRefresh() {
    final DecisionServiceParametersList value = mock(DecisionServiceParametersList.class);
    final DecisionService decisionService = mock(DecisionService.class);
    final String contentDefinitionId = "contentId";
    final Node node = mock(Node.class);
    final Edge edge1 = mock(Edge.class);
    final Child child1 = mock(Child.class);
    final Node targetNode1 = mock(Node.class);
    final Edge edge2 = mock(Edge.class);
    final Child child2 = mock(Child.class);
    final Node targetNode2 = mock(Node.class);
    final Edge edge3 = mock(Edge.class);
    final Child child3 = mock(Child.class);
    final Node targetNode3 = mock(Node.class);
    final Edge edgeNotChild = mock(Edge.class);
    final Object notChild = mock(Object.class);
    final List<Edge> edges = Arrays.asList(edge1, edge2, edge3, edgeNotChild);
    final DRGElement drgElement1 = mock(DRGElement.class);
    final DRGElement drgElement2 = mock(DRGElement.class);
    final DRGElement drgElement3 = mock(DRGElement.class);
    final Optional<DRGElement> targetDrg1 = Optional.of(drgElement1);
    final Optional<DRGElement> targetDrg2 = Optional.of(drgElement2);
    final Optional<DRGElement> targetDrg3 = Optional.of(drgElement3);
    final List<InputData> sortedList = new ArrayList<>();
    when(decisionService.getContentDefinitionId()).thenReturn(contentDefinitionId);
    when(value.getDecisionService()).thenReturn(decisionService);
    when(edge1.getContent()).thenReturn(child1);
    when(edge1.getTargetNode()).thenReturn(targetNode1);
    when(edge2.getContent()).thenReturn(child2);
    when(edge2.getTargetNode()).thenReturn(targetNode2);
    when(edge3.getContent()).thenReturn(child3);
    when(edge3.getTargetNode()).thenReturn(targetNode3);
    when(edgeNotChild.getContent()).thenReturn(notChild);
    when(node.getOutEdges()).thenReturn(edges);
    doNothing().when(widget).clear();
    doNothing().when(widget).loadGroupsElements();
    doNothing().when(widget).loadInputsParameters(anyList());
    doNothing().when(widget).loadDecisionsFromNode(any(), any());
    doNothing().when(widget).loadInputsFromNode(any(), any());
    doNothing().when(widget).loadInputsFromOthersDiagrams(anyList(), any(Node.class));
    doReturn(value).when(widget).getValue();
    doReturn(node).when(widget).getNode(contentDefinitionId);
    doReturn(targetDrg1).when(widget).getTargetDRGElement(edge1);
    doReturn(targetDrg2).when(widget).getTargetDRGElement(edge2);
    doReturn(targetDrg3).when(widget).getTargetDRGElement(edge3);
    doReturn(Optional.empty()).when(widget).getTargetDRGElement(edgeNotChild);
    doReturn(sortedList).when(widget).getSortedInputs(anyList());
    widget.refresh();
    verify(widget).loadDecisionsFromNode(node, targetNode1);
    verify(widget).loadDecisionsFromNode(node, targetNode2);
    verify(widget).loadDecisionsFromNode(node, targetNode3);
    verify(widget).loadInputsFromNode(anyList(), eq(targetNode1));
    verify(widget).loadInputsFromNode(anyList(), eq(targetNode2));
    verify(widget).loadInputsFromNode(anyList(), eq(targetNode3));
    verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode1));
    verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode2));
    verify(widget).loadInputsFromOthersDiagrams(anyList(), eq(targetNode3));
    verify(widget).getSortedInputs(anyList());
    verify(widget).loadInputsParameters(sortedList);
    verify(widget).loadGroupsElements();
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DecisionServiceParametersList(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 DecisionServiceParametersList (org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceParametersList)5 ArrayList (java.util.ArrayList)4 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)4 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)4 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)4 Edge (org.kie.workbench.common.stunner.core.graph.Edge)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)4 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