@Test(expected = ShapeShiftException.class) public void testEmailFail() throws ShapeShiftException, IOException, InterruptedException, JSONException, AddressMalformedException { server.enqueue(new MockResponse().setBody(TX_STATUS_NO_DEPOSIT_JSON)); ShapeShiftTxStatus txStatusReply = shapeShift .getTxStatus(BTC.newAddress("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN")); // Bad status shapeShift.requestEmailReceipt("mail@example.com", txStatusReply); }
@Test public void testEmail() throws ShapeShiftException, IOException, InterruptedException, JSONException, AddressMalformedException { // Schedule some responses. server.enqueue(new MockResponse().setBody(TX_STATUS_COMPLETE_JSON)); server.enqueue(new MockResponse().setBody(EMAIL_JSON)); ShapeShiftTxStatus txStatusReply = shapeShift.getTxStatus(BTC.newAddress("1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN")); ShapeShiftEmail emailReply = shapeShift.requestEmailReceipt("mail@example.com", txStatusReply); assertFalse(emailReply.isError); assertEquals(ShapeShiftEmail.Status.SUCCESS, emailReply.status); assertEquals("Email receipt sent", emailReply.message); // Optional: confirm that your app made the HTTP requests you were expecting. RecordedRequest request = server.takeRequest(); assertEquals("/txStat/1NDQPAGamGePkSZXW2CYBzXJEefB7N4bTN", request.getPath()); request = server.takeRequest(); assertEquals("/mail", request.getPath()); JSONObject reqJson = new JSONObject(request.getBody().readUtf8()); assertEquals("mail@example.com", reqJson.getString("email")); assertEquals("66fa0b4c11227f9f05efa13d23e58c65b50acbd6395a126b5cd751064e6e79df", reqJson.getString("txid")); }