Skip to content

Added toString() in TopicManagementResponse for logging #469

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 5 commits into from
Aug 10, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ target/
release.properties
integration_cert.json
integration_apikey.txt
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static com.google.common.base.Preconditions.checkState;

import com.google.api.client.json.GenericJson;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.firebase.internal.NonNull;
Expand Down Expand Up @@ -122,5 +123,13 @@ public int getIndex() {
public String getReason() {
return reason;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("index", index)
.add("reason", reason)
.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,17 @@ public void testTopicManagementResponseWithEmptyList() {
new TopicManagementResponse(ImmutableList.<GenericJson>of());
}

@Test
public void testTopicManagementResponseErrorToString() {
GenericJson json = new GenericJson().set("error", "test error");
ImmutableList<GenericJson> jsonList = ImmutableList.of(json);

TopicManagementResponse topicManagementResponse = new TopicManagementResponse(jsonList);

String expected = "[Error{index=0, reason=unknown-error}]";
assertEquals(expected, topicManagementResponse.getErrors().toString());
}

private static InstanceIdClientImpl initInstanceIdClient(
final MockLowLevelHttpResponse mockResponse,
final HttpResponseInterceptor interceptor) {
Expand Down