use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method shouldUpdateCommand.
@Test
public void shouldUpdateCommand() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final CommandDto commandDto = createCommandDto();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(commandDto).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/command/" + commandDto.getName());
assertEquals(response.getStatusCode(), 200);
verify(validator).validateConfig(workspace.getConfig());
verify(wsManager).updateWorkspace(any(), any());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method stateOfWsAgentShouldBeChecked.
@Test
public void stateOfWsAgentShouldBeChecked() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
workspace.setStatus(RUNNING);
WsAgentHealthStateDto wsAgentState = newDto(WsAgentHealthStateDto.class);
WorkspaceRuntimeImpl runtime = mock(WorkspaceRuntimeImpl.class);
MachineImpl machine = mock(MachineImpl.class);
when(runtime.getDevMachine()).thenReturn(machine);
when(wsAgentHealthChecker.check(machine)).thenReturn(wsAgentState);
workspace.setRuntime(runtime);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/" + workspace.getId() + "/check");
verify(wsAgentHealthChecker).check(machine);
assertEquals(RUNNING, wsAgentState.getWorkspaceStatus());
assertEquals(200, response.getStatusCode());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceServiceTest method stateOfWsAgentShouldNotBeCheckedIfWsIsNotRunning.
@Test
public void stateOfWsAgentShouldNotBeCheckedIfWsIsNotRunning() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
workspace.setStatus(STARTING);
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/workspace/" + workspace.getId() + "/check");
verify(wsAgentHealthChecker, never()).check(any());
assertEquals(200, response.getStatusCode());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldNotStopMachineIfWorkspaceIsNotRunning.
@Test(expectedExceptions = ConflictException.class, expectedExceptionsMessageRegExp = "Could not .* the workspace '.*' because its status is '.*'.")
public void shouldNotStopMachineIfWorkspaceIsNotRunning() throws Exception {
// given
final WorkspaceImpl workspace = createAndMockWorkspace();
// when
workspaceManager.stopMachine(workspace.getId(), "someId");
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManagerTest method shouldBeAbleToGetWorkspaceByName.
@Test
public void shouldBeAbleToGetWorkspaceByName() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getConfig().getName(), workspace.getNamespace());
assertEquals(result, workspace);
}
Aggregations