Search in sources :

Example 1 with SessionDestroyedEvent

use of org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent in project kie-wb-common by kiegroup.

the class ClientSessionManagerImplTest method testPostDestroy.

@Test
public void testPostDestroy() {
    when(session.getSessionUUID()).thenReturn("sessionUUID");
    when(diagram.getName()).thenReturn("diagramName");
    when(graph.getUUID()).thenReturn("graphUUID");
    tested.current = session;
    tested.destroy();
    verify(sessionOpenedEventMock, times(0)).fire(any(SessionOpenedEvent.class));
    verify(sessionPausedEventMock, times(0)).fire(any(SessionPausedEvent.class));
    verify(sessionResumedEventMock, times(0)).fire(any(SessionResumedEvent.class));
    verify(sessionErrorEventMock, times(0)).fire(any(OnSessionErrorEvent.class));
    ArgumentCaptor<SessionDestroyedEvent> destroyedEventArgumentCaptor = ArgumentCaptor.forClass(SessionDestroyedEvent.class);
    verify(sessionDestroyedEventMock, times(1)).fire(destroyedEventArgumentCaptor.capture());
    SessionDestroyedEvent event = destroyedEventArgumentCaptor.getValue();
    assertEquals("sessionUUID", event.getSessionUUID());
    assertEquals("diagramName", event.getDiagramName());
    assertEquals("graphUUID", event.getGraphUuid());
    assertEquals(metadata, event.getMetadata());
}
Also used : OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) SessionOpenedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionOpenedEvent) SessionResumedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionResumedEvent) SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) SessionPausedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionPausedEvent) Test(org.junit.Test)

Example 2 with SessionDestroyedEvent

use of org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent in project kie-wb-common by kiegroup.

the class WorkItemDefinitionClientRegistryTest method testOnSessionDestroyed.

@Test
public void testOnSessionDestroyed() {
    tested.load(session, metadata, () -> {
    });
    tested.onSessionDestroyed(new SessionDestroyedEvent(SESSION_ID, "name1", "graphUUID", metadata));
    verify(registry, times(1)).clear();
    verify(registryInstanceDestroyer, times(1)).accept(eq(registry));
}
Also used : SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) Test(org.junit.Test)

Example 3 with SessionDestroyedEvent

use of org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent in project kie-wb-common by kiegroup.

the class ClientSessionManagerImpl method destroy.

@Override
public void destroy() {
    SessionDestroyedEvent destroyedEvent = null;
    if (null != current) {
        final String uuid = current.getSessionUUID();
        final Diagram diagram = current.getCanvasHandler().getDiagram();
        final String name = null != diagram ? diagram.getName() : null;
        final String graphUuid = null != diagram ? diagram.getGraph().getUUID() : null;
        final Metadata metadata = null != diagram ? diagram.getMetadata() : null;
        destroyedEvent = new SessionDestroyedEvent(uuid, name, graphUuid, metadata);
    }
    super.destroy();
    if (null != destroyedEvent) {
        this.sessionDestroyedEvent.fire(destroyedEvent);
    }
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 4 with SessionDestroyedEvent

use of org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent in project kie-wb-common by kiegroup.

the class ClientSessionManagerImplTest method testPostDestroyButNoDiagram.

@Test
public void testPostDestroyButNoDiagram() {
    when(session.getSessionUUID()).thenReturn("sessionUUID");
    when(handler.getDiagram()).thenReturn(null);
    tested.current = session;
    tested.destroy();
    verify(sessionOpenedEventMock, times(0)).fire(any(SessionOpenedEvent.class));
    verify(sessionPausedEventMock, times(0)).fire(any(SessionPausedEvent.class));
    verify(sessionResumedEventMock, times(0)).fire(any(SessionResumedEvent.class));
    verify(sessionErrorEventMock, times(0)).fire(any(OnSessionErrorEvent.class));
    ArgumentCaptor<SessionDestroyedEvent> destroyedEventArgumentCaptor = ArgumentCaptor.forClass(SessionDestroyedEvent.class);
    verify(sessionDestroyedEventMock, times(1)).fire(destroyedEventArgumentCaptor.capture());
    SessionDestroyedEvent event = destroyedEventArgumentCaptor.getValue();
    assertEquals("sessionUUID", event.getSessionUUID());
    assertNull(event.getDiagramName());
    assertNull(event.getGraphUuid());
    assertNull(event.getMetadata());
}
Also used : OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) SessionOpenedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionOpenedEvent) SessionResumedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionResumedEvent) SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) SessionPausedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionPausedEvent) Test(org.junit.Test)

Aggregations

SessionDestroyedEvent (org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent)4 Test (org.junit.Test)3 OnSessionErrorEvent (org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent)2 SessionOpenedEvent (org.kie.workbench.common.stunner.core.client.session.event.SessionOpenedEvent)2 SessionPausedEvent (org.kie.workbench.common.stunner.core.client.session.event.SessionPausedEvent)2 SessionResumedEvent (org.kie.workbench.common.stunner.core.client.session.event.SessionResumedEvent)2 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1