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);
}
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);
}
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);
}
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();
}
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);
}
Aggregations