if (validWorkspaceNames.length < 1) return;
try {
// Is there an existing workspace?
Set<String> existingWorkspaceNames = graph.getWorkspaces();
Workspace workspace1 = null;
String newWorkspaceName = null;
if (existingWorkspaceNames.isEmpty()) {
workspace1 = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]);
newWorkspaceName = validWorkspaceNames[1];
assertThat(workspace1, is(notNullValue()));
String workspaceName1 = workspace1.getName();
assertThat(workspaceName1, is(notNullValue()));
assertThat(workspaceName1.trim().length(), is(not(0)));
// Initialize workspace one with some content ...
initializeContents(graph);
} else {
workspace1 = graph.useWorkspace(existingWorkspaceNames.iterator().next());
newWorkspaceName = validWorkspaceNames[0];
}
assert workspace1 != null;
assert newWorkspaceName != null;
// Clone 'workspace1' into 'workspace2'
String workspaceName = workspace1.getName();
Workspace workspace2 = graph.createWorkspace().clonedFrom(workspaceName).named(newWorkspaceName);
// Verify that the content of 'workspace1' matches that of 'workspace2'
Subgraph subgraph1 = graph.getSubgraphOfDepth(100000).at(workspace1.getRoot());
Subgraph subgraph2 = graph.getSubgraphOfDepth(100000).at(workspace2.getRoot());
assertEquivalentSubgraphs(subgraph1, subgraph2, true, true);
} catch (InvalidRequestException error) {
// Updates may not be supported, but if they are then this is a failure ...
if (source.getCapabilities().supportsUpdates()) throw error;
}