Search in sources :

Example 86 with WorkspaceImpl

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());
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 87 with WorkspaceImpl

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);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) ServerException(org.eclipse.che.api.core.ServerException) BeforeWorkspaceRemovedEvent(org.eclipse.che.api.workspace.server.event.BeforeWorkspaceRemovedEvent) Test(org.testng.annotations.Test)

Example 88 with WorkspaceImpl

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);
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) Test(org.testng.annotations.Test)

Example 89 with WorkspaceImpl

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;
}
Also used : WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)

Example 90 with WorkspaceImpl

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();
}
Also used : Path(java.nio.file.Path) WorkspaceImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl) WorkspaceConfigImpl(org.eclipse.che.api.workspace.server.model.impl.WorkspaceConfigImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

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