### Question:
GsonRequest extends JsonRfcCompliantListenableRequest<T> { @SuppressWarnings("unchecked") @Override protected Response<T> parseNetworkResponse(final NetworkResponse response) { try { final String json = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success((T) gson.fromJson(json, clazz), HttpHeaderParser.parseCacheHeaders(response)); } catch (final UnsupportedEncodingException e) { return Response.error(new ParseError(e)); } catch (final JsonSyntaxException e) { return Response.error(new ParseError(e)); } } GsonRequest(final int method, @NonNull final String url, @NonNull final Gson gson,
					@NonNull final Type clazz, @Nullable final Listener<T> listener,
					@Nullable final ErrorListener errListener,
					@Nullable final CancelListener cancelListener,
					@Nullable final String jsonBody);  GsonRequest(final int method, @NonNull final String url, @NonNull final Gson gson,
					@NonNull final Type clazz, @Nullable final Listener<T> listener,
					@Nullable final ErrorListener errListener,
					@Nullable final String jsonBody); @Override String toString();  }### Answer:
@Test public void testParseNetworkResponseWithBadJson() { final String json = "{data: null"; final Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_TYPE, "application/javascript; charset=" + CHARSET); try { final NetworkResponse networkResponse = new NetworkResponse( json.getBytes(CHARSET), headers); final Response<SampleData> response = request.parseNetworkResponse(networkResponse); assertFalse(response.isSuccess()); } catch (final UnsupportedEncodingException e) { fail(e.getMessage()); } }
@Test public void testParseNetworkResponse() { final SampleData data = newValidResponse(); final String json = new Gson().toJson(data); final Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_TYPE, "application/javascript; charset=" + CHARSET); try { final NetworkResponse networkResponse = new NetworkResponse( json.getBytes(CHARSET), headers); final Response<SampleData> response = request.parseNetworkResponse(networkResponse); assertEquals(data, response.result); } catch (final UnsupportedEncodingException e) { fail(e.getMessage()); } }
@Test public void testParseNetworkResponseWithBadEncoding() { final SampleData data = newValidResponse(); final String json = new Gson().toJson(data); final Map<String, String> headers = new HashMap<>(); headers.put(CONTENT_TYPE, "application/javascript; charset=nonexistingcharset"); try { final NetworkResponse networkResponse = new NetworkResponse( json.getBytes(CHARSET), headers); final Response<SampleData> response = request.parseNetworkResponse(networkResponse); assertFalse(response.isSuccess()); } catch (final UnsupportedEncodingException e) { fail(e.getMessage()); } }