@Override protected Request createRequest() { return new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); }
/** * {@inheritDoc} * <p> * This method does not clone the results. * </p> * * @see org.modeshape.graph.request.ChangeRequest#clone() */ @Override public CopyBranchRequest clone() { CopyBranchRequest result = new CopyBranchRequest(actualFromLocation != null ? actualFromLocation : from, fromWorkspace, actualIntoLocation != null ? actualIntoLocation : into, intoWorkspace, desiredNameForCopy, nodeConflictBehavior); result.setActualLocations(actualFromLocation, actualIntoLocation); return result; }
/** * Add a request to copy a branch to another. * * @param from the location of the top node in the existing branch that is to be copied * @param fromWorkspace the name of the workspace where the <code>from</code> node exists * @param into the location of the existing node into which the copy should be placed * @param intoWorkspace the name of the workspace where the <code>into</code> node is to be copied * @param nameForCopy the desired name for the node that results from the copy, or null if the name of the original should be * used * @return this builder for method chaining; never null * @throws IllegalArgumentException if either of the locations or workspace names are null */ public BatchRequestBuilder copyBranch( Location from, String fromWorkspace, Location into, String intoWorkspace, Name nameForCopy ) { return add(new CopyBranchRequest(from, fromWorkspace, into, intoWorkspace, nameForCopy, CopyBranchRequest.DEFAULT_NODE_CONFLICT_BEHAVIOR)); }
/** * Add a request to copy a branch to another. * * @param from the location of the top node in the existing branch that is to be copied * @param fromWorkspace the name of the workspace where the <code>from</code> node exists * @param into the location of the existing node into which the copy should be placed * @param intoWorkspace the name of the workspace where the <code>into</code> node is to be copied * @param nameForCopy the desired name for the node that results from the copy, or null if the name of the original should be * used * @param conflictBehavior the expected behavior if an equivalently-named child already exists at the <code>into</code> * location, or null if the default node conflict behavior should be used * @return this builder for method chaining; never null * @throws IllegalArgumentException if either of the locations or workspace names are null */ public BatchRequestBuilder copyBranch( Location from, String fromWorkspace, Location into, String intoWorkspace, Name nameForCopy, NodeConflictBehavior conflictBehavior ) { if (conflictBehavior == null) conflictBehavior = CopyBranchRequest.DEFAULT_NODE_CONFLICT_BEHAVIOR; return add(new CopyBranchRequest(from, fromWorkspace, into, intoWorkspace, nameForCopy, conflictBehavior)); }
/** * Add a request to copy a branch to another. * * @param from the location of the top node in the existing branch that is to be copied * @param fromWorkspace the name of the workspace where the <code>from</code> node exists * @param into the location of the existing node into which the copy should be placed * @param intoWorkspace the name of the workspace where the <code>into</code> node is to be copied * @param nameForCopy the desired name for the node that results from the copy, or null if the name of the original should be * used * @param conflictBehavior the expected behavior if an equivalently-named child already exists at the <code>into</code> * location, or null if the default conflict behavior should be used * @return the request; never null * @throws IllegalArgumentException if either of the locations or workspace names are null */ public CopyBranchRequest copyBranch( Location from, String fromWorkspace, Location into, String intoWorkspace, Name nameForCopy, NodeConflictBehavior conflictBehavior ) { if (conflictBehavior == null) conflictBehavior = CopyBranchRequest.DEFAULT_NODE_CONFLICT_BEHAVIOR; return process(new CopyBranchRequest(from, fromWorkspace, into, intoWorkspace, nameForCopy, conflictBehavior)); }
@Test public void shouldConsiderEqualTwoRequestsWithSameLocations() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); CopyBranchRequest request2 = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request, is(request2)); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullToLocation() { new CopyBranchRequest(validPathLocation1, workspace1, null, workspace2); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullFromLocation() { new CopyBranchRequest(null, workspace1, validPathLocation2, workspace2); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullFromWorkspace() { new CopyBranchRequest(validPathLocation1, null, validPathLocation2, workspace2); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullToWorkspace() { new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, null); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentFromWorkspaceName() { request = new CopyBranchRequest(validPathLocation1, workspace1 + "a", validPathLocation2, workspace2); CopyBranchRequest request2 = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentLocations() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); CopyBranchRequest request2 = new CopyBranchRequest(validPathLocation2, workspace1, validPathLocation1, workspace2); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentToWorkspaceName() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2 + "a"); CopyBranchRequest request2 = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request.equals(request2), is(false)); } }
@Test public void shouldConsiderRequestsToBeInSameWorkspaceIfFromAndToWorkspaceNamesMatch() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, new String(workspace1)); assertThat(request.isSameWorkspace(), is(true)); }
@Test public void shouldConsiderRequestsToNotBeInSameWorkspaceIfFromAndToWorkspaceNamesDoNotMatch() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request.isSameWorkspace(), is(false)); }
@Test public void shouldCreateValidRequestWithValidFromLocationAndValidToLocation() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request.from(), is(sameInstance(validPathLocation1))); assertThat(request.into(), is(sameInstance(validPathLocation2))); assertThat(request.fromWorkspace(), is(sameInstance(workspace1))); assertThat(request.intoWorkspace(), is(sameInstance(workspace2))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
CopyBranchRequest pushDown = new CopyBranchRequest(fromProxy.location(), fromProxy.workspaceName(), intoProxy.location(), intoProxy.workspaceName(), request.desiredName(), request.nodeConflictBehavior());