Skip to content

#643 Fix flaky tests for throttling pattern #752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,27 @@
*/
package com.iluwatar.throttling;

import com.iluwatar.throttling.timer.ThrottleTimerImpl;
import com.iluwatar.throttling.timer.Throttler;
import org.junit.jupiter.api.Disabled;
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
*/
public class B2BServiceTest {

@Disabled
@Test
public void dummyCustomerApiTest() {
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);

for (int i = 0; i < 5; i++) {
service.dummyCustomerApi(tenant);
}
long counter = CallsCount.getCount(tenant.getName());
assertTrue(counter == 2, "Counter limit must be reached");
assertEquals(2, counter, "Counter limit must be reached");
}
}