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 14408 additions and 17637 deletions
@@ -58,22 +58,27 @@ public class App {
*/
public static void main(String[] args) {
var mage = new Hero.Builder(Profession.MAGE, "Riobard")
.withHairColor(HairColor.BLACK)
.withWeapon(Weapon.DAGGER)
.build();
var mage =
new Hero.Builder(Profession.MAGE, "Riobard")
.withHairColor(HairColor.BLACK)
.withWeapon(Weapon.DAGGER)
.build();
LOGGER.info(mage.toString());
var warrior = new Hero.Builder(Profession.WARRIOR, "Amberjill")
.withHairColor(HairColor.BLOND)
.withHairType(HairType.LONG_CURLY).withArmor(Armor.CHAIN_MAIL).withWeapon(Weapon.SWORD)
.build();
var warrior =
new Hero.Builder(Profession.WARRIOR, "Amberjill")
.withHairColor(HairColor.BLOND)
.withHairType(HairType.LONG_CURLY)
.withArmor(Armor.CHAIN_MAIL)
.withWeapon(Weapon.SWORD)
.build();
LOGGER.info(warrior.toString());
var thief = new Hero.Builder(Profession.THIEF, "Desmond")
.withHairType(HairType.BALD)
.withWeapon(Weapon.BOW)
.build();
var thief =
new Hero.Builder(Profession.THIEF, "Desmond")
.withHairType(HairType.BALD)
.withWeapon(Weapon.BOW)
.build();
LOGGER.info(thief.toString());
}
}
@@ -26,12 +26,9 @@ package com.iluwatar.builder;
import lombok.AllArgsConstructor;
/**
* Armor enumeration.
*/
/** Armor enumeration. */
@AllArgsConstructor
public enum Armor {
CLOTHES("clothes"),
LEATHER("leather"),
CHAIN_MAIL("chain mail"),
@@ -24,11 +24,8 @@
*/
package com.iluwatar.builder;
/**
* HairColor enumeration.
*/
/** HairColor enumeration. */
public enum HairColor {
WHITE,
BLOND,
RED,
@@ -39,5 +36,4 @@ public enum HairColor {
public String toString() {
return name().toLowerCase();
}
}
@@ -26,12 +26,9 @@ package com.iluwatar.builder;
import lombok.AllArgsConstructor;
/**
* HairType enumeration.
*/
/** HairType enumeration. */
@AllArgsConstructor
public enum HairType {
BALD("bald"),
SHORT("short"),
CURLY("curly"),
@@ -24,24 +24,30 @@
*/
package com.iluwatar.builder;
/**
* Hero,the record class.
*/
public record Hero(Profession profession, String name, HairType hairType, HairColor hairColor, Armor armor, Weapon weapon) {
/** Hero,the record class. */
public record Hero(
Profession profession,
String name,
HairType hairType,
HairColor hairColor,
Armor armor,
Weapon weapon) {
private Hero(Builder builder) {
this(builder.profession, builder.name, builder.hairType, builder.hairColor, builder.armor, builder.weapon);
this(
builder.profession,
builder.name,
builder.hairType,
builder.hairColor,
builder.armor,
builder.weapon);
}
@Override
public String toString() {
var sb = new StringBuilder();
sb.append("This is a ")
.append(profession)
.append(" named ")
.append(name);
sb.append("This is a ").append(profession).append(" named ").append(name);
if (hairColor != null || hairType != null) {
sb.append(" with ");
if (hairColor != null) {
@@ -62,9 +68,7 @@ public record Hero(Profession profession, String name, HairType hairType, HairCo
return sb.toString();
}
/**
* The builder class.
*/
/** The builder class. */
public static class Builder {
private final Profession profession;
@@ -74,9 +78,7 @@ public record Hero(Profession profession, String name, HairType hairType, HairCo
private Armor armor;
private Weapon weapon;
/**
* Constructor.
*/
/** Constructor. */
public Builder(Profession profession, String name) {
if (profession == null || name == null) {
throw new IllegalArgumentException("profession and name can not be null");
@@ -24,12 +24,12 @@
*/
package com.iluwatar.builder;
/**
* Profession enumeration.
*/
/** Profession enumeration. */
public enum Profession {
WARRIOR, THIEF, MAGE, PRIEST;
WARRIOR,
THIEF,
MAGE,
PRIEST;
@Override
public String toString() {
@@ -24,12 +24,13 @@
*/
package com.iluwatar.builder;
/**
* Weapon enumeration.
*/
/** Weapon enumeration. */
public enum Weapon {
DAGGER, SWORD, AXE, WARHAMMER, BOW;
DAGGER,
SWORD,
AXE,
WARHAMMER,
BOW;
@Override
public String toString() {
@@ -24,24 +24,21 @@
*/
package com.iluwatar.builder;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
/**
* Application test
*/
import org.junit.jupiter.api.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(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -30,41 +30,33 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
/**
* HeroTest
*
*/
/** HeroTest */
class HeroTest {
/**
* Test if we get the expected exception when trying to create a hero without a profession
*/
/** Test if we get the expected exception when trying to create a hero without a profession */
@Test
void testMissingProfession() {
assertThrows(IllegalArgumentException.class, () -> new Hero.Builder(null, "Sir without a job"));
}
/**
* Test if we get the expected exception when trying to create a hero without a name
*/
/** Test if we get the expected exception when trying to create a hero without a name */
@Test
void testMissingName() {
assertThrows(IllegalArgumentException.class, () -> new Hero.Builder(Profession.THIEF, null));
}
/**
* Test if the hero build by the builder has the correct attributes, as requested
*/
/** Test if the hero build by the builder has the correct attributes, as requested */
@Test
void testBuildHero() {
final String heroName = "Sir Lancelot";
final var hero = new Hero.Builder(Profession.WARRIOR, heroName)
.withArmor(Armor.CHAIN_MAIL)
.withWeapon(Weapon.SWORD)
.withHairType(HairType.LONG_CURLY)
.withHairColor(HairColor.BLOND)
.build();
final var hero =
new Hero.Builder(Profession.WARRIOR, heroName)
.withArmor(Armor.CHAIN_MAIL)
.withWeapon(Weapon.SWORD)
.withHairType(HairType.LONG_CURLY)
.withHairColor(HairColor.BLOND)
.build();
assertNotNull(hero);
assertNotNull(hero.toString());
@@ -74,7 +66,5 @@ class HeroTest {
assertEquals(Weapon.SWORD, hero.weapon());
assertEquals(HairType.LONG_CURLY, hero.hairType());
assertEquals(HairColor.BLOND, hero.hairColor());
}
}
}