Search in sources :

Example 26 with BCResult

use of cn.beecloud.async.BCResult in project ttdj by soonphe.

the class BCQueryTest method testQueryOfflineBillStatusAsyncChannelInvalid.

/**
 * #1
 * 测试不支持的channel
 * @throws Exception
 */
@Test
public void testQueryOfflineBillStatusAsyncChannelInvalid() throws Exception {
    query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_APP, null, 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("invalid bill number", status.getErrDetail());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCBillStatus(cn.beecloud.entity.BCBillStatus) BCCallback(cn.beecloud.async.BCCallback) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 27 with BCResult

use of cn.beecloud.async.BCResult in project ttdj by soonphe.

the class BCQueryTest method testQueryRefundStatusAsyncChannelInvalid.

/**
 * #1
 * 测试channel非支持的情况
 * @throws Exception
 */
@Test
public void testQueryRefundStatusAsyncChannelInvalid() throws Exception {
    query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.ALI, "refundnum", new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCRefundStatus);
            BCRefundStatus status = (BCRefundStatus) result;
            Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, status.getResultCode());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCCallback(cn.beecloud.async.BCCallback) BCRefundStatus(cn.beecloud.entity.BCRefundStatus) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 28 with BCResult

use of cn.beecloud.async.BCResult in project ttdj by soonphe.

the class BCQueryTest method testQueryBillsAsyncByChannelBillNum.

/**
 * #5
 * 测试根据支付渠道和订单号获取订单
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncByChannelBillNum() 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, "billnum", 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)

Example 29 with BCResult

use of cn.beecloud.async.BCResult in project ttdj by soonphe.

the class BCQueryTest method testQueryRefundByIDAsyncParamInvalid.

/**
 * #1
 * 测试传入id为null的情况
 * @throws Exception
 */
@Test
public void testQueryRefundByIDAsyncParamInvalid() throws Exception {
    query.queryRefundByIDAsync(null, new BCCallback() {

        @Override
        public void done(BCResult result) {
            // 传出的应是BCQueryRefundResult类型
            Assert.assertTrue(result instanceof BCQueryRefundResult);
            BCQueryRefundResult refundResult = (BCQueryRefundResult) result;
            // 返回的结果应该是-1
            Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, refundResult.getResultCode());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCCallback(cn.beecloud.async.BCCallback) BCQueryRefundResult(cn.beecloud.entity.BCQueryRefundResult) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 30 with BCResult

use of cn.beecloud.async.BCResult in project ttdj by soonphe.

the class BCQueryTest method testQueryBillsAsyncByBean.

/**
 * #6
 * 测试通过BCQuery.QueryParams方式获取订单
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncByBean() 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);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
    BCQuery.QueryParams queryParams = new BCQuery.QueryParams();
    queryParams.channel = BCReqParams.BCChannelTypes.WX;
    queryParams.startTime = sdf.parse("2015-10-01 00:00").getTime();
    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());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCQueryBillsResult(cn.beecloud.entity.BCQueryBillsResult) BCCallback(cn.beecloud.async.BCCallback) BCBillOrder(cn.beecloud.entity.BCBillOrder) SimpleDateFormat(java.text.SimpleDateFormat) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BCCallback (cn.beecloud.async.BCCallback)61 BCResult (cn.beecloud.async.BCResult)61 Test (org.junit.Test)61 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)61 BCPayResult (cn.beecloud.entity.BCPayResult)10 BCQRCodeResult (cn.beecloud.entity.BCQRCodeResult)8 BCBillOrder (cn.beecloud.entity.BCBillOrder)7 BCQueryBillsResult (cn.beecloud.entity.BCQueryBillsResult)7 BCQueryCountResult (cn.beecloud.entity.BCQueryCountResult)7 BCQueryRefundsResult (cn.beecloud.entity.BCQueryRefundsResult)7 BCBillStatus (cn.beecloud.entity.BCBillStatus)5 BCRefundOrder (cn.beecloud.entity.BCRefundOrder)5 BCRefundStatus (cn.beecloud.entity.BCRefundStatus)5 BCQueryBillResult (cn.beecloud.entity.BCQueryBillResult)4 BCQueryRefundResult (cn.beecloud.entity.BCQueryRefundResult)4 BCRevertStatus (cn.beecloud.entity.BCRevertStatus)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 BCReqParams (cn.beecloud.entity.BCReqParams)3 Bitmap (android.graphics.Bitmap)2 Looper (android.os.Looper)2