use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class FactoryServiceTest method shouldGenerateFactoryJsonIncludeGivenProjects.
@Test
public void shouldGenerateFactoryJsonIncludeGivenProjects() throws Exception {
// given
final String wsId = "workspace123234";
WorkspaceImpl.WorkspaceImplBuilder ws = WorkspaceImpl.builder();
WorkspaceConfigImpl.WorkspaceConfigImplBuilder wsConfig = WorkspaceConfigImpl.builder();
ws.setId(wsId);
wsConfig.setProjects(Arrays.asList(DTO.createDto(ProjectConfigDto.class).withPath("/proj1").withSource(DTO.createDto(SourceStorageDto.class).withType("git").withLocation("location")), DTO.createDto(ProjectConfigDto.class).withPath("/proj2").withSource(DTO.createDto(SourceStorageDto.class).withType("git").withLocation("location"))));
wsConfig.setName("wsname");
wsConfig.setEnvironments(singletonMap("env1", DTO.createDto(EnvironmentDto.class)));
wsConfig.setDefaultEnv("env1");
ws.setStatus(WorkspaceStatus.RUNNING);
wsConfig.setCommands(singletonList(DTO.createDto(CommandDto.class).withName("MCI").withType("mvn").withCommandLine("clean install")));
ws.setConfig(wsConfig.build());
WorkspaceImpl usersWorkspace = ws.build();
when(workspaceManager.getWorkspace(eq(wsId))).thenReturn(usersWorkspace);
// when
Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get("/private" + SERVICE_PATH + "/workspace/" + wsId);
// then
assertEquals(response.getStatusCode(), 200);
FactoryDto result = DTO.createDtoFromJson(response.getBody().asString(), FactoryDto.class);
assertEquals(result.getWorkspace().getProjects().size(), 2);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToUpdateWorkspace.
@Test
public void shouldBeAbleToUpdateWorkspace() throws Exception {
WorkspaceImpl workspace = new WorkspaceImpl(createAndMockWorkspace());
workspace.setTemporary(true);
workspace.getAttributes().put("new attribute", "attribute");
when(workspaceDao.update(any())).thenAnswer(inv -> inv.getArguments()[0]);
workspaceManager.updateWorkspace(workspace.getId(), workspace);
verify(workspaceDao).update(workspace);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method snapshottedAtAttributeIncludedToWorkspaceWhenGettingByNamespaceAndName.
@Test
public void snapshottedAtAttributeIncludedToWorkspaceWhenGettingByNamespaceAndName() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
mockSnapshots(workspace, 12345);
WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getConfig().getName(), workspace.getNamespace());
assertEquals(result.getAttributes().get(SNAPSHOTTED_AT_ATTRIBUTE_NAME), "12345");
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method interruptsStartAfterEnvironmentIsStartedButRuntimeStatusIsNotRunning.
@Test
public void interruptsStartAfterEnvironmentIsStartedButRuntimeStatusIsNotRunning() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
// let's say status is changed to STOPPING by stop method,
// but starting thread hasn't been interrupted yet
allowEnvironmentStart(workspace, "env-name", () -> setRuntime("workspace", WorkspaceStatus.STOPPING));
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAndVerifyRuntimeStateAfterInterruption(workspace, cmpFuture);
verifyEventsSequence(event("workspace", WorkspaceStatus.STOPPED, WorkspaceStatus.STARTING, EventType.STARTING, null), event("workspace", WorkspaceStatus.STARTING, WorkspaceStatus.STOPPING, EventType.STOPPING, null), event("workspace", WorkspaceStatus.STOPPING, WorkspaceStatus.STOPPED, EventType.STOPPED, null));
verify(envEngine).stop(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceRuntimesTest method interruptsStartAfterEnvironmentIsStartedButThreadIsInterrupted.
@Test
public void interruptsStartAfterEnvironmentIsStartedButThreadIsInterrupted() throws Exception {
WorkspaceImpl workspace = newWorkspace("workspace", "env-name");
// the status is successfully updated from STARTING -> RUNNING but after
// that thread is interrupted so #stop is waiting for starting thread to stop the environment
allowEnvironmentStart(workspace, "env-name", () -> Thread.currentThread().interrupt());
CompletableFuture<WorkspaceRuntimeImpl> cmpFuture = runtimes.startAsync(workspace, "env-name", false);
captureAndVerifyRuntimeStateAfterInterruption(workspace, cmpFuture);
verifyEventsSequence(event("workspace", WorkspaceStatus.STOPPED, WorkspaceStatus.STARTING, EventType.STARTING, null), event("workspace", WorkspaceStatus.STARTING, WorkspaceStatus.STOPPING, EventType.STOPPING, null), event("workspace", WorkspaceStatus.STOPPING, WorkspaceStatus.STOPPED, EventType.STOPPED, null));
verify(envEngine).stop(workspace.getId());
}
Aggregations