use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method snapshottedAtAttributeIncludedToWorkspaceWhenStartingById.
@Test
public void snapshottedAtAttributeIncludedToWorkspaceWhenStartingById() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
mockSnapshots(workspace, 12345);
mockStart(workspace);
Workspace result = workspaceManager.startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), false);
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 WorkspaceServiceTest method shouldGetWorkspaces.
@Test
public void shouldGetWorkspaces() throws Exception {
final WorkspaceImpl workspace1 = createWorkspace(createConfigDto());
final WorkspaceImpl workspace2 = createWorkspace(createConfigDto(), STARTING);
when(wsManager.getWorkspaces(USER_ID, false)).thenReturn(asList(workspace1, workspace2));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace");
assertEquals(response.getStatusCode(), 200);
assertEquals(unwrapDtoList(response, WorkspaceDto.class).stream().map(ws -> new WorkspaceImpl(ws, TEST_ACCOUNT)).collect(toList()), asList(workspace1, workspace2));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldUseUsernameAsNamespaceWhenStartingWorkspaceFromConfigWithoutNamespace.
@Test
public void shouldUseUsernameAsNamespaceWhenStartingWorkspaceFromConfigWithoutNamespace() 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" + "?temporary=true");
assertEquals(response.getStatusCode(), 200);
verify(validator).validateConfig(any());
verify(wsManager).startWorkspace(any(), eq(NAMESPACE), eq(true));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldCreateWorkspace.
@Test
public void shouldCreateWorkspace() 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" + "?namespace=test" + "&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("test"), eq(ImmutableMap.of("stackId", "stack123", "factoryId", "factory123", "custom", "custom:value")));
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldRespond404WhenUpdatingEnvironmentWhichDoesNotExist.
@Test
public void shouldRespond404WhenUpdatingEnvironmentWhichDoesNotExist() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(createEnvDto()).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/environment/fake");
assertEquals(response.getStatusCode(), 404);
assertEquals(unwrapError(response), "Workspace '" + workspace.getId() + "' doesn't contain environment 'fake'");
verify(wsManager, never()).updateWorkspace(any(), any());
}
Aggregations