use of cn.beecloud.async.BCCallback in project ttdj by soonphe.
the class BCQueryTest method testQueryOfflineBillStatusAsyncTestMode.
/**
* #5
* test mode
* @throws Exception
*/
@Test
public void testQueryOfflineBillStatusAsyncTestMode() throws Exception {
BeeCloud.setSandbox(true);
query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_NATIVE, "fakeid", 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("该功能暂不支持测试模式", status.getErrDetail());
BeeCloud.setSandbox(false);
latch.countDown();
}
});
// 等待
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCCallback in project ttdj by soonphe.
the class BCQueryTest method testQueryBillsAsyncNetworkError.
/**
* #2
* 测试response为400等网络异常
* @throws Exception
*/
@Test
public void testQueryBillsAsyncNetworkError() 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);
query.queryBillsAsync(BCReqParams.BCChannelTypes.ALL, null, null, null, 2, 10, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryBillsResult);
BCQueryBillsResult billsResult = (BCQueryBillsResult) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, billsResult.getResultCode());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCCallback in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsAsyncTestMode.
/**
* #7
* test mode暂不支持
* @throws Exception
*/
@Test
public void testQueryRefundsAsyncTestMode() throws Exception {
BeeCloud.setSandbox(true);
query.queryRefundsAsync(BCReqParams.BCChannelTypes.ALL, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundsResult);
BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, refundsResult.getResultCode());
Assert.assertEquals("该功能暂不支持测试模式", refundsResult.getErrDetail());
BeeCloud.setSandbox(false);
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCCallback in project ttdj by soonphe.
the class BCQueryTest method testQueryBillsAsyncChannelNull.
/**
* #1
* 测试没有传channel的情况
* @throws Exception
*/
@Test
public void testQueryBillsAsyncChannelNull() throws Exception {
query.queryBillsAsync(null, null, null, null, null, null, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryBillsResult);
BCQueryBillsResult billsResult = (BCQueryBillsResult) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, billsResult.getResultCode());
latch.countDown();
}
});
// 最多等2s
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.async.BCCallback in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsCountAsyncNetworkError.
/**
* #2
* 网络请求400等异常情况
* @throws Exception
*/
@Test
public void testQueryRefundsCountAsyncNetworkError() 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.queryRefundsCountAsync(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