@Test public void parseNetworkResponse_shouldReturnPositioning() { mockNetworkResponse = new NetworkResponse(200, "{fixed: []}".getBytes(), new TreeMap<String, String>(), false); assertThat(subject.parseNetworkResponse(mockNetworkResponse).result) .isExactlyInstanceOf(MoPubNativeAdPositioning.MoPubClientPositioning.class); }
@Override protected Response<MoPubClientPositioning> parseNetworkResponse(final NetworkResponse response) { if (response.statusCode != HttpStatus.SC_OK) { return Response.error(new VolleyError(response)); } if (response.data.length == 0) { return Response.error(new VolleyError("Empty positioning response", new JSONException("Empty response"))); } try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(parseJson(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new VolleyError("Couldn't parse JSON from Charset", e)); } catch (JSONException e) { return Response.error(new VolleyError("JSON Parsing Error", e)); } catch (MoPubNetworkError e) { return Response.error(e); } }
PositioningRequest extends JsonRequest<MoPubClientPositioning> { @Override protected Response<MoPubClientPositioning> parseNetworkResponse(final NetworkResponse response) { if (response.statusCode != HttpStatus.SC_OK) { return Response.error(new VolleyError(response)); } if (response.data.length == 0) { return Response.error(new VolleyError("Empty positioning response", new JSONException("Empty response"))); } try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(parseJson(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new VolleyError("Couldn't parse JSON from Charset", e)); } catch (JSONException e) { return Response.error(new VolleyError("JSON Parsing Error", e)); } catch (MoPubNetworkError e) { return Response.error(e); } } }
PositioningRequest extends JsonRequest<MoPubClientPositioning> { @Override protected Response<MoPubClientPositioning> parseNetworkResponse(final NetworkResponse response) { if (response.statusCode != HttpStatus.SC_OK) { return Response.error(new VolleyError(response)); } if (response.data.length == 0) { return Response.error(new VolleyError("Empty positioning response", new JSONException("Empty response"))); } try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(parseJson(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new VolleyError("Couldn't parse JSON from Charset", e)); } catch (JSONException e) { return Response.error(new VolleyError("JSON Parsing Error", e)); } catch (MoPubNetworkError e) { return Response.error(e); } } PositioningRequest(final String url,
            final Response.Listener<MoPubClientPositioning> listener,
            final Response.ErrorListener errorListener); }
PositioningRequest extends JsonRequest<MoPubClientPositioning> { @Override protected Response<MoPubClientPositioning> parseNetworkResponse(final NetworkResponse response) { if (response.statusCode != HttpStatus.SC_OK) { return Response.error(new VolleyError(response)); } if (response.data.length == 0) { return Response.error(new VolleyError("Empty positioning response", new JSONException("Empty response"))); } try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(parseJson(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new VolleyError("Couldn't parse JSON from Charset", e)); } catch (JSONException e) { return Response.error(new VolleyError("JSON Parsing Error", e)); } catch (MoPubNetworkError e) { return Response.error(e); } } PositioningRequest(final String url,
            final Response.Listener<MoPubClientPositioning> listener,
            final Response.ErrorListener errorListener);  }
PositioningRequest extends JsonRequest<MoPubClientPositioning> { @Override protected Response<MoPubClientPositioning> parseNetworkResponse(final NetworkResponse response) { if (response.statusCode != HttpStatus.SC_OK) { return Response.error(new VolleyError(response)); } if (response.data.length == 0) { return Response.error(new VolleyError("Empty positioning response", new JSONException("Empty response"))); } try { String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers)); return Response.success(parseJson(jsonString), HttpHeaderParser.parseCacheHeaders(response)); } catch (UnsupportedEncodingException e) { return Response.error(new VolleyError("Couldn't parse JSON from Charset", e)); } catch (JSONException e) { return Response.error(new VolleyError("JSON Parsing Error", e)); } catch (MoPubNetworkError e) { return Response.error(e); } } PositioningRequest(final String url,
            final Response.Listener<MoPubClientPositioning> listener,
            final Response.ErrorListener errorListener);   }