use of cn.beecloud.entity.BCRevertStatus in project ttdj by soonphe.
the class BCOfflinePayTest method testReqRevertBillAsyncTestMode.
/**
* #4
* test mode暂不支持
* @throws Exception
*/
@Test
public void testReqRevertBillAsyncTestMode() throws Exception {
BeeCloud.setSandbox(true);
pay.reqRevertBillAsync(BCReqParams.BCChannelTypes.ALI_SCAN, "billnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRevertStatus);
BCRevertStatus revertStatus = (BCRevertStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, revertStatus.getResultCode());
Assert.assertEquals("该功能暂不支持测试模式", revertStatus.getErrDetail());
BeeCloud.setSandbox(false);
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRevertStatus in project ttdj by soonphe.
the class BCOfflinePayTest method testReqRevertBillAsyncNetworkError.
/**
* #2
* 模拟网络400等异常
* @throws Exception
*/
@Test
public void testReqRevertBillAsyncNetworkError() throws Exception {
BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 400;
response.content = "wrong";
// mock network
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpPost", String.class, Map.class)).toReturn(response);
pay.reqRevertBillAsync(BCReqParams.BCChannelTypes.WX_SCAN, "fakebillnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRevertStatus);
BCRevertStatus revertStatus = (BCRevertStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, revertStatus.getResultCode());
// System.out.println(revertStatus.getErrDetail());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRevertStatus in project ttdj by soonphe.
the class BCOfflinePayTest method testReqRevertBillAsyncSucc.
/**
* #3
* 模拟全部正常的情况
* @throws Exception
*/
@Test
public void testReqRevertBillAsyncSucc() throws Exception {
BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"Success\",\"result_code\":0,\"revert_status\":true}";
// mock network
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpPost", String.class, Map.class)).toReturn(response);
pay.reqRevertBillAsync(BCReqParams.BCChannelTypes.ALI_OFFLINE_QRCODE, "fakebillnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRevertStatus);
BCRevertStatus revertStatus = (BCRevertStatus) result;
Assert.assertEquals((Integer) 0, revertStatus.getResultCode());
Assert.assertTrue(revertStatus.getRevertStatus());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRevertStatus in project ttdj by soonphe.
the class BCOfflinePayTest method testReqRevertBillAsyncParamInvalid.
/**
* #1
* 模拟参数问题
* @throws Exception
*/
@Test
public void testReqRevertBillAsyncParamInvalid() throws Exception {
Object[][] test = new Object[][] { // 依次代表渠道类型 订单流水号
new Object[] { null, null }, new Object[] { BCReqParams.BCChannelTypes.ALI_APP, null }, new Object[] { BCReqParams.BCChannelTypes.ALI_SCAN, null } };
for (Object[] objects : test) {
final CountDownLatch localLatch = new CountDownLatch(1);
pay.reqRevertBillAsync((BCReqParams.BCChannelTypes) objects[0], (String) objects[1], new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCRevertStatus);
BCRevertStatus revertStatus = (BCRevertStatus) result;
Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, revertStatus.getResultCode());
// System.out.println(revertStatus.getErrDetail());
localLatch.countDown();
}
});
localLatch.await(2000, TimeUnit.MILLISECONDS);
}
}
Aggregations