use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceDaoTest method shouldRemoveWorkspace.
@Test(expectedExceptions = NotFoundException.class, dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingWorkspaceById")
public void shouldRemoveWorkspace() throws Exception {
final WorkspaceImpl workspace = workspaces[0];
workspaceDao.remove(workspace.getId());
workspaceDao.get(workspace.getId());
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceDaoTest method shouldNotRemoveWorkspaceWhenSubscriberThrowsExceptionOnWorkspaceRemoving.
@Test(dependsOnMethods = "shouldGetWorkspaceById")
public void shouldNotRemoveWorkspaceWhenSubscriberThrowsExceptionOnWorkspaceRemoving() throws Exception {
final WorkspaceImpl workspace = workspaces[0];
CascadeEventSubscriber<BeforeWorkspaceRemovedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, BeforeWorkspaceRemovedEvent.class);
try {
workspaceDao.remove(workspace.getId());
fail("WorkspaceDao#remove had to throw server exception");
} catch (ServerException ignored) {
}
assertEquals(workspaceDao.get(workspace.getId()), workspace);
eventService.unsubscribe(subscriber, BeforeWorkspaceRemovedEvent.class);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceDaoTest method shouldThrowConflictExceptionWhenCreatingWorkspaceWithExistingId.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenCreatingWorkspaceWithExistingId() throws Exception {
final WorkspaceImpl workspace = workspaces[0];
final WorkspaceImpl newWorkspace = createWorkspace(workspace.getId(), accounts[0], "new-name");
workspaceDao.create(newWorkspace);
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class WorkspaceManager method getWorkspace.
/**
* Gets workspace by composite key.
*
* <p> Key rules:
* <ul>
* <li>@Deprecated : If it contains <b>:</b> character then that key is combination of namespace and workspace name
* <li>@Deprecated : <b></>:workspace_name</b> is valid abstract key and current user name will be used as namespace
* <li>If it doesn't contain <b>/</b> character then that key is id(e.g. workspace123456)
* <li>If it contains <b>/</b> character then that key is combination of namespace and workspace name
* </ul>
*
* Note that namespace can contain <b>/</b> character.
*
* @param key
* composite key(e.g. workspace 'id' or 'namespace/name')
* @return the workspace instance
* @throws NullPointerException
* when {@code key} is null
* @throws NotFoundException
* when workspace doesn't exist
* @throws ServerException
* when any server error occurs
*/
public WorkspaceImpl getWorkspace(String key) throws NotFoundException, ServerException {
requireNonNull(key, "Required non-null workspace key");
WorkspaceImpl workspace = getByKey(key);
runtimes.injectRuntime(workspace);
addExtraAttributes(workspace);
return workspace;
}
use of org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl in project che by eclipse.
the class LocalWorkspaceFolderPathProviderTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
WorkspaceImpl workspace = mock(WorkspaceImpl.class);
WorkspaceConfigImpl workspaceConfig = mock(WorkspaceConfigImpl.class);
when(workspaceManager.getWorkspace(WS_ID)).thenReturn(workspace);
when(workspace.getConfig()).thenReturn(workspaceConfig);
when(workspaceConfig.getName()).thenReturn(WS_NAME);
Path tempDirectory = Files.createTempDirectory(getClass().getSimpleName());
workspacesRoot = tempDirectory.toString();
workspacesRootFile = tempDirectory.toFile();
singleFolderForAllWorkspaces = Paths.get(workspacesRoot, "singleFolderForAllWorkspaces").toString();
oldWorkspacesRoot = Paths.get(workspacesRoot, "oldWorkspacesRoot").toString();
}
Aggregations