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