Skip to content

Commit

Permalink
fix: toBuilder test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TimurSadykov committed Jan 5, 2024
1 parent 2466fc2 commit 4b5f2ae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,12 @@ public Builder setUniverseDomain(String universeDomain) {
return this;
}

@CanIgnoreReturnValue
public Builder setQuotaProjectId(String quotaProjectId) {
super.quotaProjectId = quotaProjectId;
return this;
}

public HttpTransportFactory getHttpTransportFactory() {
return transportFactory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ protected Builder() {}
protected Builder(GoogleCredentials credentials) {
super(credentials);
this.quotaProjectId = credentials.quotaProjectId;
this.universeDomain = credentials.universeDomain;
if (credentials.isExplicitUniverseDomain) {
this.universeDomain = credentials.universeDomain;
}
}

protected Builder(GoogleCredentials.Builder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Queue;
Expand Down Expand Up @@ -361,6 +362,19 @@ public void hashCode_equals() throws IOException {
assertEquals(credentials.hashCode(), otherCredentials.hashCode());
}

@Test
public void toBuilder() {
ComputeEngineCredentials credentials =
ComputeEngineCredentials.newBuilder()
.setHttpTransportFactory(new MockMetadataServerTransportFactory())
.setQuotaProjectId("quota-project")
.build();

ComputeEngineCredentials secondCredentials = credentials.toBuilder().build();

assertEquals(credentials, secondCredentials);
}

@Test
public void serialize() throws IOException, ClassNotFoundException {
MockMetadataServerTransportFactory serverTransportFactory =
Expand Down

0 comments on commit 4b5f2ae

Please sign in to comment.