WorkspaceManager { public WorkspaceImpl getWorkspace(String key) throws NotFoundException, ServerException { requireNonNull(key, "Required non-null workspace key"); return normalizeState(getByKey(key), true); } @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 getsWorkspaceByIdWithoutRuntime() throws Exception { WorkspaceImpl workspace = createAndMockWorkspace(); final WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getId()); assertEquals(result, workspace); }
@Test public void getsWorkspaceByName() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); final WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getName(), workspace.getNamespace()); assertEquals(result, workspace); }
@Test(expectedExceptions = NotFoundException.class) public void throwsNotFoundExceptionWhenWorkspaceDoesNotExist() throws Exception { when(workspaceDao.get(any())).thenThrow(new NotFoundException("not found")); workspaceManager.getWorkspace("workspace123"); }
@Test public void getsWorkspaceByKey() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); final WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getNamespace() + ":" + workspace.getName()); assertEquals(result, workspace); }
@Test public void getsWorkspaceByKeyWithoutOwner() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); final WorkspaceImpl result = workspaceManager.getWorkspace(":" + workspace.getName()); assertEquals(result, workspace); }
@Test public void getsWorkspaceByNameReturnWorkspaceWithStatusEqualToItsRuntimeStatus() throws Exception { final WorkspaceImpl workspace = createAndMockWorkspace(); mockRuntime(workspace, STARTING); final WorkspaceImpl result = workspaceManager.getWorkspace(workspace.getName(), workspace.getNamespace()); assertEquals( result.getStatus(), STARTING, "Workspace status must be taken from the runtime instance"); }