Search in sources :

Example 26 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfAttributeNameIsNull.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Attribute name 'null' is not valid")
public void shouldFailValidationIfAttributeNameIsNull() throws Exception {
    final AccountImpl account = new AccountImpl("accountId", "namespace", "test");
    final WorkspaceImpl workspace = new WorkspaceImpl("id", account, createConfig());
    workspace.getAttributes().put(null, "value1");
    wsValidator.validateWorkspace(workspace);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Test(org.testng.annotations.Test)

Example 27 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class DefaultWorkspaceValidatorTest method shouldFailValidationIfAttributeNameIsEmpty.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Attribute name '' is not valid")
public void shouldFailValidationIfAttributeNameIsEmpty() throws Exception {
    final AccountImpl account = new AccountImpl("accountId", "namespace", "test");
    final WorkspaceImpl workspace = new WorkspaceImpl("id", account, createConfig());
    workspace.getAttributes().put("", "value1");
    wsValidator.validateWorkspace(workspace);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) AccountImpl(org.eclipse.che.account.spi.AccountImpl) Test(org.testng.annotations.Test)

Example 28 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method usesProvidedEnvironmentInsteadOfDefault.

@Test
public void usesProvidedEnvironmentInsteadOfDefault() throws Exception {
    WorkspaceConfigImpl config = createConfig();
    config.getEnvironments().put("non-default-env", new EnvironmentImpl(null, null));
    WorkspaceImpl workspace = createAndMockWorkspace(config, NAMESPACE);
    mockStart(workspace);
    workspaceManager.startWorkspace(workspace.getId(), "non-default-env", false);
    verify(runtimes).startAsync(workspaceCaptor.capture(), eq("non-default-env"), eq(false));
    assertEquals(workspaceCaptor.getValue().getConfig(), config);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) Test(org.testng.annotations.Test)

Example 29 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method stopsRunningWorkspacesOnShutdown.

@Test
public void stopsRunningWorkspacesOnShutdown() throws Exception {
    when(runtimes.refuseWorkspacesStart()).thenReturn(true);
    WorkspaceImpl stopped = createAndMockWorkspace();
    mockRuntime(stopped, STOPPED);
    WorkspaceImpl starting = createAndMockWorkspace();
    mockRuntime(starting, STARTING);
    WorkspaceImpl running = createAndMockWorkspace();
    mockRuntime(running, RUNNING);
    when(runtimes.getRuntimesIds()).thenReturn(new HashSet<>(asList(running.getId(), starting.getId())));
    // action
    workspaceManager.shutdown();
    captureRunAsyncCallsAndRunSynchronously();
    verify(runtimes).stop(running.getId());
    verify(runtimes).stop(starting.getId());
    verify(runtimes, never()).stop(stopped.getId());
    verify(runtimes).shutdown();
    verify(sharedPool).shutdown();
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 30 with WorkspaceImpl

use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.

the class WorkspaceManagerTest method shouldBeAbleToCreateWorkspaceWithAttributes.

@Test
public void shouldBeAbleToCreateWorkspaceWithAttributes() throws Exception {
    WorkspaceImpl workspace = workspaceManager.createWorkspace(createConfig(), NAMESPACE, singletonMap("testKey", "testValue"));
    assertEquals(workspace.getAttributes().get("testKey"), "testValue");
    assertEquals(workspace.getStatus(), STOPPED);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Aggregations

WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)165 Test (org.testng.annotations.Test)130 Response (com.jayway.restassured.response.Response)34 WorkspaceRuntimeImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceRuntimeImpl)15 ServerException (org.eclipse.che.api.core.ServerException)14 SnapshotImpl (org.eclipse.che.api.machine.server.model.impl.SnapshotImpl)12 ApiOperation (io.swagger.annotations.ApiOperation)11 ApiResponses (io.swagger.annotations.ApiResponses)11 AccountImpl (org.eclipse.che.account.spi.AccountImpl)11 Path (javax.ws.rs.Path)10 Produces (javax.ws.rs.Produces)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)10 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)9 WorkspaceConfigImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl)9 NotFoundException (org.eclipse.che.api.core.NotFoundException)8 MachineImpl (org.eclipse.che.api.machine.server.model.impl.MachineImpl)8 Consumes (javax.ws.rs.Consumes)7 ConflictException (org.eclipse.che.api.core.ConflictException)7 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)7 ProjectConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)7