Search in sources :

Example 6 with BCQueryBillsResult

use of cn.beecloud.entity.BCQueryBillsResult in project ttdj by soonphe.

the class BCQueryTest method testQueryBillsAsyncTestMode.

/**
 * #7
 * test mode
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncTestMode() throws Exception {
    BeeCloud.setSandbox(true);
    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);
    BCQuery.QueryParams queryParams = new BCQuery.QueryParams();
    queryParams.channel = BCReqParams.BCChannelTypes.WX;
    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());
            BeeCloud.setSandbox(false);
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCQueryBillsResult(cn.beecloud.entity.BCQueryBillsResult) BCCallback(cn.beecloud.async.BCCallback) BCResult(cn.beecloud.async.BCResult) BCBillOrder(cn.beecloud.entity.BCBillOrder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with BCQueryBillsResult

use of cn.beecloud.entity.BCQueryBillsResult in project ttdj by soonphe.

the class BCQueryTest method testQueryBillsAsyncByChannel.

/**
 * #4
 * 测试根据支付渠道获取订单
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncByChannel() 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, 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);
}
Also used : BCQueryBillsResult(cn.beecloud.entity.BCQueryBillsResult) BCCallback(cn.beecloud.async.BCCallback) BCResult(cn.beecloud.async.BCResult) BCBillOrder(cn.beecloud.entity.BCBillOrder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BCCallback (cn.beecloud.async.BCCallback)7 BCResult (cn.beecloud.async.BCResult)7 BCQueryBillsResult (cn.beecloud.entity.BCQueryBillsResult)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 BCBillOrder (cn.beecloud.entity.BCBillOrder)5 SimpleDateFormat (java.text.SimpleDateFormat)1