Search in sources :

Example 16 with WorkspaceConfigDto

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

the class WorkspaceEventsHandlerTest method shouldSubscribesOnWsAgentOutputWhenWorkspaceIsStarting.

//    @Test disabled because of GWT timer usage
public void shouldSubscribesOnWsAgentOutputWhenWorkspaceIsStarting() throws Exception {
    WorkspaceRuntimeDto runtime = mock(WorkspaceRuntimeDto.class);
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspaceStatusEvent.getEventType()).thenReturn(STARTING);
    when(workspace.getRuntime()).thenReturn(runtime);
    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);
    workspaceEventsHandler.workspaceStatusSubscriptionHandler.onMessageReceived(workspaceStatusEvent);
    verify(workspacePromise).then(workspaceCaptor.capture());
    workspaceCaptor.getValue().apply(workspace);
    verify(messageBus, times(2)).subscribe(eq(WS_AGENT_LOG_CHANNEL), (MessageHandler) anyObject());
}
Also used : WorkspaceRuntimeDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto) 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)

Example 17 with WorkspaceConfigDto

use of org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto 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)

Example 18 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldValidateCorrectWorkspaceName.

@Test(dataProvider = "validNameProvider")
public void shouldValidateCorrectWorkspaceName(String name) throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.withName(name);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 19 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfNameIsNull.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace name required")
public void shouldFailValidationIfNameIsNull() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.withName(null);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Example 20 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfCommandNameIsNull.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Workspace ws-name contains command with null or empty name")
public void shouldFailValidationIfCommandNameIsNull() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    config.getCommands().get(0).withName(null);
    wsValidator.validateConfig(config);
}
Also used : WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) Test(org.testng.annotations.Test)

Aggregations

WorkspaceConfigDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto)29 Test (org.testng.annotations.Test)17 EnvironmentDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentDto)8 HashMap (java.util.HashMap)6 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)6 Test (org.junit.Test)5 ExtendedMachineDto (org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto)4 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)4 Matchers.anyString (org.mockito.Matchers.anyString)4 Response (com.jayway.restassured.response.Response)3 CommandDto (org.eclipse.che.api.machine.shared.dto.CommandDto)3 MachineConfigDto (org.eclipse.che.api.machine.shared.dto.MachineConfigDto)3 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)3 EnvironmentRecipeDto (org.eclipse.che.api.workspace.shared.dto.EnvironmentRecipeDto)3 WorkspaceRuntimeDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 MachineDto (org.eclipse.che.api.machine.shared.dto.MachineDto)2 StackComponentDto (org.eclipse.che.api.workspace.shared.dto.stack.StackComponentDto)2 StackDto (org.eclipse.che.api.workspace.shared.dto.stack.StackDto)2