Search in sources :

Example 6 with WorkspaceRuntimeDto

use of org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto in project che by eclipse.

the class WorkspaceEventsHandlerTest method shouldSubscribeOnWsAgentOutputWhenWorkspaceIsRunningAfterRefreshPage.

@Test
public void shouldSubscribeOnWsAgentOutputWhenWorkspaceIsRunningAfterRefreshPage() throws Exception {
    WorkspaceRuntimeDto runtime = mock(WorkspaceRuntimeDto.class);
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspace.getRuntime()).thenReturn(runtime);
    MachineDto devMachine = mock(MachineDto.class);
    when(devMachine.getWorkspaceId()).thenReturn(WORKSPACE_ID);
    when(devMachine.getId()).thenReturn(MACHINE_NAME);
    when(runtime.getDevMachine()).thenReturn(devMachine);
    when(runtime.getActiveEnv()).thenReturn(ACTIVE_ENV);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    Map<String, EnvironmentDto> environments = new HashMap<>(3);
    EnvironmentDto environment = mock(EnvironmentDto.class);
    environments.put(ACTIVE_ENV, environment);
    when(workspaceConfig.getEnvironments()).thenReturn(environments);
    MachineConfigDto devMachineConfig = mock(MachineConfigDto.class);
    when(devMachineConfig.getName()).thenReturn(MACHINE_NAME);
    workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
    verify(messageBus).subscribe(eq(WS_AGENT_LOG_CHANNEL), (MessageHandler) anyObject());
}
Also used : WorkspaceRuntimeDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto) MachineDto(org.eclipse.che.api.machine.shared.dto.MachineDto) HashMap(java.util.HashMap) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) MachineConfigDto(org.eclipse.che.api.machine.shared.dto.MachineConfigDto) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)6 HashMap (java.util.HashMap)3 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)3 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)3 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)3 WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Test (org.junit.Test)2 ServerDto (org.eclipse.che.api.machine.shared.dto.ServerDto)1