Search in sources :

Example 1 with WorkspaceConfigDto

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

the class CreateWorkspacePresenter method createWorkspace.

private void createWorkspace() {
    WorkspaceConfigDto workspaceConfig = getWorkspaceConfig();
    workspaceClient.create(workspaceConfig, null).then(new Operation<WorkspaceDto>() {

        @Override
        public void apply(WorkspaceDto workspace) throws OperationException {
            DefaultWorkspaceComponent component = wsComponentProvider.get();
            component.startWorkspace(workspace, callback);
        }
    }).catchError(new Operation<PromiseError>() {

        @Override
        public void apply(PromiseError arg) throws OperationException {
            callback.onFailure(new Exception(arg.getCause()));
        }
    });
}
Also used : DefaultWorkspaceComponent(org.eclipse.che.ide.workspace.DefaultWorkspaceComponent) PromiseError(org.eclipse.che.api.promises.client.PromiseError) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) Operation(org.eclipse.che.api.promises.client.Operation) OperationException(org.eclipse.che.api.promises.client.OperationException) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 2 with WorkspaceConfigDto

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

the class WorkspaceEventsHandlerTest method onWsAgentOutputEventReceivedTest.

@Test
public void onWsAgentOutputEventReceivedTest() 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);
    workspaceEventsHandler.wsAgentLogSubscriptionHandler.onMessageReceived("");
    verify(eventBus).fireEvent(Matchers.<EnvironmentOutputEvent>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 3 with WorkspaceConfigDto

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

the class WorkspaceEventsHandlerTest method onErrorEventReceivedTest.

@Test
public void onErrorEventReceivedTest() throws Exception {
    WorkspaceConfigDto workspaceConfig = mock(WorkspaceConfigDto.class);
    when(workspace.getConfig()).thenReturn(workspaceConfig);
    when(workspaceServiceClient.getWorkspaces(anyInt(), anyInt())).thenReturn(workspacesPromise);
    List<WorkspaceDto> workspaces = new ArrayList<>(1);
    workspaces.add(workspace);
    MessageDialog errorDialog = mock(MessageDialog.class);
    when(dialogFactory.createMessageDialog(anyString(), anyString(), (ConfirmCallback) anyObject())).thenReturn(errorDialog);
    when(workspaceStatusEvent.getEventType()).thenReturn(ERROR);
    workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
    workspaceEventsHandler.workspaceStatusSubscriptionHandler.onMessageReceived(workspaceStatusEvent);
    verify(workspacesPromise).then(workspacesCaptor.capture());
    workspacesCaptor.getValue().apply(workspaces);
    verify(notificationManager).notify(anyString(), eq(StatusNotification.Status.FAIL), eq(FLOAT_MODE));
    verify(startWorkspaceNotification).show(WORKSPACE_ID);
    verify(eventBus, times(2)).fireEvent(Matchers.<WorkspaceStoppedEvent>anyObject());
    verify(eventBus, times(2)).fireEvent(Matchers.<WsAgentStateEvent>anyObject());
    verify(errorDialog).show();
}
Also used : ArrayList(java.util.ArrayList) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) WorkspaceDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceDto) MessageDialog(org.eclipse.che.ide.api.dialogs.MessageDialog) Test(org.junit.Test)

Example 4 with WorkspaceConfigDto

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

the class FactoryBuilderTest method prepareFactory.

private static FactoryDto prepareFactory() {
    ProjectConfigDto project = dto.createDto(ProjectConfigDto.class).withSource(dto.createDto(SourceStorageDto.class).withType("git").withLocation("location")).withType("type").withAttributes(singletonMap("key", singletonList("value"))).withDescription("description").withName("name").withPath("/path");
    EnvironmentDto environment = dto.createDto(EnvironmentDto.class).withRecipe(newDto(EnvironmentRecipeDto.class).withType("compose").withContentType("application/x-yaml").withContent("some content")).withMachines(singletonMap("devmachine", newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent")).withAttributes(singletonMap("memoryLimitBytes", "" + 512L * 1024L * 1024L))));
    WorkspaceConfigDto workspaceConfig = dto.createDto(WorkspaceConfigDto.class).withProjects(singletonList(project)).withCommands(singletonList(dto.createDto(CommandDto.class).withName("command1").withType("maven").withCommandLine("mvn test"))).withDefaultEnv("env1").withEnvironments(singletonMap("test", environment));
    IdeDto ide = dto.createDto(IdeDto.class).withOnAppClosed(dto.createDto(OnAppClosedDto.class).withActions(singletonList(dto.createDto(IdeActionDto.class).withId("warnOnClose")))).withOnAppLoaded(dto.createDto(OnAppLoadedDto.class).withActions(asList(dto.createDto(IdeActionDto.class).withId("newProject"), dto.createDto(IdeActionDto.class).withId("openWelcomePage").withProperties(ImmutableMap.of("authenticatedTitle", "Greeting title for authenticated users", "authenticatedContentUrl", "http://example.com/content.url"))))).withOnProjectsLoaded(dto.createDto(OnProjectsLoadedDto.class).withActions(asList(dto.createDto(IdeActionDto.class).withId("openFile").withProperties(singletonMap("file", "pom.xml")), dto.createDto(IdeActionDto.class).withId("run"), dto.createDto(IdeActionDto.class).withId("findReplace").withProperties(ImmutableMap.of("in", "src/main/resources/consts2.properties", "find", "OLD_VALUE_2", "replace", "NEW_VALUE_2", "replaceMode", "mode")))));
    return dto.createDto(FactoryDto.class).withV("4.0").withWorkspace(workspaceConfig).withCreator(dto.createDto(AuthorDto.class).withEmail("email").withName("name")).withPolicies(dto.createDto(PoliciesDto.class).withReferer("referrer").withSince(123L).withUntil(123L)).withButton(dto.createDto(ButtonDto.class).withType(Button.Type.LOGO).withAttributes(dto.createDto(ButtonAttributesDto.class).withColor("color").withCounter(true).withLogo("logo").withStyle("style"))).withIde(ide);
}
Also used : ButtonAttributesDto(org.eclipse.che.api.factory.shared.dto.ButtonAttributesDto) OnAppLoadedDto(org.eclipse.che.api.factory.shared.dto.OnAppLoadedDto) IdeDto(org.eclipse.che.api.factory.shared.dto.IdeDto) IdeActionDto(org.eclipse.che.api.factory.shared.dto.IdeActionDto) EnvironmentDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentDto) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) WorkspaceConfigDto(org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto) CommandDto(org.eclipse.che.api.machine.shared.dto.CommandDto) EnvironmentRecipeDto(org.eclipse.che.api.workspace.shared.dto.EnvironmentRecipeDto)

Example 5 with WorkspaceConfigDto

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

the class DefaultWorkspaceValidatorTest method shouldValidateCorrectWorkspace.

@Test
public void shouldValidateCorrectWorkspace() throws Exception {
    final WorkspaceConfigDto config = createConfig();
    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