Search in sources :

Example 1 with BCRefundStatus

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

the class BCQueryTest method testQueryRefundStatusAsyncRefundNumInvalid.

/**
 * #2
 * 输入退款单号为null的情况
 * @throws Exception
 */
@Test
public void testQueryRefundStatusAsyncRefundNumInvalid() throws Exception {
    query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, null, 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 2 with BCRefundStatus

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

the class BCQueryTest method testQueryRefundStatusAsyncTestMode.

/**
 * #5
 * test mode
 * @throws Exception
 */
@Test
public void testQueryRefundStatusAsyncTestMode() throws Exception {
    BeeCloud.setSandbox(true);
    query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, "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());
            Assert.assertEquals("该功能暂不支持测试模式", status.getErrDetail());
            BeeCloud.setSandbox(false);
            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 3 with BCRefundStatus

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

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

the class BCQueryTest method testQueryRefundStatusAsyncSucc.

/**
 * #4
 * 网络请求200
 * @throws Exception
 */
@Test
public void testQueryRefundStatusAsyncSucc() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 200;
    response.content = "{\"result_msg\":\"OK\",\"refund_status\":\"SUCCESS\",\"resultCode\":0,\"errMsg\":\"OK:\",\"err_detail\":\"\",\"result_code\":0}";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
    query.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, "refundnum", new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCRefundStatus);
            BCRefundStatus status = (BCRefundStatus) result;
            Assert.assertEquals((Integer) 0, status.getResultCode());
            Assert.assertTrue(BCRefundStatus.RefundStatus.REFUND_STATUS_SUCCESS.equals(status.getRefundStatus()));
            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 5 with BCRefundStatus

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

the class BCQueryTest method testQueryRefundStatusAsyncNetworkError.

/**
 * #3
 * 网络请求400等异常情况
 * @throws Exception
 */
@Test
public void testQueryRefundStatusAsyncNetworkError() 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.queryRefundStatusAsync(BCReqParams.BCChannelTypes.WX, "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)

Aggregations

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