Skip to content

Commit 1ffdba6

Browse files
SUPERCILEXchingor13
authored andcommitted
fix: add details to GoogleJsonResponseExceptions created with GoogleJsonResponseExceptionFactoryTesting (#1395)
* Add details to GoogleJsonResponseExceptions created with GoogleJsonResponseExceptionFactoryTesting * Add import
1 parent 420d9da commit 1ffdba6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

google-api-client/src/main/java/com/google/api/client/googleapis/testing/json/GoogleJsonResponseExceptionFactoryTesting.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
1818
import com.google.api.client.http.HttpRequest;
1919
import com.google.api.client.http.HttpResponse;
20+
import com.google.api.client.json.Json;
2021
import com.google.api.client.json.JsonFactory;
2122
import com.google.api.client.testing.http.HttpTesting;
2223
import com.google.api.client.testing.http.MockHttpTransport;
@@ -59,7 +60,10 @@ public static GoogleJsonResponseException newMock(JsonFactory jsonFactory,
5960
MockLowLevelHttpResponse otherServiceUnavaiableLowLevelResponse =
6061
new MockLowLevelHttpResponse()
6162
.setStatusCode(httpCode)
62-
.setReasonPhrase(reasonPhrase);
63+
.setReasonPhrase(reasonPhrase)
64+
.setContentType(Json.MEDIA_TYPE)
65+
.setContent("{ \"error\": { \"errors\": [ { \"reason\": \"" + reasonPhrase + "\" } ], " +
66+
"\"code\": " + httpCode + " } }");
6367
MockHttpTransport otherTransport = new MockHttpTransport.Builder()
6468
.setLowLevelHttpResponse(otherServiceUnavaiableLowLevelResponse)
6569
.build();

0 commit comments

Comments
 (0)