📍Use lombok, reformat, and optimize the code (#1560)

* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@ -58,9 +58,8 @@ public class Tenant {
}
}
@Slf4j
public final class CallsCount {
private static final Logger LOGGER = LoggerFactory.getLogger(CallsCount.class);
private final Map<String, AtomicLong> tenantCallsCount = new ConcurrentHashMap<>();
public void addTenant(String tenantName) {

View File

@ -27,8 +27,7 @@ import com.iluwatar.throttling.timer.ThrottleTimerImpl;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* Throttling pattern is a design pattern to throttle or limit the use of resources or even a
@ -41,10 +40,9 @@ import org.slf4j.LoggerFactory;
* ({@link Tenant}) is the Tenant POJO class with which many tenants can be created ({@link
* B2BService}) is the service which is consumed by the tenants and is throttled.
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Application entry point.
*

View File

@ -26,17 +26,15 @@ package com.iluwatar.throttling;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* A class to keep track of the counter of different Tenants.
*
* @author drastogi
*/
@Slf4j
public final class CallsCount {
private static final Logger LOGGER = LoggerFactory.getLogger(CallsCount.class);
private final Map<String, AtomicLong> tenantCallsCount = new ConcurrentHashMap<>();
/**

View File

@ -37,7 +37,7 @@ public class B2BServiceTest {
private final CallsCount callsCount = new CallsCount();
@Test
public void dummyCustomerApiTest() {
void dummyCustomerApiTest() {
var tenant = new Tenant("testTenant", 2, callsCount);
// In order to assure that throttling limits will not be reset, we use an empty throttling implementation
var timer = (Throttler) () -> {

View File

@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test;
public class TenantTest {
@Test
public void constructorTest() {
void constructorTest() {
assertThrows(InvalidParameterException.class, () -> {
new Tenant("FailTenant", -1, new CallsCount());
});