Skip to content

Commit

Permalink
Add optionsBuilder to LocalDatastoreHelper for common options
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Apr 18, 2016
1 parent 91bd460 commit 2a4b8ec
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,31 +556,28 @@ private static int findAvailablePort() {
}
}

private DatastoreOptions.Builder optionsBuilder() {
return DatastoreOptions.builder()
.projectId(projectId)
.host("localhost:" + Integer.toString(port))
.authCredentials(AuthCredentials.noAuth())
.retryParams(RetryParams.noRetries());
}

/**
* Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on
* localhost.
*/
public DatastoreOptions options() {
return DatastoreOptions.builder()
.projectId(projectId)
.host("localhost:" + Integer.toString(port))
.authCredentials(AuthCredentials.noAuth())
.retryParams(RetryParams.noRetries())
.build();
return optionsBuilder().build();
}

/**
* Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on
* localhost. The default namespace is set to {@code namespace}.
*/
public DatastoreOptions options(String namespace) {
return DatastoreOptions.builder()
.projectId(projectId)
.host("localhost:" + Integer.toString(port))
.authCredentials(AuthCredentials.noAuth())
.retryParams(RetryParams.noRetries())
.namespace(namespace)
.build();
return optionsBuilder().namespace(namespace).build();
}

/**
Expand Down

0 comments on commit 2a4b8ec

Please sign in to comment.