WorkspaceManager { @Traced public void removeWorkspace(String workspaceId) throws ConflictException, ServerException { TracingTags.WORKSPACE_ID.set(workspaceId); requireNonNull(workspaceId, "Required non-null workspace id"); if (runtimes.hasRuntime(workspaceId)) { throw new ConflictException( format("The workspace '%s' is currently running and cannot be removed.", workspaceId)); } Optional<WorkspaceImpl> workspaceOpt = workspaceDao.remove(workspaceId); LOG.info("Workspace '{}' removed by user '{}'", workspaceId, sessionUserNameOrUndefined()); } @Inject  WorkspaceManager(
      WorkspaceDao workspaceDao,
      WorkspaceRuntimes runtimes,
      EventService eventService,
      AccountManager accountManager,
      PreferenceManager preferenceManager,
      WorkspaceValidator validator,
      DevfileIntegrityValidator devfileIntegrityValidator); @Traced WorkspaceImpl createWorkspace(
      WorkspaceConfig config, String namespace, Map<String, String> attributes); @Traced WorkspaceImpl createWorkspace(
      Devfile devfile,
      String namespace,
      Map<String, String> attributes,
      FileContentProvider contentProvider); WorkspaceImpl getWorkspace(String key); WorkspaceImpl getWorkspace(String name, String namespace); Page<WorkspaceImpl> getWorkspaces(
      String user, boolean includeRuntimes, int maxItems, long skipCount); Page<WorkspaceImpl> getByNamespace(
      String namespace, boolean includeRuntimes, int maxItems, long skipCount); WorkspaceImpl updateWorkspace(String id, Workspace update); @Traced void removeWorkspace(String workspaceId); WorkspaceImpl startWorkspace(
      String workspaceId, @Nullable String envName, @Nullable Map<String, String> options); WorkspaceImpl startWorkspace(
      WorkspaceConfig config, String namespace, boolean isTemporary, Map<String, String> options); void stopWorkspace(String workspaceId, Map<String, String> options); Set<String> getSupportedRecipes(); long getWorkspacesTotalCount();  }
@Test public void removesWorkspace() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); workspaceManager.removeWorkspace(workspace.getId()); verify(workspaceDao).remove(workspace.getId()); }
@Test(expectedExceptions = ConflictException.class) public void throwsExceptionWhenRemoveNotStoppedWorkspace() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); when(runtimes.hasRuntime(workspace.getId())).thenReturn(true); workspaceManager.removeWorkspace(workspace.getId()); }