Search in sources :

Example 1 with BCQueryCountResult

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

the class BCQueryTest method testQueryBillsCountAsyncSucc.

/**
 * #3
 * 网络请求200
 * @throws Exception
 */
@Test
public void testQueryBillsCountAsyncSucc() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 200;
    response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"count\":826,\"result_code\":0}";
    // mock
    PowerMockito.stub(PowerMockito.method(BCHttpClientUtil.class, "httpGet", String.class)).toReturn(response);
    BCQuery.QueryParams params = new BCQuery.QueryParams();
    params.channel = BCReqParams.BCChannelTypes.ALL;
    params.payResult = Boolean.TRUE;
    query.queryBillsCountAsync(params, new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCQueryCountResult);
            BCQueryCountResult countResult = (BCQueryCountResult) result;
            Assert.assertEquals((Integer) 0, countResult.getResultCode());
            Assert.assertEquals((Integer) 826, countResult.getCount());
            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)

Example 2 with BCQueryCountResult

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

the class BCQueryTest method testQueryBillsCountAsyncNetworkError.

/**
 * #2
 * 网络请求400等异常情况
 * @throws Exception
 */
@Test
public void testQueryBillsCountAsyncNetworkError() 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.queryBillsCountAsync(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)

Example 3 with BCQueryCountResult

use of cn.beecloud.entity.BCQueryCountResult 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)

Example 4 with BCQueryCountResult

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

the class BCQueryTest method testQueryRefundsCountAsyncChannelInvalid.

/**
 * #1
 * 测试channel为null
 * @throws Exception
 */
@Test
public void testQueryRefundsCountAsyncChannelInvalid() throws Exception {
    BCQuery.QueryParams queryParams = new BCQuery.QueryParams();
    queryParams.channel = null;
    query.queryRefundsCountAsync(queryParams, 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)

Example 5 with BCQueryCountResult

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

the class BCQueryTest method testQueryRefundsCountAsyncSucc.

/**
 * #3
 * 网络请求200
 * @throws Exception
 */
@Test
public void testQueryRefundsCountAsyncSucc() throws Exception {
    final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response();
    response.code = 200;
    response.content = "{\"result_msg\":\"OK\",\"err_detail\":\"\",\"count\":826,\"result_code\":0}";
    // 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.queryRefundsCountAsync(queryParams, new BCCallback() {

        @Override
        public void done(BCResult result) {
            Assert.assertTrue(result instanceof BCQueryCountResult);
            BCQueryCountResult countResult = (BCQueryCountResult) result;
            Assert.assertEquals((Integer) 0, countResult.getResultCode());
            Assert.assertEquals((Integer) 826, countResult.getCount());
            latch.countDown();
        }
    });
    latch.await(2000, TimeUnit.MILLISECONDS);
}
Also used : BCQueryCountResult(cn.beecloud.entity.BCQueryCountResult) BCCallback(cn.beecloud.async.BCCallback) 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)7 BCResult (cn.beecloud.async.BCResult)7 BCQueryCountResult (cn.beecloud.entity.BCQueryCountResult)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 SimpleDateFormat (java.text.SimpleDateFormat)1