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()));
}
});
}
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());
}
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();
}
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);
}
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);
}
Aggregations