Search in sources :

Example 1 with BCBillStatus

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

the class BCQueryTest method testQueryOfflineBillStatusAsyncNetworkError.

/**
 * #3
 * 网络请求400等异常情况
 * @throws Exception
 */
@Test
public void testQueryOfflineBillStatusAsyncNetworkError() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 400;
    response.content = "wrong";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpPost", String.class, Map.class)).toReturn(response);
    query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_SCAN, "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());
            // 释放
            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 2 with BCBillStatus

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

the class BCQueryTest method testQueryOfflineBillStatusAsyncBillNumInvalid.

/**
 * #2
 * billNum为null的情况
 * @throws Exception
 */
@Test
public void testQueryOfflineBillStatusAsyncBillNumInvalid() throws Exception {
    query.queryOfflineBillStatusAsync(BCReqParams.BCChannelTypes.WX_SCAN, 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());
            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 3 with BCBillStatus

use of cn.beecloud.entity.BCBillStatus 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 4 with BCBillStatus

use of cn.beecloud.entity.BCBillStatus 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 5 with BCBillStatus

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

the class BCQueryTest method testQueryOfflineBillStatusAsyncSucc.

/**
 * #4
 * 模拟请求成功的情况
 * @throws Exception
 */
@Test
public void testQueryOfflineBillStatusAsyncSucc() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 200;
    response.content = "{\"result_msg\":\"OK\",\"submit_msg\":\"OK\",\"resultCode\":0,\"errMsg\":\"OK:\",\"err_detail\":\"\",\"result_code\":0,\"did_submit\":true,\"pay_result\":true}";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpPost", String.class, Map.class)).toReturn(response);
    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((Integer) 0, status.getResultCode());
            Assert.assertTrue(status.getPayResult());
            // 释放
            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)

Aggregations

BCCallback (cn.beecloud.async.BCCallback)5 BCResult (cn.beecloud.async.BCResult)5 BCBillStatus (cn.beecloud.entity.BCBillStatus)5 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5