Search in sources :

Example 56 with DRGElement

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

the class DecisionComponentsTest method testLoadModelComponents.

@Test
public void testLoadModelComponents() {
    final String dmnModelName = "ModelName";
    final DRGElement drgElement1 = mock(DRGElement.class);
    final DRGElement drgElement2 = mock(DRGElement.class);
    final DecisionComponent decisionComponent1 = mock(DecisionComponent.class);
    final DecisionComponent decisionComponent2 = mock(DecisionComponent.class);
    final List<DecisionComponent> decisionComponentsList = new ArrayList<>();
    final Definitions definitions = mock(Definitions.class);
    when(definitions.getName()).thenReturn(new Name(dmnModelName));
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(dmnDiagramsSession.getModelDRGElements()).thenReturn(Arrays.asList(drgElement1, drgElement2));
    when(drgElement1.getName()).thenReturn(new Name("Decision-1"));
    when(drgElement2.getName()).thenReturn(new Name("Decision-2"));
    when(decisionComponent1.getName()).thenReturn("Decision-1");
    when(decisionComponent2.getName()).thenReturn("Decision-2");
    doReturn(decisionComponent1).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement1);
    doReturn(decisionComponent2).when(decisionComponents).makeDecisionComponent(dmnModelName, drgElement2);
    doReturn(decisionComponentsList).when(decisionComponents).getModelDRGElements();
    doNothing().when(decisionComponents).refreshView();
    decisionComponents.loadModelComponents();
    assertTrue(decisionComponentsList.contains(decisionComponent1));
    assertTrue(decisionComponentsList.contains(decisionComponent2));
    assertEquals(2, decisionComponentsList.size());
    verify(decisionComponents).refreshView();
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ArrayList(java.util.ArrayList) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 57 with DRGElement

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

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsNotDuplicated() {
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement1 = mock(DRGElement.class);
    final DRGElement drgElement2 = mock(DRGElement.class);
    final DRGElement drgElement3 = mock(DRGElement.class);
    final ClientSession currentSession = mock(ClientSession.class);
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final Graph<?, Node> graph = mock(Graph.class);
    final List<Node> nodes = new ArrayList<>();
    final int x = 10;
    final int y = 20;
    final String id1 = "123";
    final String id2 = "456";
    final String id3 = "789";
    nodes.add(createNode(id1));
    nodes.add(createNode(id2));
    when(graph.nodes()).thenReturn(nodes);
    when(drgElement1.getId()).thenReturn(new Id(id1));
    when(drgElement2.getId()).thenReturn(new Id(id2));
    when(drgElement3.getId()).thenReturn(new Id(id3));
    when(sessionManager.getCurrentSession()).thenReturn(currentSession);
    when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
    doReturn(graph).when(view).getGraph();
    view.makeDragProxyCallbackImpl(drgElement3, factory).onComplete(x, y);
    verify(notificationEvent, never()).fire(any());
    verify(buildCanvasShapeEvent).fire(buildCanvasShapeEventArgumentCaptor.capture());
    final BuildCanvasShapeEvent canvasShapeEvent = buildCanvasShapeEventArgumentCaptor.getValue();
    assertEquals(canvasHandler, canvasShapeEvent.getCanvasHandler());
    assertEquals(drgElement3, canvasShapeEvent.getDefinition());
    assertEquals(factory, canvasShapeEvent.getShapeFactory());
    assertEquals(x, canvasShapeEvent.getClientX(), 0.1);
    assertEquals(y, canvasShapeEvent.getClientY(), 0.1);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) DecisionComponentsItemView_DuplicatedNode(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode) Node(org.kie.workbench.common.stunner.core.graph.Node) ArrayList(java.util.ArrayList) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BuildCanvasShapeEvent(org.kie.workbench.common.stunner.core.client.canvas.controls.event.BuildCanvasShapeEvent) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 58 with DRGElement

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

the class DecisionComponentsItemTest method testGetDrgElement.

@Test
public void testGetDrgElement() {
    final DecisionComponent decisionComponent = mock(DecisionComponent.class);
    final DRGElement expectedDrgElement = null;
    when(decisionComponent.getDrgElement()).thenReturn(expectedDrgElement);
    doReturn(decisionComponent).when(item).getDecisionComponent();
    final DRGElement actualDrgElement = item.getDrgElement();
    assertEquals(expectedDrgElement, actualDrgElement);
}
Also used : DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 59 with DRGElement

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

the class DMNElementsSynchronizerTest method testSynchronizeFromNode.

@Test
public void testSynchronizeFromNode() {
    final Node node = mock(Node.class);
    final Optional<Node> optional = Optional.of(node);
    final Definition definition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    doNothing().when(synchronizer).synchronizeElementsFrom(drgElement);
    when(definition.getDefinition()).thenReturn(drgElement);
    when(node.getContent()).thenReturn(definition);
    synchronizer.synchronizeFromNode(optional);
    verify(synchronizer).synchronizeElementsFrom(drgElement);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 60 with DRGElement

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

the class DMNElementsSynchronizerTest method testGetDRGElementFromContentDefinition.

@Test
public void testGetDRGElementFromContentDefinition() {
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final DRGElement drgElement = mock(DRGElement.class);
    when(definition.getDefinition()).thenReturn(drgElement);
    when(node.getContent()).thenReturn(definition);
    final DRGElement actual = synchronizer.getDRGElementFromContentDefinition(node);
    assertEquals(drgElement, actual);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)72 Test (org.junit.Test)45 Node (org.kie.workbench.common.stunner.core.graph.Node)27 ArrayList (java.util.ArrayList)25 Edge (org.kie.workbench.common.stunner.core.graph.Edge)17 View (org.kie.workbench.common.stunner.core.graph.content.view.View)17 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 List (java.util.List)15 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)15 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)15 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)15 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)10 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 Import (org.kie.workbench.common.dmn.api.definition.model.Import)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)8 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)7 Optional (java.util.Optional)6