File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
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)