Search in sources :

Example 6 with BCQueryRefundsResult

use of cn.beecloud.entity.BCQueryRefundsResult 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);
}
Also used : BCCallback(cn.beecloud.async.BCCallback) BCRefundOrder(cn.beecloud.entity.BCRefundOrder) BCQueryRefundsResult(cn.beecloud.entity.BCQueryRefundsResult) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with BCQueryRefundsResult

use of cn.beecloud.entity.BCQueryRefundsResult 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);
}
Also used : BCCallback(cn.beecloud.async.BCCallback) BCRefundOrder(cn.beecloud.entity.BCRefundOrder) BCQueryRefundsResult(cn.beecloud.entity.BCQueryRefundsResult) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BCCallback (cn.beecloud.async.BCCallback)7 BCResult (cn.beecloud.async.BCResult)7 BCQueryRefundsResult (cn.beecloud.entity.BCQueryRefundsResult)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 BCRefundOrder (cn.beecloud.entity.BCRefundOrder)4