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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations