📍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:
@ -102,10 +102,9 @@ Next we present a runnable `Worker` class that the thread pool will utilize to h
|
||||
peeling and coffee making.
|
||||
|
||||
```java
|
||||
@Slf4j
|
||||
public class Worker implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Worker.class);
|
||||
|
||||
private final Task task;
|
||||
|
||||
public Worker(final Task task) {
|
||||
|
@ -26,8 +26,7 @@ package com.iluwatar.threadpool;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Thread Pool pattern is where a number of threads are created to perform a number of tasks, which
|
||||
@ -42,10 +41,9 @@ import org.slf4j.LoggerFactory;
|
||||
* ExecutorService} with fixed number of threads (Thread Pool) and use them to execute the {@link
|
||||
* Worker}s.
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*
|
||||
|
@ -23,17 +23,15 @@
|
||||
|
||||
package com.iluwatar.threadpool;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Worker implements {@link Runnable} and thus can be executed by {@link
|
||||
* java.util.concurrent.ExecutorService}.
|
||||
*/
|
||||
@Slf4j
|
||||
public class Worker implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Worker.class);
|
||||
|
||||
private final Task task;
|
||||
|
||||
public Worker(final Task task) {
|
||||
|
@ -83,7 +83,7 @@ public abstract class TaskTest<T extends Task> {
|
||||
* threads
|
||||
*/
|
||||
@Test
|
||||
public void testIdGeneration() throws Exception {
|
||||
void testIdGeneration() throws Exception {
|
||||
assertTimeout(ofMillis(10000), () -> {
|
||||
final var service = Executors.newFixedThreadPool(THREAD_COUNT);
|
||||
|
||||
@ -113,7 +113,7 @@ public abstract class TaskTest<T extends Task> {
|
||||
* a given number of times
|
||||
*/
|
||||
@Test
|
||||
public void testTimeMs() {
|
||||
void testTimeMs() {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
assertEquals(this.expectedExecutionTime * i, this.factory.apply(i).getTimeMs());
|
||||
}
|
||||
@ -123,7 +123,7 @@ public abstract class TaskTest<T extends Task> {
|
||||
* Verify if the task has some sort of {@link T#toString()}, different from 'null'
|
||||
*/
|
||||
@Test
|
||||
public void testToString() {
|
||||
void testToString() {
|
||||
assertNotNull(this.factory.apply(0).toString());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class WorkerTest {
|
||||
* Verify if a worker does the actual job
|
||||
*/
|
||||
@Test
|
||||
public void testRun() {
|
||||
void testRun() {
|
||||
final var task = mock(Task.class);
|
||||
final var worker = new Worker(task);
|
||||
verifyZeroInteractions(task);
|
||||
|
Reference in New Issue
Block a user