use of cn.beecloud.entity.BCRefundOrder in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundByIDAsyncSucc.
/**
* #3
* 模拟response为200
* @throws Exception
*/
@Test
public void testQueryRefundByIDAsyncSucc() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"refund\":{\"result\":false,\"create_time\":1446531122439,\"refund_no\":\"2015110362316\",\"total_fee\":1,\"refund_fee\":1,\"channel\":\"WX\",\"bill_no\":\"ccd378d8823640a68e220949686e5922\",\"finish\":false,\"optional\":\"{\\\"test\\\":\\\"test\\\"}\",\"title\":\"demo测试\",\"sub_channel\":\"WX_NATIVE\",\"message_detail\":\"\"}}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryRefundByIDAsync("refundid", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundResult);
BCQueryRefundResult refundResult = (BCQueryRefundResult) result;
Assert.assertEquals((Integer) 0, refundResult.getResultCode());
BCRefundOrder refundOrder = refundResult.getRefund();
Assert.assertEquals("ccd378d8823640a68e220949686e5922", refundOrder.getBillNum());
Assert.assertEquals("2015110362316", refundOrder.getRefundNum());
Assert.assertEquals("demo测试", refundOrder.getTitle());
Assert.assertEquals((Integer) 1, refundOrder.getTotalFee());
Assert.assertEquals((Integer) 1, refundOrder.getRefundFee());
Assert.assertEquals("WX", refundOrder.getChannel());
Assert.assertEquals("WX_NATIVE", refundOrder.getSubChannel());
Assert.assertFalse(refundOrder.isRefundFinished());
Assert.assertFalse(refundOrder.getRefundResult());
Assert.assertEquals((Long) 1446531122439L, refundOrder.getRefundCreatedTime());
Assert.assertEquals("{\"test\":\"test\"}", refundOrder.getOptional());
// 释放
latch.countDown();
}
});
// 等待
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRefundOrder in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsAsyncByChannelBillRefundNum.
/**
* #5
* 测试根据支付渠道和(支付订单号|退款单号)获取退款订单列表
* @throws Exception
*/
@Test
public void testQueryRefundsAsyncByChannelBillRefundNum() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be content for refunds, here delete the record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"refunds\":[{\"refund_no\":\"201511141447430832000\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryRefundsAsync(BCReqParams.BCChannelTypes.ALL, "billnum", "refundnum", new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundsResult);
BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
Assert.assertEquals((Integer) 0, refundsResult.getResultCode());
Assert.assertEquals((int) refundsResult.getCount(), refundsResult.getRefunds().size());
BCRefundOrder refundOrder = refundsResult.getRefunds().get(0);
Assert.assertEquals("201511141447430832000", refundOrder.getRefundNum());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRefundOrder in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsAsyncSucc.
/**
* #3
* 正常response为200的情况
* @throws Exception
*/
@Test
public void testQueryRefundsAsyncSucc() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be more content for refunds, here just keep one record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"refunds\":[{\"result\":false,\"create_time\":1447430833318,\"refund_no\":\"201511141447430832000\",\"total_fee\":1,\"refund_fee\":1,\"channel\":\"WX\",\"bill_no\":\"20151113132244266\",\"finish\":false,\"optional\":\"\",\"title\":\"2015-10-21 Release\",\"sub_channel\":\"WX_APP\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryRefundsAsync(BCReqParams.BCChannelTypes.ALL, null, null, null, null, 2, 10, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundsResult);
BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
Assert.assertEquals((Integer) 0, refundsResult.getResultCode());
Assert.assertTrue(refundsResult.getCount() == refundsResult.getRefunds().size());
BCRefundOrder refundOrder = refundsResult.getRefunds().get(0);
Assert.assertEquals("20151113132244266", refundOrder.getBillNum());
Assert.assertEquals("201511141447430832000", refundOrder.getRefundNum());
Assert.assertEquals("2015-10-21 Release", refundOrder.getTitle());
Assert.assertEquals((Integer) 1, refundOrder.getTotalFee());
Assert.assertEquals((Integer) 1, refundOrder.getRefundFee());
Assert.assertEquals("WX", refundOrder.getChannel());
Assert.assertEquals("WX_APP", refundOrder.getSubChannel());
Assert.assertFalse(refundOrder.isRefundFinished());
Assert.assertFalse(refundOrder.getRefundResult());
Assert.assertEquals((Long) 1447430833318L, refundOrder.getRefundCreatedTime());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRefundOrder in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsAsyncByChannel.
/**
* #4
* 测试根据支付渠道获取退款订单
* @throws Exception
*/
@Test
public void testQueryRefundsAsyncByChannel() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be content for refunds, here delete the record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"refunds\":[{\"refund_no\":\"201511141447430832000\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
query.queryRefundsAsync(BCReqParams.BCChannelTypes.ALL, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundsResult);
BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
Assert.assertEquals((Integer) 0, refundsResult.getResultCode());
Assert.assertEquals((int) refundsResult.getCount(), refundsResult.getRefunds().size());
BCRefundOrder refundOrder = refundsResult.getRefunds().get(0);
Assert.assertEquals("201511141447430832000", refundOrder.getRefundNum());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
use of cn.beecloud.entity.BCRefundOrder in project ttdj by soonphe.
the class BCQueryTest method testQueryRefundsAsyncByBean.
/**
* #6
* 测试根据BCQuery.QueryParams获取退款订单列表
* @throws Exception
*/
@Test
public void testQueryRefundsAsyncByBean() throws Exception {
final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
response.code = 200;
// please note this content is fake, there should be content for refunds, here delete the record for the limit of space
response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"result_code\":0,\"refunds\":[{\"refund_no\":\"201511141447430832000\"}]}";
// mock
PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
BCQuery.QueryParams queryParams = new BCQuery.QueryParams();
queryParams.channel = BCReqParams.BCChannelTypes.UN;
queryParams.refundNum = "refundnum";
queryParams.billNum = "billnum";
query.queryRefundsAsync(queryParams, new BCCallback() {
@Override
public void done(BCResult result) {
Assert.assertTrue(result instanceof BCQueryRefundsResult);
BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
Assert.assertEquals((Integer) 0, refundsResult.getResultCode());
Assert.assertEquals((int) refundsResult.getCount(), refundsResult.getRefunds().size());
BCRefundOrder refundOrder = refundsResult.getRefunds().get(0);
Assert.assertEquals("201511141447430832000", refundOrder.getRefundNum());
latch.countDown();
}
});
latch.await(2000, TimeUnit.MILLISECONDS);
}
Aggregations