@Override protected Request createRequest() { return new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.DO_NOT_CREATE); }
/** * Add a request to create a new workspace, and specify the behavior should a workspace already exists with a name that * matches the desired name for the new workspace. * * @param desiredNameOfNewWorkspace the desired name of the new workspace * @param createConflictBehavior the behavior if a workspace already exists with the same name, or null if the default * behavior should be used * @return this builder for method chaining; never null */ public BatchRequestBuilder createWorkspace( String desiredNameOfNewWorkspace, CreateConflictBehavior createConflictBehavior ) { return add(new CreateWorkspaceRequest(desiredNameOfNewWorkspace, createConflictBehavior)); }
/** * Add a request to create a new workspace, and specify the behavior should a workspace already exists with a name that * matches the desired name for the new workspace. * * @param desiredNameOfNewWorkspace the desired name of the new workspace * @param createConflictBehavior the behavior if a workspace already exists with the same name, or null if the default * behavior should be used * @return the request; never null */ public CreateWorkspaceRequest createWorkspace( String desiredNameOfNewWorkspace, CreateConflictBehavior createConflictBehavior ) { return process(new CreateWorkspaceRequest(desiredNameOfNewWorkspace, createConflictBehavior)); }
/** * {@inheritDoc} * <p> * This method does not clone the results. * </p> * * @see org.modeshape.graph.request.ChangeRequest#clone() */ @Override public CreateWorkspaceRequest clone() { CreateWorkspaceRequest request = new CreateWorkspaceRequest( actualWorkspaceName != null ? actualWorkspaceName : desiredNameOfNewWorkspace, createConflictBehavior); request.setActualWorkspaceName(actualWorkspaceName); request.setActualRootLocation(actualLocationOfRoot); return request; }
@Test public void shouldConsiderEqualTwoRequestsWithSameLocations() { request = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); CreateWorkspaceRequest request2 = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); assertThat(request, is(request2)); }
@Test public void shouldConsiderEqualTwoRequestsWithDifferentCreateConflictBehaviors() { request = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.DO_NOT_CREATE); CreateWorkspaceRequest request2 = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); assertThat(request, is(request2)); }
@Test( expected = IllegalArgumentException.class ) public void shouldNotAllowCreatingRequestWithNullWorkspaceName() { new CreateWorkspaceRequest(null, CreateConflictBehavior.DO_NOT_CREATE); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentDesiredWorkspaceNames() { request = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); CreateWorkspaceRequest request2 = new CreateWorkspaceRequest(workspace2, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); assertThat(request.equals(request2), is(false)); } }
@Test public void shouldAllowCreatingRequestWithNullCreateConflictBehavior() { request = new CreateWorkspaceRequest(workspace1, null); assertThat(request.conflictBehavior(), is(CreateWorkspaceRequest.DEFAULT_CREATE_CONFLICT_BEHAVIOR)); }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new CreateWorkspaceRequest(workspace1, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); assertThat(request.desiredNameOfNewWorkspace(), is(workspace1)); assertThat(request.conflictBehavior(), is(CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME)); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }