Search in sources :

Example 21 with BCResult

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

the class BCQueryTest method testQueryOfflineBillStatusAsyncTestMode.

/**
 * #5
 * test mode
 * @throws Exception
 */
@Test
public void testQueryOfflineBillStatusAsyncTestMode() throws Exception {
    BeeCloud.setSandbox(true);
    query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_NATIVE, "fakeid", 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("该功能暂不支持测试模式", status.getErrDetail());
            BeeCloud.setSandbox(false);
            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 22 with BCResult

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

the class BCQueryTest method testQueryBillsAsyncNetworkError.

/**
 * #2
 * 测试response为400等网络异常
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncNetworkError() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 400;
    response.content = "wrong";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
    query.queryBillsAsync(BCReqParams.BCChannelTypes.ALL, null, null, null, 2, 10, new BCCallback() {

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

Example 23 with BCResult

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

the class BCQueryTest method testQueryRefundsAsyncTestMode.

/**
 * #7
 * test mode暂不支持
 * @throws Exception
 */
@Test
public void testQueryRefundsAsyncTestMode() throws Exception {
    BeeCloud.setSandbox(true);
    query.queryRefundsAsync(BCReqParams.BCChannelTypes.ALL, new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCQueryRefundsResult);
            BCQueryRefundsResult refundsResult = (BCQueryRefundsResult) result;
            Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, refundsResult.getResultCode());
            Assert.assertEquals("该功能暂不支持测试模式", refundsResult.getErrDetail());
            BeeCloud.setSandbox(false);
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCCallback(cn.beecloud.async.BCCallback) BCQueryRefundsResult(cn.beecloud.entity.BCQueryRefundsResult) BCResult(cn.beecloud.async.BCResult) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 24 with BCResult

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

the class BCQueryTest method testQueryBillsAsyncChannelNull.

/**
 * #1
 * 测试没有传channel的情况
 * @throws Exception
 */
@Test
public void testQueryBillsAsyncChannelNull() throws Exception {
    query.queryBillsAsync(null, null, null, null, null, null, new BCCallback() {

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

Example 25 with BCResult

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

the class BCQueryTest method testQueryRefundsCountAsyncNetworkError.

/**
 * #2
 * 网络请求400等异常情况
 * @throws Exception
 */
@Test
public void testQueryRefundsCountAsyncNetworkError() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 400;
    response.content = "wrong";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
    BCQuery.QueryParams params = new BCQuery.QueryParams();
    params.channel = BCReqParams.BCChannelTypes.ALL;
    query.queryRefundsCountAsync(params, new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCQueryCountResult);
            BCQueryCountResult countResult = (BCQueryCountResult) result;
            Assert.assertEquals(BCRestfulCommonResult.APP_INNER_FAIL_NUM, countResult.getResultCode());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCQueryCountResult(cn.beecloud.entity.BCQueryCountResult) BCCallback(cn.beecloud.async.BCCallback) 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