@Test(expected = ShapeShiftException.class) public void testGetRateFail() throws ShapeShiftException, IOException { server.enqueue(new MockResponse().setBody(GET_RATE_BTC_LTC_JSON)); // Incorrect pair shapeShift.getRate(NBT, LTC); }
@Test public void testGetRate() throws ShapeShiftException, IOException, InterruptedException, JSONException { // Schedule some responses. server.enqueue(new MockResponse().setBody(GET_RATE_BTC_LTC_JSON)); ShapeShiftRate rateReply = shapeShift.getRate(BTC, LTC); assertFalse(rateReply.isError); assertEquals("btc_ltc", rateReply.pair); assertNotNull(rateReply.rate); assertEquals(LTC, rateReply.rate.convert(BTC.oneCoin()).type); assertEquals(BTC, rateReply.rate.convert(LTC.oneCoin()).type); // Optional: confirm that your app made the HTTP requests you were expecting. RecordedRequest request = server.takeRequest(); assertEquals("/rate/btc_ltc", request.getPath()); }