Search in sources :

Example 1 with SystemServiceItemStoppedEvent

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());
}
Also used : SystemServiceItemStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent) SystemServiceItemStoppedEventDto(org.eclipse.che.api.system.shared.dto.SystemServiceItemStoppedEventDto) Test(org.testng.annotations.Test)

Example 2 with SystemServiceItemStoppedEvent

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) } };
}
Also used : SystemStatusChangedEvent(org.eclipse.che.api.system.shared.event.SystemStatusChangedEvent) SystemServiceItemStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent) StoppingSystemServiceEvent(org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent) SystemServiceStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent) DataProvider(org.testng.annotations.DataProvider)

Example 3 with SystemServiceItemStoppedEvent

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));
}
Also used : EventSubscriber(org.eclipse.che.api.core.notification.EventSubscriber) SystemServiceItemStoppedEvent(org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent) WorkspaceStatusEvent(org.eclipse.che.api.workspace.shared.dto.event.WorkspaceStatusEvent) Test(org.testng.annotations.Test)

Aggregations

SystemServiceItemStoppedEvent (org.eclipse.che.api.system.shared.event.service.SystemServiceItemStoppedEvent)3 Test (org.testng.annotations.Test)2 EventSubscriber (org.eclipse.che.api.core.notification.EventSubscriber)1 SystemServiceItemStoppedEventDto (org.eclipse.che.api.system.shared.dto.SystemServiceItemStoppedEventDto)1 SystemStatusChangedEvent (org.eclipse.che.api.system.shared.event.SystemStatusChangedEvent)1 StoppingSystemServiceEvent (org.eclipse.che.api.system.shared.event.service.StoppingSystemServiceEvent)1 SystemServiceStoppedEvent (org.eclipse.che.api.system.shared.event.service.SystemServiceStoppedEvent)1 WorkspaceStatusEvent (org.eclipse.che.api.workspace.shared.dto.event.WorkspaceStatusEvent)1 DataProvider (org.testng.annotations.DataProvider)1