WorkspaceManager { public Workspace getWorkspace(String name) { checkNotNull("name", name); Optional<Workspace> optionalWorkspace = this.workspaces.keySet() .stream() .filter(w -> name.equals(w.getName())) .findAny(); return optionalWorkspace .orElseThrow(() -> new NoSuchElementException(String.format("Workspace <<%s>> not found", name))); } WorkspaceManager(); @Inject  WorkspaceManager(WorkspaceManagerPreferences workspaceManagerPreferences); @PostConstruct void initialize(); Workspace getOrCreateWorkspace(String name); Workspace getWorkspace(String name); T getBean(Workspace workspace,
                         String beanName); void putBean(Workspace workspace,
                            String beanName,
                            T instance); void delete(final Workspace workspace); int getWorkspaceCount(); long getBeansCount(final Workspace workspace);  }
@Test public void testWorkspaceNotFound() { assertThatThrownBy(() -> workspaceManager.getWorkspace("none")) .isInstanceOf(NoSuchElementException.class) .hasMessage("Workspace <<none>> not found"); }