### Question:
ExchangeRateUtil { public JSONObject parseCoinbaseResponse(JSONObject response) { JSONObject responseRates = null; try { responseRates = response.getJSONObject("data").getJSONObject("rates"); } catch (JSONException e) { e.printStackTrace(); } JSONObject formattedRates = new JSONObject(); if (responseRates != null) { Iterator<String> iter = responseRates.keys(); while (iter.hasNext()) { String rateCode = iter.next(); try { JSONObject currentCurrency = new JSONObject(); currentCurrency.put(RATE, responseRates.getDouble(rateCode) / 1e8); currentCurrency.put(TIMESTAMP, System.currentTimeMillis() / 1000); formattedRates.put(rateCode, currentCurrency); } catch (JSONException e) { ZapLog.e(LOG_TAG, "Unable to read exchange rate from coinbase response."); } } } else { return null; } return formattedRates; } private  ExchangeRateUtil(); static ExchangeRateUtil getInstance(); void getExchangeRates(); JSONObject parseBlockchainInfoResponse(JSONObject response); JSONObject parseCoinbaseResponse(JSONObject response); void registerExchangeRateListener(ExchangeRateUtil.ExchangeRateListener listener); void unregisterExchangeRateListener(ExchangeRateUtil.ExchangeRateListener listener);  }### Answer:
@Test public void parseCoinbaseResponse() throws JSONException { JSONObject in = new JSONObject(readStringFromFile("exchange_rate_coinbase_response.json")); JSONObject out = ExchangeRateUtil.getInstance().parseCoinbaseResponse(in); assertEquals(2, out.length()); assertEquals(1E-8, out.getJSONObject("USD").getDouble("rate")); }