@Test public void shouldReturnRootPathsThatAreAlwaysEquivalent() { path = paths.createRootPath(); for (int i = 0; i != 10; ++i) { assertThat(paths.createRootPath(), is(path)); } }
/** * Returns the path to the given node * * @param node the node for which the path should be returned; may not be null * @return the path to that node */ protected Path pathTo( NodeType node ) { if (node.getParent() == null) { return pathFactory.createRootPath(); } return pathFactory.create(node.getParent(), node.getName()); }
@Test public void shouldCreateRootPathWithNoSegments() { assertThat(paths.createRootPath().getSegmentsList().isEmpty(), is(true)); assertThat(paths.createRootPath().getSegmentsList().size(), is(0)); assertThat(paths.createRootPath().getSegmentsArray().length, is(0)); assertThat(paths.createRootPath().size(), is(0)); }
protected BaseTransaction( ExecutionContext context, Repository<NodeType, WorkspaceType> repository, UUID rootNodeUuid ) { this.rootNodeUuid = rootNodeUuid; this.context = context; this.propertyFactory = context.getPropertyFactory(); this.valueFactories = context.getValueFactories(); this.pathFactory = valueFactories.getPathFactory(); this.nameFactory = valueFactories.getNameFactory(); this.repository = repository; this.rootLocation = Location.create(pathFactory.createRootPath(), rootNodeUuid); }
@Test public void shouldCreateRootPathWithLengthOfZero() { assertThat(paths.createRootPath().size(), is(0)); }
@Test public void shouldCreateRootPath() { assertThat(paths.createRootPath(), is(notNullValue())); }
@Test public void shouldParsePathRuleFromDefinitionWithRootRepositoryPathAndRootSourcePath() { Projection.Rule rule = Projection.parsePathRule("/ => /", context); assertThat(rule, is(instanceOf(Projection.PathRule.class))); Projection.PathRule pathRule = (Projection.PathRule)rule; assertThat(pathRule.getPathInRepository(), is(pathFactory.createRootPath())); assertThat(pathRule.getPathInSource(), is(pathFactory.createRootPath())); }
/** * @param sourceName * @param context * @param processed */ public MockRepositoryRequestProcessor( String sourceName, ExecutionContext context, Queue<Request> processed ) { super(sourceName, context, null); assert processed != null; this.processed = processed; this.defaultWorkspaceRoot = Location.create(context.getValueFactories().getPathFactory().createRootPath()); }
@Test public void shouldCreateRootPathThatHasNoParent() { assertThat(paths.createRootPath().getParent(), is(nullValue())); }
/** * @param sourceName * @param context * @param processed */ public MockSearchEngineProcessor( String sourceName, ExecutionContext context, Queue<Request> processed ) { super(sourceName, context, null, null); assert processed != null; this.processed = processed; this.defaultWorkspaceRoot = Location.create(context.getValueFactories().getPathFactory().createRootPath()); }
/** * Create a graph sequencer output instance using {@link Graph.Batch} object. * * @param batch the {@link Graph.Batch} object; may not be null */ public GraphSequencerOutput( Graph.Batch batch ) { super(); this.batch = batch; ExecutionContext context = batch.getGraph().getContext(); this.pathFactory = context.getValueFactories().getPathFactory(); this.startingPath = this.pathFactory.createRootPath(); }
@Test public void shouldParsePathRuleFromDefinitionWithRootRepositoryPathAndNonRootSourcePath() { Projection.Rule rule = Projection.parsePathRule("/ => /b", context); assertThat(rule, is(instanceOf(Projection.PathRule.class))); Projection.PathRule pathRule = (Projection.PathRule)rule; assertThat(pathRule.getPathInRepository(), is(pathFactory.createRootPath())); assertThat(pathRule.getPathInSource(), is(pathFactory.create("/b"))); }
@Test public void shouldParsePathRuleFromDefinitionWithNonRootRepositoryPathAndRootSourcePath() { Projection.Rule rule = Projection.parsePathRule("/a => /", context); assertThat(rule, is(instanceOf(Projection.PathRule.class))); Projection.PathRule pathRule = (Projection.PathRule)rule; assertThat(pathRule.getPathInRepository(), is(pathFactory.create("/a"))); assertThat(pathRule.getPathInSource(), is(pathFactory.createRootPath())); }
protected Path getPath() { if (parent == null) return pathFactory().createRootPath(); return pathFactory().create(parent.getPath(), name); }
@Override public void process( VerifyWorkspaceRequest request ) { PathWorkspace original = getWorkspace(request, request.workspaceName()); if (original != null) { Path path = getExecutionContext().getValueFactories().getPathFactory().createRootPath(); request.setActualRootLocation(Location.create(path, repository.getRootNodeUuid())); request.setActualWorkspaceName(original.getName()); } }
@SuppressWarnings( "synthetic-access" ) public void execute( ExecutionContext context, Request request ) throws RepositorySourceException { lastExecutedRequest = request; if (request instanceof VerifyWorkspaceRequest) { VerifyWorkspaceRequest workspaceRequest = (VerifyWorkspaceRequest)request; workspaceRequest.setActualRootLocation(Location.create(context.getValueFactories() .getPathFactory() .createRootPath())); workspaceRequest.setActualWorkspaceName("default"); } }
@Override public void process( DestroyWorkspaceRequest request ) { if (!updatesAllowed(request)) return; PathWorkspace workspace = repository.getWorkspace(request.workspaceName()); if (workspace != null) { request.setActualRootLocation(Location.create(pathFactory.createRootPath(), repository.getRootNodeUuid())); recordChange(request); } else { String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName()); request.setError(new InvalidWorkspaceException(msg)); } }
@Override public void process( CloneWorkspaceRequest request ) { // Just update the actual location String workspaceName = request.desiredNameOfTargetWorkspace(); assert workspaceName != null; request.setActualWorkspaceName(workspaceName); request.setActualRootLocation(Location.create(context.getValueFactories().getPathFactory().createRootPath())); }
@Override public void process( VerifyWorkspaceRequest request ) { // Just update the actual location String workspaceName = request.workspaceName(); if (workspaceName == null) workspaceName = "default"; request.setActualWorkspaceName(workspaceName); request.setActualRootLocation(Location.create(context.getValueFactories().getPathFactory().createRootPath())); }
@Override public void process( CreateWorkspaceRequest request ) { // Just update the actual location String workspaceName = request.desiredNameOfNewWorkspace(); if (workspaceName == null) workspaceName = "default"; request.setActualWorkspaceName(workspaceName); request.setActualRootLocation(Location.create(context.getValueFactories().getPathFactory().createRootPath())); }