deps: Refactor dependencies (#3224)

* remove spring dep
move junit, logging, mockito under dep mgmt

* upgrade anti-corruption-layer deps

* async method invocation

* balking, bloc

* bridge to bytecode

* caching

* callback - cqrs

* component - health check

* hexagonal - metadata mapping

* rest of the patterns

* remove checkstyle, take spotless into use
This commit is contained in:
Ilkka Seppälä
2025-03-29 19:34:27 +02:00
committed by GitHub
parent 371439aeaa
commit 0ca162a55c
1863 changed files with 14403 additions and 17632 deletions
@@ -26,9 +26,7 @@ package com.iluwatar.balking;
import java.util.concurrent.TimeUnit;
/**
* An interface to simulate delay while executing some work.
*/
/** An interface to simulate delay while executing some work. */
public interface DelayProvider {
void executeAfterDelay(long interval, TimeUnit timeUnit, Runnable task);
}
@@ -28,30 +28,26 @@ import java.util.concurrent.TimeUnit;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
* Washing machine class.
*/
/** Washing machine class. */
@Slf4j
public class WashingMachine {
private final DelayProvider delayProvider;
@Getter
private WashingMachineState washingMachineState;
@Getter private WashingMachineState washingMachineState;
/**
* Creates a new instance of WashingMachine.
*/
/** Creates a new instance of WashingMachine. */
public WashingMachine() {
this((interval, timeUnit, task) -> {
try {
Thread.sleep(timeUnit.toMillis(interval));
} catch (InterruptedException ie) {
LOGGER.error("", ie);
Thread.currentThread().interrupt();
}
task.run();
});
this(
(interval, timeUnit, task) -> {
try {
Thread.sleep(timeUnit.toMillis(interval));
} catch (InterruptedException ie) {
LOGGER.error("", ie);
Thread.currentThread().interrupt();
}
task.run();
});
}
/**
@@ -63,9 +59,7 @@ public class WashingMachine {
this.washingMachineState = WashingMachineState.ENABLED;
}
/**
* Method responsible for washing if the object is in appropriate state.
*/
/** Method responsible for washing if the object is in appropriate state. */
public void wash() {
synchronized (this) {
var machineState = getWashingMachineState();
@@ -81,12 +75,9 @@ public class WashingMachine {
this.delayProvider.executeAfterDelay(50, TimeUnit.MILLISECONDS, this::endOfWashing);
}
/**
* Method is responsible for ending the washing by changing machine state.
*/
/** Method is responsible for ending the washing by changing machine state. */
public synchronized void endOfWashing() {
washingMachineState = WashingMachineState.ENABLED;
LOGGER.info("{}: Washing completed.", Thread.currentThread().getId());
}
}
@@ -24,27 +24,22 @@
*/
package com.iluwatar.balking;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Application test
*/
/** Application test */
class AppTest {
/**
* Issue: Add at least one assertion to this test case.
*
* Solution: Inserted assertion to check whether the execution of the main method in {@link App}
* throws an exception.
* <p>Solution: Inserted assertion to check whether the execution of the main method in {@link
* App} throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow((Executable) App::main);
}
}
}
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
/**
* Tests for {@link WashingMachine}
*/
/** Tests for {@link WashingMachine} */
class WashingMachineTest {
private final FakeDelayProvider fakeDelayProvider = new FakeDelayProvider();
@@ -69,4 +67,4 @@ class WashingMachineTest {
this.task = task;
}
}
}
}