@Disabled @Test public void dummyCustomerApiTest() { Tenant tenant = new Tenant("testTenant", 2); Throttler timer = new ThrottleTimerImpl(100); B2BService service = new B2BService(timer); for (int i = 0; i < 5; i++) { service.dummyCustomerApi(tenant); } long counter = CallsCount.getCount(tenant.getName()); assertTrue(counter == 2, "Counter limit must be reached"); }
public int dummyCustomerApi(Tenant tenant) { String tenantName = tenant.getName(); long count = CallsCount.getCount(tenantName); LOGGER.debug("Counter for {} : {} ", tenant.getName(), count); if (count >= tenant.getAllowedCallsPerSecond()) { LOGGER.error("API access per second limit reached for: {}", tenantName); return -1; } CallsCount.incrementCount(tenantName); return getRandomCustomerId(); }
B2BService { public int dummyCustomerApi(Tenant tenant) { String tenantName = tenant.getName(); long count = CallsCount.getCount(tenantName); LOGGER.debug("Counter for {} : {} ", tenant.getName(), count); if (count >= tenant.getAllowedCallsPerSecond()) { LOGGER.error("API access per second limit reached for: {}", tenantName); return -1; } CallsCount.incrementCount(tenantName); return getRandomCustomerId(); } }
B2BService { public int dummyCustomerApi(Tenant tenant) { String tenantName = tenant.getName(); long count = CallsCount.getCount(tenantName); LOGGER.debug("Counter for {} : {} ", tenant.getName(), count); if (count >= tenant.getAllowedCallsPerSecond()) { LOGGER.error("API access per second limit reached for: {}", tenantName); return -1; } CallsCount.incrementCount(tenantName); return getRandomCustomerId(); } B2BService(Throttler timer); }
B2BService { public int dummyCustomerApi(Tenant tenant) { String tenantName = tenant.getName(); long count = CallsCount.getCount(tenantName); LOGGER.debug("Counter for {} : {} ", tenant.getName(), count); if (count >= tenant.getAllowedCallsPerSecond()) { LOGGER.error("API access per second limit reached for: {}", tenantName); return -1; } CallsCount.incrementCount(tenantName); return getRandomCustomerId(); } B2BService(Throttler timer); int dummyCustomerApi(Tenant tenant); }
B2BService { public int dummyCustomerApi(Tenant tenant) { String tenantName = tenant.getName(); long count = CallsCount.getCount(tenantName); LOGGER.debug("Counter for {} : {} ", tenant.getName(), count); if (count >= tenant.getAllowedCallsPerSecond()) { LOGGER.error("API access per second limit reached for: {}", tenantName); return -1; } CallsCount.incrementCount(tenantName); return getRandomCustomerId(); } B2BService(Throttler timer); int dummyCustomerApi(Tenant tenant);  }