/** * Get the name of the current workspace being used by this graph. If the graph has not yet been instructed to * {@link #useWorkspace(String) use} or {@link #createWorkspace() create} a workspace, this method will assume that the * source's default workspace is to be used and will obtain from the source the name of that default workspace. * * @return the name of the current workspace; never null * @see #getCurrentWorkspace() */ public String getCurrentWorkspaceName() { return getCurrentWorkspace().getName(); }
@Test public void shouldReturnListOfWorkspaces() { // The the actual names of the workspaces ... Set<String> workspaceNames = new HashSet<String>(); for (String workspaceName : graph.getWorkspaces()) { Workspace workspace = graph.useWorkspace(workspaceName); workspaceNames.add(workspace.getName()); } // The actual names should be the absolute paths to the directories representing the root ... for (String expectedName : predefinedWorkspaces) { assertThat(workspaceNames.remove(expectedName), is(true)); } assertThat(workspaceNames.isEmpty(), is(true)); // The actual names of the workspaces should also be canonical paths ... workspaceNames = new HashSet<String>(graph.getWorkspaces()); for (String expectedName : predefinedWorkspaces) { assertThat(workspaceNames.remove(expectedName), is(true)); } assertThat(workspaceNames.isEmpty(), is(true)); }
@Test public void shouldReturnListOfWorkspaces() { // The the actual names of the workspaces ... Set<String> workspaceNames = new HashSet<String>(); for (String workspaceName : graph.getWorkspaces()) { Workspace workspace = graph.useWorkspace(workspaceName); workspaceNames.add(workspace.getName()); } // The actual names should be the absolute paths to the directories representing the root ... for (String expectedName : predefinedWorkspaces) { assertThat(workspaceNames.remove(expectedName), is(true)); } assertThat(workspaceNames.isEmpty(), is(true)); // The actual names of the workspaces should also be canonical paths ... workspaceNames = new HashSet<String>(graph.getWorkspaces()); for (String expectedName : predefinedWorkspaces) { assertThat(workspaceNames.remove(expectedName), is(true)); } assertThat(workspaceNames.isEmpty(), is(true)); } }
@Test public void shouldAllowCreatingWorkspaceWithValidNameIfAllowedByCapabilities() { if (source.getCapabilities().supportsCreatingWorkspaces()) { String[] validNames = generateValidNamesForNewWorkspaces(); for (String validName : validNames) { Workspace workspace = graph.createWorkspace().named(validName); assertThat(workspace, is(notNullValue())); String workspaceName1 = workspace.getName(); assertThat(workspaceName1, is(notNullValue())); assertThat(workspaceName1.trim().length(), is(not(0))); } } }
this.context = store.getContext(); if (workspaceName != null) { this.workspaceName = this.store.useWorkspace(workspaceName).getName(); } else { this.workspaceName = this.store.getCurrentWorkspaceName();
existing = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]); assertThat(existing, is(notNullValue())); String workspaceName1 = existing.getName(); assertThat(workspaceName1, is(notNullValue())); assertThat(workspaceName1.trim().length(), is(not(0))); graph.createWorkspace().clonedFrom(existing.getName()).named(existing.getName()); fail("No error reported after attempting to create a cloned workspace that was same name as clone"); } catch (InvalidWorkspaceException error) {
newWorkspaceName = validWorkspaceNames[1]; assertThat(workspace1, is(notNullValue())); String workspaceName1 = workspace1.getName(); assertThat(workspaceName1, is(notNullValue())); assertThat(workspaceName1.trim().length(), is(not(0))); String workspaceName = workspace1.getName(); Workspace workspace2 = graph.createWorkspace().clonedFrom(workspaceName).named(newWorkspaceName);