use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryOfflineBillStatusAsyncChannelInvalid.
/**
* #1
* 测试不支持的channel
* @throws Exception
*/
@Test
public void testQueryOfflineBillStatusAsyncChannelInvalid() throws Exception {
query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_APP, 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());
Assert.assertEquals("invalid bill number", status.getErrDetail());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundStatusAsyncChannelInvalid.
/**
* #1
* 测试channel非支持的情况
* @throws Exception
*/
@Test
public void testQueryRefundStatusAsyncChannelInvalid() throws Exception {
query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.ALI, "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());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryBillsAsyncByChannelBillNum.
/**
* #5
* 测试根据支付渠道和订单号获取订单
* @throws Exception
*/
@Test
public void testQueryBillsAsyncByChannelBillNum() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be content for bills, here delete the record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"bills\":[{\"bill_no\":\"bc1447657931\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryBillsAsync(BCReqParams.BCChannelTypes.ALL, "billnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryBillsResult);
BCQueryBillsResult billsResult = (BCQueryBillsResult) result;
Assert.assertEquals((Integer) 0, billsResult.getResultCode());
Assert.assertEquals((int) billsResult.getCount(), billsResult.getBills().size());
BCBillOrder billOrder = billsResult.getBills().get(0);
Assert.assertEquals("bc1447657931", billOrder.getBillNum());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundByIDAsyncParamInvalid.
/**
* #1
* 测试传入id为null的情况
* @throws Exception
*/
@Test
public void testQueryRefundByIDAsyncParamInvalid() throws Exception {
query.queryRefundByIDAsync(null, new BCCallback() {
@Override
public void done(BCResult result) {
// 传出的应是BCQueryRefundResult类型
Assert.assertTrue(result instanceof BCQueryRefundResult);
BCQueryRefundResult refundResult = (BCQueryRefundResult) result;
// 返回的结果应该是-1
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, refundResult.getResultCode());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCResult in project ttdj by soonphe.
the class BCQueryTest method testQueryBillsAsyncByBean.
/**
* #6
* 测试通过BCQuery.QueryParams方式获取订单
* @throws Exception
*/
@Test
public void testQueryBillsAsyncByBean() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be content for bills, here delete the record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"bills\":[{\"bill_no\":\"bc1447657931\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
BCQuery.QueryParams queryParams = new BCQuery.QueryParams();
queryParams.channel = BCReqParams.BCChannelTypes.WX;
queryParams.startTime = sdf.parse("2015-10-01 00:00").getTime();
query.queryBillsAsync(queryParams, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryBillsResult);
BCQueryBillsResult billsResult = (BCQueryBillsResult) result;
Assert.assertEquals((Integer) 0, billsResult.getResultCode());
Assert.assertEquals((int) billsResult.getCount(), billsResult.getBills().size());
BCBillOrder billOrder = billsResult.getBills().get(0);
Assert.assertEquals("bc1447657931", billOrder.getBillNum());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
Aggregations