use of org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent in project che by eclipse.
the class DtoConverterTest method convertsSystemServiceItemStoppedEvent.
@Test
public void convertsSystemServiceItemStoppedEvent() {
SystemServiceItemStoppedEvent event = new SystemServiceItemStoppedEvent("service1", "workspace1", 3, 5);
SystemServiceItemStoppedEventDto dto = DtoConverter.asDto(event);
assertEquals(dto.getType(), EventType.SERVICE_ITEM_STOPPED);
assertEquals(dto.getService(), event.getServiceName());
assertEquals(dto.getItem(), event.getItem());
assertEquals(dto.getCurrent(), event.getCurrent());
assertEquals(dto.getTotal(), event.getTotal());
}
use of org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent in project che by eclipse.
the class SystemEventsWebsocketBroadcasterTest method eventToDto.
@DataProvider(name = "eventToDto")
private static Object[][] eventToDto() {
SystemStatusChangedEvent statusChanged = new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN);
StoppingSystemServiceEvent stoppingService = new StoppingSystemServiceEvent("service1");
SystemServiceStoppedEvent serviceStopped = new SystemServiceStoppedEvent("service1");
SystemServiceItemStoppedEvent itemStopped = new SystemServiceItemStoppedEvent("service1", "item1", 5, 10);
return new Object[][] { { statusChanged, DtoConverter.asDto(statusChanged) }, { stoppingService, DtoConverter.asDto(stoppingService) }, { serviceStopped, DtoConverter.asDto(serviceStopped) }, { itemStopped, DtoConverter.asDto(itemStopped) } };
}
use of org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent in project che by eclipse.
the class WorkspaceServiceTerminationTest method publishesStoppedWorkspaceStoppedEventsAsServiceItemStoppedEvents.
@Test
public void publishesStoppedWorkspaceStoppedEventsAsServiceItemStoppedEvents() throws Exception {
when(workspaceManager.getRunningWorkspacesIds()).thenReturn(ImmutableSet.of("id1", "id2", "id3"));
doAnswer(inv -> {
@SuppressWarnings("unchecked") EventSubscriber<WorkspaceStatusEvent> subscriber = (EventSubscriber<WorkspaceStatusEvent>) inv.getArguments()[0];
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STARTING, "id1"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.RUNNING, "id1"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STOPPING, "id1"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STOPPED, "id1"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.RUNNING, "id2"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STOPPING, "id2"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STOPPED, "id2"));
subscriber.onEvent(newWorkspaceStatusEvent(WorkspaceStatus.STOPPED, "id3"));
return null;
}).when(eventService).subscribe(any());
termination.terminate();
verify(eventService).publish(new SystemServiceItemStoppedEvent("workspace", "id1", 1, 3));
verify(eventService).publish(new SystemServiceItemStoppedEvent("workspace", "id2", 2, 3));
verify(eventService).publish(new SystemServiceItemStoppedEvent("workspace", "id3", 3, 3));
}
Aggregations