Merge branch 'master' of https://github.com/Argyro-Sioziou/java-design-patterns into acyclic-visitor

This commit is contained in:
Argyro-Sioziou 2018-05-27 15:44:04 +03:00
commit e9a219f643

View File

@ -22,29 +22,27 @@
*/ */
package com.iluwatar.throttling; package com.iluwatar.throttling;
import com.iluwatar.throttling.timer.ThrottleTimerImpl;
import com.iluwatar.throttling.timer.Throttler; import com.iluwatar.throttling.timer.Throttler;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals;
/** /**
* B2BServiceTest class to test the B2BService * B2BServiceTest class to test the B2BService
*/ */
public class B2BServiceTest { public class B2BServiceTest {
@Disabled
@Test @Test
public void dummyCustomerApiTest() { public void dummyCustomerApiTest() {
Tenant tenant = new Tenant("testTenant", 2); Tenant tenant = new Tenant("testTenant", 2);
Throttler timer = new ThrottleTimerImpl(100); // In order to assure that throttling limits will not be reset, we use an empty throttling implementation
Throttler timer = () -> { };
B2BService service = new B2BService(timer); B2BService service = new B2BService(timer);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
service.dummyCustomerApi(tenant); service.dummyCustomerApi(tenant);
} }
long counter = CallsCount.getCount(tenant.getName()); long counter = CallsCount.getCount(tenant.getName());
assertTrue(counter == 2, "Counter limit must be reached"); assertEquals(2, counter, "Counter limit must be reached");
} }
} }