📍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

@ -54,6 +54,7 @@ The service architecture is as follows:
In terms of code, the end user application is:
```java
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);

View File

@ -23,8 +23,7 @@
package com.iluwatar.circuitbreaker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* <p>
@ -55,10 +54,9 @@ import org.slf4j.LoggerFactory;
* recovers, it goes back to the closed state and the cycle continues.
* </p>
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point.
*

View File

@ -35,7 +35,7 @@ public class DefaultCircuitBreakerTest {
//long timeout, int failureThreshold, long retryTimePeriod
@Test
public void testEvaluateState() {
void testEvaluateState() {
var circuitBreaker = new DefaultCircuitBreaker(null, 1, 1, 100);
//Right now, failureCount<failureThreshold, so state should be closed
assertEquals(circuitBreaker.getState(), "CLOSED");
@ -57,7 +57,7 @@ public class DefaultCircuitBreakerTest {
}
@Test
public void testSetStateForBypass() {
void testSetStateForBypass() {
var circuitBreaker = new DefaultCircuitBreaker(null, 1, 1, 2000 * 1000 * 1000);
//Right now, failureCount<failureThreshold, so state should be closed
//Bypass it and set it to open
@ -66,7 +66,7 @@ public class DefaultCircuitBreakerTest {
}
@Test
public void testApiResponses() throws RemoteServiceException {
void testApiResponses() throws RemoteServiceException {
RemoteService mockService = new RemoteService() {
@Override
public String call() throws RemoteServiceException {
@ -79,6 +79,5 @@ public class DefaultCircuitBreakerTest {
var serviceStartTime = System.nanoTime() - 60 * 1000 * 1000 * 1000;
var response = circuitBreaker.attemptRequest();
assertEquals(response, "Remote Success");
}
}

View File

@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
/**
* Monitoring Service test
*/
public class DelayedRemoteServiceTest {
class DelayedRemoteServiceTest {
/**
* Testing immediate response of the delayed service.
@ -39,7 +39,7 @@ public class DelayedRemoteServiceTest {
* @throws RemoteServiceException
*/
@Test
public void testDefaultConstructor() throws RemoteServiceException {
void testDefaultConstructor() throws RemoteServiceException {
Assertions.assertThrows(RemoteServiceException.class, () -> {
var obj = new DelayedRemoteService();
obj.call();

View File

@ -30,18 +30,18 @@ import org.junit.jupiter.api.Test;
/**
* Monitoring Service test
*/
public class MonitoringServiceTest {
class MonitoringServiceTest {
//long timeout, int failureThreshold, long retryTimePeriod
@Test
public void testLocalResponse() {
void testLocalResponse() {
var monitoringService = new MonitoringService(null,null);
var response = monitoringService.localResourceResponse();
assertEquals(response, "Local Service is working");
}
@Test
public void testDelayedRemoteResponseSuccess() {
void testDelayedRemoteResponseSuccess() {
var delayedService = new DelayedRemoteService(System.nanoTime()-2*1000*1000*1000, 2);
var delayedServiceCircuitBreaker = new DefaultCircuitBreaker(delayedService, 3000,
1,
@ -54,7 +54,7 @@ public class MonitoringServiceTest {
}
@Test
public void testDelayedRemoteResponseFailure() {
void testDelayedRemoteResponseFailure() {
var delayedService = new DelayedRemoteService(System.nanoTime(), 2);
var delayedServiceCircuitBreaker = new DefaultCircuitBreaker(delayedService, 3000,
1,
@ -66,7 +66,7 @@ public class MonitoringServiceTest {
}
@Test
public void testQuickRemoteServiceResponse() {
void testQuickRemoteServiceResponse() {
var delayedService = new QuickRemoteService();
var delayedServiceCircuitBreaker = new DefaultCircuitBreaker(delayedService, 3000,
1,