📍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:
@ -23,11 +23,9 @@
|
||||
|
||||
package com.iluwatar.producer.consumer;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Producer Consumer Design pattern is a classic concurrency or threading pattern which reduces
|
||||
@ -39,10 +37,9 @@ import org.slf4j.LoggerFactory;
|
||||
* different timing require to produce item or consuming item. by using producer consumer pattern
|
||||
* both Producer and Consumer Thread can work with different speed.
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
*
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.producer.consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Class responsible for consume the {@link Item} produced by {@link Producer}.
|
||||
*/
|
||||
@Slf4j
|
||||
public class Consumer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Consumer.class);
|
||||
|
||||
private final ItemQueue queue;
|
||||
|
||||
private final String name;
|
||||
|
@ -40,7 +40,7 @@ public class ConsumerTest {
|
||||
private static final int ITEM_COUNT = 5;
|
||||
|
||||
@Test
|
||||
public void testConsume() throws Exception {
|
||||
void testConsume() throws Exception {
|
||||
final var queue = spy(new ItemQueue());
|
||||
for (var id = 0; id < ITEM_COUNT; id++) {
|
||||
queue.put(new Item("producer", id));
|
||||
|
@ -40,7 +40,7 @@ import org.junit.jupiter.api.Test;
|
||||
public class ProducerTest {
|
||||
|
||||
@Test
|
||||
public void testProduce() {
|
||||
void testProduce() {
|
||||
assertTimeout(ofMillis(6000), () -> {
|
||||
final var queue = mock(ItemQueue.class);
|
||||
final var producer = new Producer("producer", queue);
|
||||
|
Reference in New Issue
Block a user