use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldRestoreWorkspace.
@Test
public void shouldRestoreWorkspace() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.startWorkspace(any(), any(), any())).thenReturn(workspace);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().post(SECURE_PATH + "/workspace/" + workspace.getId() + "/runtime" + "?environment=" + workspace.getConfig().getDefaultEnv() + "&restore=true");
assertEquals(response.getStatusCode(), 200);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(wsManager).startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), true);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldStartWorkspaceFromConfig.
@Test
public void shouldStartWorkspaceFromConfig() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.startWorkspace(anyObject(), anyString(), anyBoolean())).thenReturn(workspace);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final WorkspaceDto workspaceDto = DtoConverter.asDto(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(workspaceDto.getConfig()).when().post(SECURE_PATH + "/workspace/runtime" + "?namespace=test" + "&temporary=true");
assertEquals(response.getStatusCode(), 200);
verify(validator).validateConfig(any());
verify(wsManager).startWorkspace(any(), eq("test"), eq(true));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldGetWorkspaceByKey.
@Test
public void shouldGetWorkspaceByKey() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getNamespace() + "/" + workspace.getConfig().getName())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/" + workspace.getNamespace() + "/" + workspace.getConfig().getName());
assertEquals(response.getStatusCode(), 200);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldDeleteWorkspace.
@Test
public void shouldDeleteWorkspace() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.getSnapshot(anyString())).thenReturn(ImmutableList.of(mock(SnapshotImpl.class)));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().delete(SECURE_PATH + "/workspace/" + workspace.getId());
assertEquals(response.getStatusCode(), 204);
verify(wsManager).removeSnapshots(workspace.getId());
verify(wsManager).removeWorkspace(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldUseUsernameAsNamespaceWhenCreatingWorkspaceWithoutSpecifiedNamespace.
@Test
public void shouldUseUsernameAsNamespaceWhenCreatingWorkspaceWithoutSpecifiedNamespace() throws Exception {
final WorkspaceConfigDto configDto = createConfigDto();
final WorkspaceImpl workspace = createWorkspace(configDto);
when(wsManager.createWorkspace(any(), any(), any())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(configDto).when().post(SECURE_PATH + "/workspace" + "?attribute=stackId:stack123" + "&attribute=factoryId:factory123" + "&attribute=custom:custom:value");
assertEquals(response.getStatusCode(), 201);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT), workspace);
verify(validator).validateConfig(any());
verify(validator).validateAttributes(any());
verify(wsManager).createWorkspace(anyObject(), eq(NAMESPACE), eq(ImmutableMap.of("stackId", "stack123", "factoryId", "factory123", "custom", "custom:value")));
}
Aggregations