WorkspaceRuntimes { public Set<String> getRunning() { return statuses .asMap() .entrySet() .stream() .filter(e -> RUNNING == e.getValue()) .map(Entry::getKey) .collect(toSet()); } @VisibleForTesting  WorkspaceRuntimes(
      ConcurrentMap<String, InternalRuntime<?>> runtimes,
      EventService eventService,
      Map<String, InternalEnvironmentFactory> envFactories,
      RuntimeInfrastructure infra,
      WorkspaceSharedPool sharedPool,
      WorkspaceDao workspaceDao,
      @SuppressWarnings("unused") DBInitializer ignored,
      ProbeScheduler probeScheduler,
      WorkspaceStatusCache statuses,
      WorkspaceLockService lockService,
      DevfileConverter devfileConverter); @Inject  WorkspaceRuntimes(
      EventService eventService,
      Map<String, InternalEnvironmentFactory> envFactories,
      RuntimeInfrastructure infra,
      WorkspaceSharedPool sharedPool,
      WorkspaceDao workspaceDao,
      @SuppressWarnings("unused") DBInitializer ignored,
      ProbeScheduler probeScheduler,
      WorkspaceStatusCache statuses,
      WorkspaceLockService lockService,
      DevfileConverter devfileConverter); void validate(WorkspaceImpl workspace, @Nullable String envName); String evalInfrastructureNamespace(NamespaceResolutionContext resolutionCtx); String evalLegacyInfrastructureNamespace(NamespaceResolutionContext resolutionContext); boolean isInfrastructureNamespaceValid(String namespaceName); void injectRuntime(WorkspaceImpl workspace); boolean hasRuntime(String workspaceId); InternalRuntime<?> getInternalRuntime(String workspaceId); WorkspaceStatus getStatus(String workspaceId); @Traced CompletableFuture<Void> startAsync(
      WorkspaceImpl workspace, @Nullable String envName, Map<String, String> options); @Traced CompletableFuture<Void> stopAsync(WorkspaceImpl workspace, Map<String, String> options); boolean refuseStart(); Set<String> getRunning(); Set<String> getActive(); Set<String> getActive(String owner); boolean isAnyActive(); Set<String> getInProgress(); Set<String> getInProgress(String owner); boolean isAnyInProgress(); Optional<RuntimeContext> getRuntimeContext(String workspaceId); Set<String> getSupportedRecipes();  }
@Test public void shouldReturnWorkspaceIdsOfRunningRuntimes() { when(statuses.asMap()) .thenReturn( ImmutableMap.of( "ws1", WorkspaceStatus.STARTING, "ws2", WorkspaceStatus.RUNNING, "ws3", WorkspaceStatus.RUNNING, "ws4", WorkspaceStatus.RUNNING, "ws5", WorkspaceStatus.STOPPING)); Set<String> running = runtimes.getRunning(); assertEquals(running.size(), 3); assertTrue(running.containsAll(asList("ws2", "ws3", "ws4"))); }