Search in sources :

Example 51 with Id

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

the class HrefBuilderTest method testGetHref.

@Test
public void testGetHref() {
    final DRGElement drgElement = mock(DRGElement.class);
    final Name name = mock(Name.class);
    final Id id = mock(Id.class);
    final Definitions definitions = mock(Definitions.class);
    final String uuid = "0000-1111-2222";
    when(id.getValue()).thenReturn(uuid);
    when(name.getValue()).thenReturn("Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(name);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(Collections.emptyList());
    final String actual = HrefBuilder.getHref(drgElement);
    final String expected = "#" + uuid;
    assertEquals(expected, actual);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) 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 52 with Id

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

Example 53 with Id

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

the class DecisionComponentsItemViewTest method testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported.

@Test
public void testMakeDragProxyCallbackImplWhenNodeIsDuplicatedButIsNotImported() {
    final ClientSession currentSession = mock(ClientSession.class);
    final AbstractCanvasHandler canvasHandler = mock(AbstractCanvasHandler.class);
    final ShapeFactory factory = mock(ShapeFactory.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final int x = 10;
    final int y = 20;
    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(sessionManager.getCurrentSession()).thenReturn(currentSession);
    when(currentSession.getCanvasHandler()).thenReturn(canvasHandler);
    doReturn(graph).when(view).getGraph();
    view.setIsImported(false);
    view.makeDragProxyCallbackImpl(drgElement, factory).onComplete(x, y);
    verify(buildCanvasShapeEvent).fire(any());
    verify(notificationEvent, never()).fire(notificationEventArgumentCaptor.capture());
}
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) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 54 with Id

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

the class DMNDiagramsSessionTest method testGetCurrentDiagramId.

@Test
public void testGetCurrentDiagramId() {
    final DMNDiagramElement diagramElement = mock(DMNDiagramElement.class);
    final Diagram stunnerDiagram = mock(Diagram.class);
    final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement);
    final Id id = mock(Id.class);
    final String expectedId = "value";
    when(id.getValue()).thenReturn(expectedId);
    when(diagramElement.getId()).thenReturn(id);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram);
    final String actualId = dmnDiagramsSession.getCurrentDiagramId();
    assertEquals(expectedId, actualId);
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 55 with Id

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

the class DMNDiagramsSessionTest method testSetCurrentDMNDiagramElement.

@Test
public void testSetCurrentDMNDiagramElement() {
    final DMNDiagramElement diagramElement = new DMNDiagramElement(new Id(), new Name("DRG"));
    final Diagram stunnerDiagram = mock(Diagram.class);
    final DMNDiagramSelected selectedDiagram = new DMNDiagramSelected(diagramElement);
    dmnDiagramsSession.add(diagramElement, stunnerDiagram);
    dmnDiagramsSession.onDMNDiagramSelected(selectedDiagram);
    verify(dmnDiagramsSessionState).setCurrentDMNDiagramElement(diagramElement);
}
Also used : Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Aggregations

Id (org.kie.workbench.common.dmn.api.property.dmn.Id)173 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)102 Test (org.junit.Test)78 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)74 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)59 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)30 Node (org.kie.workbench.common.stunner.core.graph.Node)29 View (org.kie.workbench.common.stunner.core.graph.content.view.View)29 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)23 QName (javax.xml.namespace.QName)20 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)18 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 ArrayList (java.util.ArrayList)16 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)15 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)15 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)15 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)13 List (java.util.List)11