use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryBillByIDAsyncSucc.
/**
* #3
* 模拟response为200
* @throws Exception
*/
@Test
public void testQueryBillByIDAsyncSucc() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"pay\":{\"spay_result\":false,\"create_time\":1447643289722,\"total_fee\":1,\"channel\":\"WX\",\"trade_no\":\"\",\"bill_no\":\"20151116110810464\",\"optional\":\"{\\\"testkey1\\\":\\\"测试value值1\\\"}\",\"revert_result\":false,\"title\":\"安卓微信支付测试\",\"sub_channel\":\"WX_APP\",\"message_detail\":\"\",\"refund_result\":false},\"result_code\":0}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryBillByIDAsync("billid", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryBillResult);
BCQueryBillResult billResult = (BCQueryBillResult) result;
Assert.assertEquals((Integer) 0, billResult.getResultCode());
BCBillOrder billOrder = billResult.getBill();
Assert.assertEquals("20151116110810464", billOrder.getBillNum());
Assert.assertEquals("安卓微信支付测试", billOrder.getTitle());
Assert.assertTrue(billOrder.getTradeNum() == null || billOrder.getTradeNum().length() == 0);
Assert.assertEquals((Integer) 1, billOrder.getTotalFee());
Assert.assertEquals("WX", billOrder.getChannel());
Assert.assertEquals("WX_APP", billOrder.getSubChannel());
Assert.assertFalse(billOrder.getPayResult());
Assert.assertFalse(billOrder.getRevertResult());
Assert.assertEquals((Long) 1447643289722L, billOrder.getCreatedTime());
Assert.assertEquals("{\"testkey1\":\"测试value值1\"}", billOrder.getOptional());
// 释放
latch.countDown();
}
});
// 等待
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundStatusAsyncRefundNumInvalid.
/**
* #2
* 输入退款单号为null的情况
* @throws Exception
*/
@Test
public void testQueryRefundStatusAsyncRefundNumInvalid() throws Exception {
query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, null, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRefundStatus);
BCRefundStatus status = (BCRefundStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, status.getResultCode());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryOfflineBillStatusAsyncBillNumInvalid.
/**
* #2
* billNum为null的情况
* @throws Exception
*/
@Test
public void testQueryOfflineBillStatusAsyncBillNumInvalid() throws Exception {
query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_SCAN, null, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCBillStatus);
BCBillStatus status = (BCBillStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, status.getResultCode());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundStatusAsyncTestMode.
/**
* #5
* test mode
* @throws Exception
*/
@Test
public void testQueryRefundStatusAsyncTestMode() throws Exception {
BeeCloud.setSandbox(true);
query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, "refundnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRefundStatus);
BCRefundStatus status = (BCRefundStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, status.getResultCode());
Assert.assertEquals("该功能暂不支持测试模式", status.getErrDetail());
BeeCloud.setSandbox(false);
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryBillsCountAsyncNetworkError.
/**
* #2
* 网络请求400等异常情况
* @throws Exception
*/
@Test
public void testQueryBillsCountAsyncNetworkError() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 400;
response.content = "wrong";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
BCQuery.QueryParams params = new BCQuery.QueryParams();
params.channel = BCReqParams.BCChannelTypes.ALL;
query.queryBillsCountAsync(params, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryCountResult);
BCQueryCountResult countResult = (BCQueryCountResult) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, countResult.getResultCode());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
Aggregations