Search in sources :

Example 1 with RuntimeAbnormalStoppingEvent

use of org.eclipse.che.api.workspace.server.event.RuntimeAbnormalStoppingEvent in project che-server by eclipse-che.

the class WorkspaceRuntimesTest method stoppingStatusIsSetWhenRuntimeAbnormallyStopping.

@Test
public void stoppingStatusIsSetWhenRuntimeAbnormallyStopping() throws Exception {
    String error = "Some kind of error happened";
    EventService localEventService = new EventService();
    WorkspaceRuntimes localRuntimes = new WorkspaceRuntimes(localEventService, ImmutableMap.of(TEST_ENVIRONMENT_TYPE, testEnvFactory), infrastructure, sharedPool, workspaceDao, dbInitializer, probeScheduler, statuses, lockService, devfileConverter, false);
    localRuntimes.init();
    RuntimeIdentityDto identity = DtoFactory.newDto(RuntimeIdentityDto.class).withWorkspaceId("workspace123").withEnvName("my-env").withOwnerId("myId");
    mockWorkspaceWithConfig(identity);
    RuntimeContext context = mockContext(identity);
    when(context.getRuntime()).thenReturn(new TestInternalRuntime(context));
    RuntimeAbnormalStoppingEvent event = new RuntimeAbnormalStoppingEvent(identity, error);
    localRuntimes.recoverOne(infrastructure, identity);
    // when
    localEventService.publish(event);
    // then
    verify(statuses).replace("workspace123", WorkspaceStatus.STOPPING);
}
Also used : RuntimeAbnormalStoppingEvent(org.eclipse.che.api.workspace.server.event.RuntimeAbnormalStoppingEvent) RuntimeIdentityDto(org.eclipse.che.api.workspace.shared.dto.RuntimeIdentityDto) EventService(org.eclipse.che.api.core.notification.EventService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RuntimeContext(org.eclipse.che.api.workspace.server.spi.RuntimeContext) Test(org.testng.annotations.Test)

Example 2 with RuntimeAbnormalStoppingEvent

use of org.eclipse.che.api.workspace.server.event.RuntimeAbnormalStoppingEvent in project devspaces-images by redhat-developer.

the class WorkspaceRuntimesTest method stoppingStatusIsSetWhenRuntimeAbnormallyStopping.

@Test
public void stoppingStatusIsSetWhenRuntimeAbnormallyStopping() throws Exception {
    String error = "Some kind of error happened";
    EventService localEventService = new EventService();
    WorkspaceRuntimes localRuntimes = new WorkspaceRuntimes(localEventService, ImmutableMap.of(TEST_ENVIRONMENT_TYPE, testEnvFactory), infrastructure, sharedPool, workspaceDao, dbInitializer, probeScheduler, statuses, lockService, devfileConverter, false);
    localRuntimes.init();
    RuntimeIdentityDto identity = DtoFactory.newDto(RuntimeIdentityDto.class).withWorkspaceId("workspace123").withEnvName("my-env").withOwnerId("myId");
    mockWorkspaceWithConfig(identity);
    RuntimeContext context = mockContext(identity);
    when(context.getRuntime()).thenReturn(new TestInternalRuntime(context));
    RuntimeAbnormalStoppingEvent event = new RuntimeAbnormalStoppingEvent(identity, error);
    localRuntimes.recoverOne(infrastructure, identity);
    // when
    localEventService.publish(event);
    // then
    verify(statuses).replace("workspace123", WorkspaceStatus.STOPPING);
}
Also used : RuntimeAbnormalStoppingEvent(org.eclipse.che.api.workspace.server.event.RuntimeAbnormalStoppingEvent) RuntimeIdentityDto(org.eclipse.che.api.workspace.shared.dto.RuntimeIdentityDto) EventService(org.eclipse.che.api.core.notification.EventService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) RuntimeContext(org.eclipse.che.api.workspace.server.spi.RuntimeContext) Test(org.testng.annotations.Test)

Aggregations

EventService (org.eclipse.che.api.core.notification.EventService)2 RuntimeAbnormalStoppingEvent (org.eclipse.che.api.workspace.server.event.RuntimeAbnormalStoppingEvent)2 RuntimeContext (org.eclipse.che.api.workspace.server.spi.RuntimeContext)2 RuntimeIdentityDto (org.eclipse.che.api.workspace.shared.dto.RuntimeIdentityDto)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 Test (org.testng.annotations.Test)2