/** * Obtain a copy of this request (without any results) with the new supplied maximum depth. * * @param maxDepth the maximum depth for the new request * @return the copy of thist request, but with the desired maximum depth * @throws IllegalArgumentException if the maximum depth is not positive */ public ReadBranchRequest withMaximumDepth( int maxDepth ) { return new ReadBranchRequest(at, workspaceName, maxDepth); } }
/** * Add a request to read the branch at the supplied location, to a maximum depth of 2. * * @param at the location of the branch * @param workspaceName the name of the workspace containing the branch * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null or if the maximum depth is not positive */ public BatchRequestBuilder readBranch( Location at, String workspaceName ) { return add(new ReadBranchRequest(at, workspaceName)); }
/** * Add a request to read the branch at the supplied location, to a maximum depth of 2. * * @param at the location of the branch * @param workspaceName the name of the workspace containing the branch * @return the request; never null * @throws IllegalArgumentException if the location or workspace name is null or if the maximum depth is not positive */ public ReadBranchRequest readBranch( Location at, String workspaceName ) { return process(new ReadBranchRequest(at, workspaceName)); }
@Override protected Request createRequest() { return new ReadBranchRequest(validPathLocation1, workspace1); }
/** * Add a request to read the branch (of given depth) at the supplied location. * * @param at the location of the branch * @param workspaceName the name of the workspace containing the branch * @param maxDepth the maximum depth to read * @return the request; never null * @throws IllegalArgumentException if the location or workspace name is null or if the maximum depth is not positive */ public ReadBranchRequest readBranch( Location at, String workspaceName, int maxDepth ) { return process(new ReadBranchRequest(at, workspaceName, maxDepth)); }
/** * Add a request to read the branch (of given depth) at the supplied location. * * @param at the location of the branch * @param workspaceName the name of the workspace containing the branch * @param maxDepth the maximum depth to read * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null or if the maximum depth is not positive */ public BatchRequestBuilder readBranch( Location at, String workspaceName, int maxDepth ) { return add(new ReadBranchRequest(at, workspaceName, maxDepth)); }
@Test public void shouldConsiderEqualTwoRequestsWithSameLocations() { request = new ReadBranchRequest(validPathLocation1, workspace1); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, new String(workspace1)); assertThat(request, is(request2)); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullFromLocation() { new ReadBranchRequest(null, workspace1); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullWorkspaceName() { new ReadBranchRequest(validPathLocation1, null); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentWorkspaceNames() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, workspace2, 20); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithSameLocationsButDifferentMaximumDepths() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, workspace1, 2); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentLocations() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation2, workspace1, 20); assertThat(request.equals(request2), is(false)); }
@Test public void shouldIterateOverNodesInBranchOfDepthOne() { request = new ReadBranchRequest(location("/a"), workspace1, 1); request.setActualLocationOfNode(request.at()); request.setChildren(location("/a"), location("/a/b"), location("/a/c")); Iterator<Location> actual = request.iterator(); assertThat(actual.hasNext(), is(true)); assertThat(actual.next(), is(location("/a"))); assertThat(actual.hasNext(), is(false)); }
@Test public void shouldCreateValidRequestWithValidLocationAndMaximumDepth() { request = new ReadBranchRequest(validPathLocation1, workspace1, 10); assertThat(request.at(), is(sameInstance(validPathLocation1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); assertThat(request.maximumDepth(), is(10)); }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new ReadBranchRequest(validPathLocation1, workspace1); assertThat(request.at(), is(sameInstance(validPathLocation1))); assertThat(request.inWorkspace(), is(sameInstance(workspace1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); assertThat(request.maximumDepth(), is(ReadBranchRequest.DEFAULT_MAXIMUM_DEPTH)); }
int depthPerRead = Math.min(maxDepthPerRead, depth); ReadBranchRequest readSubgraph = new ReadBranchRequest(startingLocation, workspaceName, depthPerRead); try { channel.addAndAwait(readSubgraph); readSubgraph = new ReadBranchRequest(location, workspaceName, depthPerRead); try { channel.addAndAwait(readSubgraph);
@Test public void shouldIncludeTimeLoadedInReadBranchRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadBranchRequest(location("/"), workspaceName, 2); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIterateOverNodesInBranchOfDepthTwo() { request = new ReadBranchRequest(location("/a"), workspace1, 2); request.setActualLocationOfNode(request.at()); request.setChildren(location("/a"), location("/a/b"), location("/a/c"), location("/a/d")); request.setChildren(location("/a/b"), location("/a/b/j"), location("/a/b/k")); request.setChildren(location("/a/c"), location("/a/c/j"), location("/a/c/k")); request.setChildren(location("/a/d")); Iterator<Location> actual = request.iterator(); assertThat(actual.hasNext(), is(true)); assertThat(actual.next(), is(location("/a"))); assertThat(actual.hasNext(), is(true)); assertThat(actual.next(), is(location("/a/b"))); assertThat(actual.hasNext(), is(true)); assertThat(actual.next(), is(location("/a/c"))); assertThat(actual.hasNext(), is(true)); assertThat(actual.next(), is(location("/a/d"))); assertThat(actual.hasNext(), is(false)); }
ProxyNode proxy = projectedNode.asProxy(); ReadBranchRequest pushDownRequest = new ReadBranchRequest(proxy.location(), proxy.workspaceName(), maxDepth); federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
@Test public void shouldIterateOverNodesInBranchOfDepthThree() { request = new ReadBranchRequest(location("/a"), workspace1, 3); request.setActualLocationOfNode(request.at()); request.setChildren(location("/a"), location("/a/b"), location("/a/c"), location("/a/d"));