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
@@ -43,31 +43,44 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class App {
/**
* Program entry point.
*/
/** Program entry point. */
public static void main(String[] args) throws IOException, ClassNotFoundException {
// Write V1
var fishV1 = new RainbowFish("Zed", 10, 11, 12);
LOGGER.info("fishV1 name={} age={} length={} weight={}", fishV1.getName(),
fishV1.getAge(), fishV1.getLengthMeters(), fishV1.getWeightTons());
LOGGER.info(
"fishV1 name={} age={} length={} weight={}",
fishV1.getName(),
fishV1.getAge(),
fishV1.getLengthMeters(),
fishV1.getWeightTons());
RainbowFishSerializer.writeV1(fishV1, "fish1.out");
// Read V1
var deserializedRainbowFishV1 = RainbowFishSerializer.readV1("fish1.out");
LOGGER.info("deserializedFishV1 name={} age={} length={} weight={}",
deserializedRainbowFishV1.getName(), deserializedRainbowFishV1.getAge(),
deserializedRainbowFishV1.getLengthMeters(), deserializedRainbowFishV1.getWeightTons());
LOGGER.info(
"deserializedFishV1 name={} age={} length={} weight={}",
deserializedRainbowFishV1.getName(),
deserializedRainbowFishV1.getAge(),
deserializedRainbowFishV1.getLengthMeters(),
deserializedRainbowFishV1.getWeightTons());
// Write V2
var fishV2 = new RainbowFishV2("Scar", 5, 12, 15, true, true, true);
LOGGER.info(
"fishV2 name={} age={} length={} weight={} sleeping={} hungry={} angry={}",
fishV2.getName(), fishV2.getAge(), fishV2.getLengthMeters(), fishV2.getWeightTons(),
fishV2.isHungry(), fishV2.isAngry(), fishV2.isSleeping());
fishV2.getName(),
fishV2.getAge(),
fishV2.getLengthMeters(),
fishV2.getWeightTons(),
fishV2.isHungry(),
fishV2.isAngry(),
fishV2.isSleeping());
RainbowFishSerializer.writeV2(fishV2, "fish2.out");
// Read V2 with V1 method
var deserializedFishV2 = RainbowFishSerializer.readV1("fish2.out");
LOGGER.info("deserializedFishV2 name={} age={} length={} weight={}",
deserializedFishV2.getName(), deserializedFishV2.getAge(),
deserializedFishV2.getLengthMeters(), deserializedFishV2.getWeightTons());
LOGGER.info(
"deserializedFishV2 name={} age={} length={} weight={}",
deserializedFishV2.getName(),
deserializedFishV2.getAge(),
deserializedFishV2.getLengthMeters(),
deserializedFishV2.getWeightTons());
}
}
@@ -29,19 +29,15 @@ import java.io.Serializable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* RainbowFish is the initial schema.
*/
/** RainbowFish is the initial schema. */
@Getter
@RequiredArgsConstructor
public class RainbowFish implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;
private final String name;
private final int age;
private final int lengthMeters;
private final int weightTons;
}
@@ -44,51 +44,56 @@ public final class RainbowFishSerializer {
public static final String LENGTH_METERS = "lengthMeters";
public static final String WEIGHT_TONS = "weightTons";
/**
* Write V1 RainbowFish to file.
*/
/** Write V1 RainbowFish to file. */
public static void writeV1(RainbowFish rainbowFish, String filename) throws IOException {
var map = Map.of(
"name", rainbowFish.getName(),
"age", String.format("%d", rainbowFish.getAge()),
LENGTH_METERS, String.format("%d", rainbowFish.getLengthMeters()),
WEIGHT_TONS, String.format("%d", rainbowFish.getWeightTons())
);
var map =
Map.of(
"name",
rainbowFish.getName(),
"age",
String.format("%d", rainbowFish.getAge()),
LENGTH_METERS,
String.format("%d", rainbowFish.getLengthMeters()),
WEIGHT_TONS,
String.format("%d", rainbowFish.getWeightTons()));
try (var fileOut = new FileOutputStream(filename);
var objOut = new ObjectOutputStream(fileOut)) {
var objOut = new ObjectOutputStream(fileOut)) {
objOut.writeObject(map);
}
}
/**
* Write V2 RainbowFish to file.
*/
/** Write V2 RainbowFish to file. */
public static void writeV2(RainbowFishV2 rainbowFish, String filename) throws IOException {
var map = Map.of(
"name", rainbowFish.getName(),
"age", String.format("%d", rainbowFish.getAge()),
LENGTH_METERS, String.format("%d", rainbowFish.getLengthMeters()),
WEIGHT_TONS, String.format("%d", rainbowFish.getWeightTons()),
"angry", Boolean.toString(rainbowFish.isAngry()),
"hungry", Boolean.toString(rainbowFish.isHungry()),
"sleeping", Boolean.toString(rainbowFish.isSleeping())
);
var map =
Map.of(
"name",
rainbowFish.getName(),
"age",
String.format("%d", rainbowFish.getAge()),
LENGTH_METERS,
String.format("%d", rainbowFish.getLengthMeters()),
WEIGHT_TONS,
String.format("%d", rainbowFish.getWeightTons()),
"angry",
Boolean.toString(rainbowFish.isAngry()),
"hungry",
Boolean.toString(rainbowFish.isHungry()),
"sleeping",
Boolean.toString(rainbowFish.isSleeping()));
try (var fileOut = new FileOutputStream(filename);
var objOut = new ObjectOutputStream(fileOut)) {
var objOut = new ObjectOutputStream(fileOut)) {
objOut.writeObject(map);
}
}
/**
* Read V1 RainbowFish from file.
*/
/** Read V1 RainbowFish from file. */
public static RainbowFish readV1(String filename) throws IOException, ClassNotFoundException {
Map<String, String> map;
try (var fileIn = new FileInputStream(filename);
var objIn = new ObjectInputStream(fileIn)) {
var objIn = new ObjectInputStream(fileIn)) {
map = (Map<String, String>) objIn.readObject();
}
@@ -96,7 +101,6 @@ public final class RainbowFishSerializer {
map.get("name"),
Integer.parseInt(map.get("age")),
Integer.parseInt(map.get(LENGTH_METERS)),
Integer.parseInt(map.get(WEIGHT_TONS))
);
Integer.parseInt(map.get(WEIGHT_TONS)));
}
}
@@ -27,14 +27,11 @@ package com.iluwatar.tolerantreader;
import java.io.Serial;
import lombok.Getter;
/**
* RainbowFishV2 is the evolved schema.
*/
/** RainbowFishV2 is the evolved schema. */
@Getter
public class RainbowFishV2 extends RainbowFish {
@Serial
private static final long serialVersionUID = 1L;
@Serial private static final long serialVersionUID = 1L;
private boolean sleeping;
private boolean hungry;
@@ -44,15 +41,18 @@ public class RainbowFishV2 extends RainbowFish {
super(name, age, lengthMeters, weightTons);
}
/**
* Constructor.
*/
public RainbowFishV2(String name, int age, int lengthMeters, int weightTons, boolean sleeping,
boolean hungry, boolean angry) {
/** Constructor. */
public RainbowFishV2(
String name,
int age,
int lengthMeters,
int weightTons,
boolean sleeping,
boolean hungry,
boolean angry) {
this(name, age, lengthMeters, weightTons);
this.sleeping = sleeping;
this.hungry = hungry;
this.angry = angry;
}
}
@@ -31,14 +31,12 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Application test
*/
/** Application test */
class AppTest {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
@BeforeEach
@@ -34,37 +34,24 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
/**
* RainbowFishSerializerTest
*
*/
/** RainbowFishSerializerTest */
class RainbowFishSerializerTest {
/**
* Create a temporary folder, used to generate files in during this test
*/
@TempDir
static Path testFolder;
/** Create a temporary folder, used to generate files in during this test */
@TempDir static Path testFolder;
@BeforeEach
void beforeEach() {
assertTrue(Files.isDirectory(testFolder));
}
/**
* Rainbow fish version 1 used during the tests
*/
/** Rainbow fish version 1 used during the tests */
private static final RainbowFish V1 = new RainbowFish("version1", 1, 2, 3);
/**
* Rainbow fish version 2 used during the tests
*/
/** Rainbow fish version 2 used during the tests */
private static final RainbowFishV2 V2 = new RainbowFishV2("version2", 4, 5, 6, true, false, true);
/**
* Verify if a fish, written as version 1 can be read back as version 1
*/
/** Verify if a fish, written as version 1 can be read back as version 1 */
@Test
void testWriteV1ReadV1() throws Exception {
final var outputPath = Files.createFile(testFolder.resolve("outputFile"));
@@ -76,12 +63,9 @@ class RainbowFishSerializerTest {
assertEquals(V1.getAge(), fish.getAge());
assertEquals(V1.getLengthMeters(), fish.getLengthMeters());
assertEquals(V1.getWeightTons(), fish.getWeightTons());
}
/**
* Verify if a fish, written as version 2 can be read back as version 1
*/
/** Verify if a fish, written as version 2 can be read back as version 1 */
@Test
void testWriteV2ReadV1() throws Exception {
final var outputPath = Files.createFile(testFolder.resolve("outputFile2"));
@@ -94,5 +78,4 @@ class RainbowFishSerializerTest {
assertEquals(V2.getLengthMeters(), fish.getLengthMeters());
assertEquals(V2.getWeightTons(), fish.getWeightTons());
}
}
@@ -28,15 +28,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
* RainbowFishTest
*
*/
/** RainbowFishTest */
class RainbowFishTest {
/**
* Verify if the getters of a {@link RainbowFish} return the expected values
*/
/** Verify if the getters of a {@link RainbowFish} return the expected values */
@Test
void testValues() {
final var fish = new RainbowFish("name", 1, 2, 3);
@@ -45,5 +40,4 @@ class RainbowFishTest {
assertEquals(2, fish.getLengthMeters());
assertEquals(3, fish.getWeightTons());
}
}
}
@@ -30,15 +30,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* RainbowFishV2Test
*
*/
/** RainbowFishV2Test */
class RainbowFishV2Test {
/**
* Verify if the getters of a {@link RainbowFish} return the expected values
*/
/** Verify if the getters of a {@link RainbowFish} return the expected values */
@Test
void testValues() {
final var fish = new RainbowFishV2("name", 1, 2, 3, false, true, false);
@@ -50,5 +45,4 @@ class RainbowFishV2Test {
assertTrue(fish.isHungry());
assertFalse(fish.isAngry());
}
}
}