Skip to content

Move check outside CallableOperation. #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,6 @@ Tenant createTenant(Tenant.CreateRequest request) throws FirebaseAuthException {

Tenant updateTenant(Tenant.UpdateRequest request) throws FirebaseAuthException {
Map<String, Object> properties = request.getProperties();
// TODO(micahstairs): Move this check so that argument validation happens outside the
// CallableOperation.
checkArgument(!properties.isEmpty(), "tenant update must have at least one property set");
GenericUrl url = new GenericUrl(tenantMgtBaseUrl + getTenantUrlSuffix(request.getTenantId()));
url.put("updateMask", Joiner.on(",").join(generateMask(properties)));
return sendRequest("PATCH", url, properties, Tenant.class);
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/google/firebase/auth/TenantManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Tenant getTenant(@NonNull String tenantId) throws FirebaseAuthException {
}

public synchronized TenantAwareFirebaseAuth getAuthForTenant(@NonNull String tenantId) {
checkArgument(!Strings.isNullOrEmpty(tenantId), "tenantId must not be null or empty");
checkArgument(!Strings.isNullOrEmpty(tenantId), "Tenant ID must not be null or empty.");
if (!tenantAwareAuths.containsKey(tenantId)) {
tenantAwareAuths.put(tenantId, new TenantAwareFirebaseAuth(firebaseApp, tenantId));
}
Expand All @@ -90,7 +90,7 @@ public ApiFuture<Tenant> getTenantAsync(@NonNull String tenantId) {

private CallableOperation<Tenant, FirebaseAuthException> getTenantOp(final String tenantId) {
checkNotDestroyed();
checkArgument(!Strings.isNullOrEmpty(tenantId), "tenantId must not be null or empty");
checkArgument(!Strings.isNullOrEmpty(tenantId), "Tenant ID must not be null or empty.");
return new CallableOperation<Tenant, FirebaseAuthException>() {
@Override
protected Tenant execute() throws FirebaseAuthException {
Expand Down Expand Up @@ -196,7 +196,7 @@ public ApiFuture<Tenant> createTenantAsync(@NonNull CreateRequest request) {
private CallableOperation<Tenant, FirebaseAuthException> createTenantOp(
final CreateRequest request) {
checkNotDestroyed();
checkNotNull(request, "create request must not be null");
checkNotNull(request, "Create request must not be null.");
return new CallableOperation<Tenant, FirebaseAuthException>() {
@Override
protected Tenant execute() throws FirebaseAuthException {
Expand Down Expand Up @@ -234,7 +234,9 @@ public ApiFuture<Tenant> updateTenantAsync(@NonNull UpdateRequest request) {
private CallableOperation<Tenant, FirebaseAuthException> updateTenantOp(
final UpdateRequest request) {
checkNotDestroyed();
checkNotNull(request, "update request must not be null");
checkNotNull(request, "Update request must not be null.");
checkArgument(!request.getProperties().isEmpty(),
"Tenant update must have at least one property set.");
return new CallableOperation<Tenant, FirebaseAuthException>() {
@Override
protected Tenant execute() throws FirebaseAuthException {
Expand Down Expand Up @@ -269,7 +271,7 @@ public ApiFuture<Void> deleteTenantAsync(String tenantId) {

private CallableOperation<Void, FirebaseAuthException> deleteTenantOp(final String tenantId) {
checkNotDestroyed();
checkArgument(!Strings.isNullOrEmpty(tenantId), "tenantId must not be null or empty");
checkArgument(!Strings.isNullOrEmpty(tenantId), "Tenant ID must not be null or empty.");
return new CallableOperation<Void, FirebaseAuthException>() {
@Override
protected Void execute() throws FirebaseAuthException {
Expand Down