Search in sources :

Example 1 with DecisionComponentsItemView_DuplicatedNode

use of org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode in project kie-wb-common by kiegroup.

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicated.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicated() {
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final int x = 10;
    final int y = 20;
    final String expectedWarnMessage = "This 'DRGElement' already exists!";
    final NotificationEvent.NotificationType expectedWarnType = WARNING;
    final Graph<?, Node> graph = mock(Graph.class);
    final List<Node> nodes = new ArrayList<>();
    final String id1 = "123";
    final String id2 = "123";
    nodes.add(createNode(id1));
    nodes.add(createNode(id2));
    when(graph.nodes()).thenReturn(nodes);
    when(drgElement.getId()).thenReturn(new Id(id1));
    when(clientTranslationService.getValue(DecisionComponentsItemView_DuplicatedNode)).thenReturn(expectedWarnMessage);
    doReturn(graph).when(view).getGraph();
    view.setIsImported(true);
    view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
    verify(buildCanvasShapeEvent, never()).fire(any());
    verify(notificationEvent).fire(notificationEventArgumentCaptor.capture());
    final NotificationEvent notificationEvent = notificationEventArgumentCaptor.getValue();
    assertEquals(expectedWarnMessage, notificationEvent.getNotification());
    assertEquals(expectedWarnType, notificationEvent.getType());
}
Also used : 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) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)1 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)1 DecisionComponentsItemView_DuplicatedNode (org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode)1 DMNShapeFactory (org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory)1 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)1