BCQuery { public void queryBillsCountAsync(final QueryParams queryParams, final BCCallback callback) { if (queryParams == null) { Log.w(TAG, "查询参数queryParams不可为null"); return; } queryOrdersAsync(queryParams.channel, QueryOrderType.QUERY_BILLS_COUNT, queryParams.billNum, queryParams.payResult, null, null, queryParams.startTime, queryParams.endTime, null, null, null, callback); } private  BCQuery(); synchronized static BCQuery getInstance(); void queryBillsAsync(final BCReqParams.BCChannelTypes channel, final String billNum,
                                final Long startTime, final Long endTime,
                                final Integer skip, final Integer limit, final BCCallback callback); void queryBillsAsync(final BCReqParams.BCChannelTypes channel, final BCCallback callback); void queryBillsAsync(final BCReqParams.BCChannelTypes channel, final String billNum, final BCCallback callback); void queryBillsAsync(final QueryParams queryParams, final BCCallback callback); void queryRefundsAsync(final BCReqParams.BCChannelTypes channel, final String billNum, final String refundNum,
                                final Long startTime, final Long endTime,
                                final Integer skip, final Integer limit, final BCCallback callback); void queryRefundsAsync(final BCReqParams.BCChannelTypes channel, final BCCallback callback); void queryRefundsAsync(final BCReqParams.BCChannelTypes channel, final String billNum,
                                  final String refundNum, final BCCallback callback); void queryRefundsAsync(final QueryParams queryParams, final BCCallback callback); void queryBillsCountAsync(final QueryParams queryParams, final BCCallback callback); void queryRefundsCountAsync(final QueryParams queryParams, final BCCallback callback); void queryRefundStatusAsync(final BCReqParams.BCChannelTypes channel, final String refundNum,
                                       final BCCallback callback); void queryBillByIDAsync(final String id, final BCCallback callback); void queryRefundByIDAsync(final String id, final BCCallback callback); void queryOfflineBillStatusAsync(final BCReqParams.BCChannelTypes channelType,
                                          final String billNum,
                                          final BCCallback callback); void subscriptionSupportedBanks(final BCCallback callback); void queryPlans(final BCPlanCriteria criteria, final BCCallback callback); void querySubscriptions(final BCSubscriptionCriteria criteria, final BCCallback callback);  }
@Test public void testQueryBillsCountAsyncChannelInvalid() throws Exception { BCQuery.QueryParams queryParams = new BCQuery.QueryParams(); queryParams.channel = null; query.queryBillsCountAsync(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); }
@Test public void testQueryBillsCountAsyncNetworkError() throws Exception { final BCHttpClientUtil.Response response = new BCHttpClientUtil.Response(); response.code = 400; response.content = "wrong"; 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); }
@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}"; 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); }