### Question:
InMemoryRepositorySource implements BaseRepositorySource, ObjectFactory { public synchronized RepositoryConnection getConnection() throws RepositorySourceException { if (repository == null) { repository = new InMemoryRepository(this); ExecutionContext context = repositoryContext != null ? repositoryContext.getExecutionContext() : defaultContext; InMemoryTransaction txn = repository.startTransaction(context, false); try { for (String initialName : getPredefinedWorkspaceNames()) { repository.createWorkspace(txn, initialName, CreateConflictBehavior.DO_NOT_CREATE, null); } } finally { txn.commit(); } } return new Connection<InMemoryNode, InMemoryWorkspace>(this, repository); } InMemoryRepositorySource(ExecutionContext defaultContext); void initialize( RepositoryContext context ); RepositoryContext getRepositoryContext(); int getRetryLimit(); void setRetryLimit( int limit ); CachePolicy getDefaultCachePolicy(); void setDefaultCachePolicy( CachePolicy defaultCachePolicy ); String getDefaultWorkspaceName(); void setDefaultWorkspaceName( String defaultWorkspaceName ); String getRootNodeUuid(); UUID getRootNodeUuidObject(); void setRootNodeUuid( UUID rootNodeUuid ); void setRootNodeUuid( String rootNodeUuid ); void setJndiName( String name ); synchronized void setJndiName( String name,
                                          Context context ); synchronized String getJndiName(); String getName(); void setName( String name ); synchronized RepositoryConnection getConnection(); synchronized void close(); synchronized Reference getReference(); Object getObjectInstance( Object obj,
                                     javax.naming.Name name,
                                     Context nameCtx,
                                     Hashtable<?, ?> environment ); synchronized String[] getPredefinedWorkspaceNames(); synchronized void setPredefinedWorkspaceNames( String[] predefinedWorkspaceNames ); RepositorySourceCapabilities getCapabilities(); @Description( i18n = GraphI18n.class, value = "updatesAllowedPropertyDescription" ) @Label( i18n = GraphI18n.class, value = "updatesAllowedPropertyLabel" ) @Category( i18n = GraphI18n.class, value = "updatesAllowedPropertyCategory" ) @ReadOnly boolean areUpdatesAllowed(); void setUpdatesAllowed( boolean updatesAllowed ); @Override String toString(); static final int DEFAULT_RETRY_LIMIT; static final String DEFAULT_WORKSPACE_NAME; }### Answer:
@Test public void shouldMakeAvailablePredefinedWorkspaces() { RepositoryConnection connection = source.getConnection(); GetWorkspacesRequest request = new GetWorkspacesRequest(); connection.execute(context, request); Set<String> workspaces = request.getAvailableWorkspaceNames(); Set<String> graphWorkspaces = new HashSet<String>(Arrays.asList(predefinedWorkspaces)); assertThat(workspaces, is(graphWorkspaces)); for (String workspaceName : predefinedWorkspaces) { ReadNodeRequest readRoot = new ReadNodeRequest(locationFor("/"), workspaceName); connection.execute(context, readRoot); assertThat(readRoot.getActualLocationOfNode().getPath(), is(pathFor("/"))); } }