@Test public void testGetUid() { mockServer .expect(requestTo("https://api.weibo.com/2/account/get_uid.json")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("account"), responseHeaders)); assertEquals(123, accountTemplate.getUid()); }
@Test public void testGetRateLimitStatus() { mockServer .expect(requestTo("https://api.weibo.com/2/account/rate_limit_status.json")) .andExpect(method(GET)) .andRespond(withResponse(jsonResource("rateLimitStatus"), responseHeaders)); RateLimitStatus rateLimitStatus = accountTemplate.getRateLimitStatus(); List<ApiRateLimit> apiRateLimits = rateLimitStatus.getApiRateLimits(); assertEquals(5, apiRateLimits.size()); ApiRateLimit updateStatusRateLimit = apiRateLimits.iterator().next(); assertEquals("/statuses/update", updateStatusRateLimit.getApi()); assertEquals(30, updateStatusRateLimit.getLimit()); assertEquals(LimitTimeUnit.HOURS, updateStatusRateLimit.getLimitTimeUnit()); assertEquals(10, updateStatusRateLimit.getRemainingHits()); assertEquals(1000, rateLimitStatus.getIpLimit()); assertEquals(LimitTimeUnit.HOURS, rateLimitStatus.getLimitTimeUnit()); assertEquals(999, rateLimitStatus.getRemainingIpHits()); assertEquals(149, rateLimitStatus.getRemainingUserHits()); assertEquals(this.getTestDateInMillis(), rateLimitStatus.getResetTime().getTime()); assertEquals(2295, rateLimitStatus.getResetTimeInSeconds()); assertEquals(150, rateLimitStatus.getUserLimit()); }