use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramEditor method newDiagram.
private void newDiagram(final String uuid, final String title, final String definitionSetId, final String shapeSetId, final Command callback) {
BusyPopup.showMessage("Loading");
final Metadata metadata = buildMetadata(definitionSetId, shapeSetId, title);
clientFactoryServices.newDiagram(uuid, definitionSetId, metadata, new ServiceCallback<Diagram>() {
@Override
public void onSuccess(final Diagram diagram) {
marshallerService.setOnDiagramLoad(onDiagramLoadCallback(callback));
marshallerService.registerDiagramInstance(diagram, title, shapeSetId);
open(diagram, callback);
}
@Override
public void onError(final ClientRuntimeError error) {
showError(error);
callback.execute();
}
});
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramEditorTest method testGetHashcodeSupplier.
@Test
public void testGetHashcodeSupplier() {
final Diagram diagram = new DiagramImpl("something", null);
final Integer expectedHashcode = diagram.hashCode();
doReturn(diagram).when(editor).getDiagram();
final Integer actualHashcode = editor.getHashcodeSupplier().get();
assertEquals(expectedHashcode, actualHashcode);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramEditorTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(searchBarComponent.getView()).thenReturn(searchBarComponentView);
when(searchBarComponentView.getElement()).thenReturn(searchBarComponentViewElement);
when(presenter.getView()).thenReturn(sessionPresenterView);
when(drdNameChanger.getElement()).thenReturn(drdNameChangerElement);
doReturn(presenter).when(presenter).withToolbar(anyBoolean());
doReturn(presenter).when(presenter).withPalette(anyBoolean());
doReturn(presenter).when(presenter).displayNotifications(any());
doReturn(session).when(presenter).getInstance();
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(expressionEditor).when(session).getExpressionEditor();
doAnswer((invocation) -> {
Diagram diagram = (Diagram) invocation.getArguments()[0];
SessionPresenter.SessionPresenterCallback callback = (SessionPresenter.SessionPresenterCallback) invocation.getArguments()[1];
callback.onOpen(diagram);
callback.afterCanvasInitialized();
callback.afterSessionOpened();
callback.onSuccess();
return null;
}).when(presenter).open(any(Diagram.class), any(SessionPresenter.SessionPresenterCallback.class));
editor = spy(new DMNDiagramEditor(sessionManager, null, presenter, refreshFormPropertiesEvent, null, null, decisionNavigatorDock, diagramPropertiesDock, diagramPreviewAndExplorerDock, layoutHelper, layoutExecutor, dataTypesPage, includedModelsPage, documentationView, editorSearchIndex, searchBarComponent, null, null, null, null, screenPanelView, null, kieView, feelInitializer, dmnDiagramsSession, marshallerService, drdNameChanger, lazyCanvasFocusUtils));
doReturn(searchBarComponentWidget).when(editor).getWidget(searchBarComponentViewElement);
doReturn(drdNameWidget).when(editor).getWidget(drdNameChangerElement);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNClientProjectDiagramServiceTest method testGetMarshallerCallback.
@Test
public void testGetMarshallerCallback() {
final DMNContentResource resource = mock(DMNContentResource.class);
final Diagram diagram = mock(Diagram.class);
final Graph graph = mock(Graph.class);
final ProjectMetadata projectMetadata = mock(ProjectMetadata.class);
final String name = "name";
when(diagram.getName()).thenReturn(name);
when(diagram.getGraph()).thenReturn(graph);
when(resource.getMetadata()).thenReturn(projectMetadata);
service.getMarshallerCallback(resource, projectDiagramCallback).onSuccess(diagram);
verify(projectDiagramCallback).onSuccess(projectDiagramArgumentCaptor.capture());
final ProjectDiagramImpl projectDiagram = projectDiagramArgumentCaptor.getValue();
assertEquals(name, projectDiagram.getName());
assertEquals(graph, projectDiagram.getGraph());
assertEquals(projectMetadata, projectDiagram.getMetadata());
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNClientProjectDiagramServiceTest method testAsProjectDiagramImpl.
@Test
public void testAsProjectDiagramImpl() {
final Graph graph = mock(Graph.class);
final Diagram diagram = mock(Diagram.class);
final DMNContentResource resource = mock(DMNContentResource.class);
final ProjectMetadata metadata = mock(ProjectMetadata.class);
when(diagram.getName()).thenReturn("Traffic Violation.dmn");
when(diagram.getGraph()).thenReturn(graph);
when(resource.getMetadata()).thenReturn(metadata);
final ProjectDiagramImpl projectDiagram = service.asProjectDiagramImpl(diagram, resource);
assertEquals("Traffic Violation", projectDiagram.getName());
assertEquals(graph, projectDiagram.getGraph());
assertEquals(metadata, projectDiagram.getMetadata());
}
Aggregations