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
@@ -25,43 +25,40 @@
package com.iluwatar.strangler;
/**
* The Strangler pattern is a software design pattern that incrementally migrate a legacy system by
* gradually replacing specific pieces of functionality with new applications and services. As
* features from the legacy system are replaced, the new system eventually replaces all of the old
* system's features, strangling the old system and allowing you to decommission it.
*
* <p>The Strangler pattern is a software design pattern that incrementally migrate a legacy
* system by gradually replacing specific pieces of functionality with new applications and
* services. As features from the legacy system are replaced, the new system eventually
* replaces all of the old system's features, strangling the old system and allowing you
* to decommission it.</p>
*
* <p>This pattern is not only about updating but also enhancement.</p>
*
* <p>In this example, {@link OldArithmetic} indicates old system and its implementation depends
* on its source ({@link OldSource}). Now we tend to update system with new techniques and
* new features. In reality, the system may too complex, so usually need gradual migration.
* {@link HalfArithmetic} indicates system in the process of migration, its implementation
* depends on old one ({@link OldSource}) and under development one ({@link HalfSource}). The
* {@link HalfSource} covers part of {@link OldSource} and add new functionality. You can release
* this version system with new features, which also supports old version system functionalities.
* After whole migration, the new system ({@link NewArithmetic}) only depends on new source
* ({@link NewSource}).</p>
* <p>This pattern is not only about updating but also enhancement.
*
* <p>In this example, {@link OldArithmetic} indicates old system and its implementation depends on
* its source ({@link OldSource}). Now we tend to update system with new techniques and new
* features. In reality, the system may too complex, so usually need gradual migration. {@link
* HalfArithmetic} indicates system in the process of migration, its implementation depends on old
* one ({@link OldSource}) and under development one ({@link HalfSource}). The {@link HalfSource}
* covers part of {@link OldSource} and add new functionality. You can release this version system
* with new features, which also supports old version system functionalities. After whole migration,
* the new system ({@link NewArithmetic}) only depends on new source ({@link NewSource}).
*/
public class App {
/**
* Program entry point.
*
* @param args command line args
*/
public static void main(final String[] args) {
final var nums = new int[]{1, 2, 3, 4, 5};
//Before migration
final var nums = new int[] {1, 2, 3, 4, 5};
// Before migration
final var oldSystem = new OldArithmetic(new OldSource());
oldSystem.sum(nums);
oldSystem.mul(nums);
//In process of migration
// In process of migration
final var halfSystem = new HalfArithmetic(new HalfSource(), new OldSource());
halfSystem.sum(nums);
halfSystem.mul(nums);
halfSystem.ifHasZero(nums);
//After migration
// After migration
final var newSystem = new NewArithmetic(new NewSource());
newSystem.sum(nums);
newSystem.mul(nums);
@@ -27,8 +27,8 @@ package com.iluwatar.strangler;
import lombok.extern.slf4j.Slf4j;
/**
* System under migration. Depends on old version source ({@link OldSource}) and
* developing one ({@link HalfSource}).
* System under migration. Depends on old version source ({@link OldSource}) and developing one
* ({@link HalfSource}).
*/
@Slf4j
public class HalfArithmetic {
@@ -44,6 +44,7 @@ public class HalfArithmetic {
/**
* Accumulate sum.
*
* @param nums numbers need to add together
* @return accumulate sum
*/
@@ -54,6 +55,7 @@ public class HalfArithmetic {
/**
* Accumulate multiplication.
*
* @param nums numbers need to multiply together
* @return accumulate multiplication
*/
@@ -64,6 +66,7 @@ public class HalfArithmetic {
/**
* Check if it has any zero.
*
* @param nums numbers need to check
* @return if it has any zero, return true, else, return false
*/
@@ -27,26 +27,18 @@ package com.iluwatar.strangler;
import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
/**
* Source under development. Replace part of old source and has added some new features.
*/
/** Source under development. Replace part of old source and has added some new features. */
@Slf4j
public class HalfSource {
private static final String VERSION = "1.5";
/**
* Implement accumulate sum with new technique.
* Replace old one in {@link OldSource}
*/
/** Implement accumulate sum with new technique. Replace old one in {@link OldSource} */
public int accumulateSum(int... nums) {
LOGGER.info("Source module {}", VERSION);
return Arrays.stream(nums).reduce(0, Integer::sum);
}
/**
* Check if all number is not zero.
* New feature.
*/
/** Check if all number is not zero. New feature. */
public boolean ifNonZero(int... nums) {
LOGGER.info("Source module {}", VERSION);
return Arrays.stream(nums).allMatch(num -> num != 0);
@@ -26,9 +26,7 @@ package com.iluwatar.strangler;
import lombok.extern.slf4j.Slf4j;
/**
* System after whole migration. Only depends on new version source ({@link NewSource}).
*/
/** System after whole migration. Only depends on new version source ({@link NewSource}). */
@Slf4j
public class NewArithmetic {
private static final String VERSION = "2.0";
@@ -41,6 +39,7 @@ public class NewArithmetic {
/**
* Accumulate sum.
*
* @param nums numbers need to add together
* @return accumulate sum
*/
@@ -51,6 +50,7 @@ public class NewArithmetic {
/**
* Accumulate multiplication.
*
* @param nums numbers need to multiply together
* @return accumulate multiplication
*/
@@ -61,6 +61,7 @@ public class NewArithmetic {
/**
* Check if it has any zero.
*
* @param nums numbers need to check
* @return if it has any zero, return true, else, return false
*/
@@ -28,8 +28,8 @@ import java.util.Arrays;
import lombok.extern.slf4j.Slf4j;
/**
* New source. Completely covers functionalities of old source with new techniques
* and also has some new features.
* New source. Completely covers functionalities of old source with new techniques and also has some
* new features.
*/
@Slf4j
public class NewSource {
@@ -41,10 +41,7 @@ public class NewSource {
return Arrays.stream(nums).reduce(0, Integer::sum);
}
/**
* Implement accumulate multiply with new technique.
* Replace old one in {@link OldSource}
*/
/** Implement accumulate multiply with new technique. Replace old one in {@link OldSource} */
public int accumulateMul(int... nums) {
LOGGER.info(SOURCE_MODULE, VERSION);
return Arrays.stream(nums).reduce(1, (a, b) -> a * b);
@@ -26,9 +26,7 @@ package com.iluwatar.strangler;
import lombok.extern.slf4j.Slf4j;
/**
* Old version system depends on old version source ({@link OldSource}).
*/
/** Old version system depends on old version source ({@link OldSource}). */
@Slf4j
public class OldArithmetic {
private static final String VERSION = "1.0";
@@ -41,6 +39,7 @@ public class OldArithmetic {
/**
* Accumulate sum.
*
* @param nums numbers need to add together
* @return accumulate sum
*/
@@ -51,6 +50,7 @@ public class OldArithmetic {
/**
* Accumulate multiplication.
*
* @param nums numbers need to multiply together
* @return accumulate multiplication
*/
@@ -26,16 +26,12 @@ package com.iluwatar.strangler;
import lombok.extern.slf4j.Slf4j;
/**
* Old source with techniques out of date.
*/
/** Old source with techniques out of date. */
@Slf4j
public class OldSource {
private static final String VERSION = "1.0";
/**
* Implement accumulate sum with old technique.
*/
/** Implement accumulate sum with old technique. */
public int accumulateSum(int... nums) {
LOGGER.info("Source module {}", VERSION);
var sum = 0;
@@ -45,9 +41,7 @@ public class OldSource {
return sum;
}
/**
* Implement accumulate multiply with old technique.
*/
/** Implement accumulate multiply with old technique. */
public int accumulateMul(int... nums) {
LOGGER.info("Source module {}", VERSION);
var sum = 1;
@@ -24,17 +24,15 @@
*/
package com.iluwatar.strangler;
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 {
@Test
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -29,11 +29,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Test methods in HalfArithmetic
*/
/** Test methods in HalfArithmetic */
class HalfArithmeticTest {
private static final HalfArithmetic arithmetic = new HalfArithmetic(new HalfSource(), new OldSource());
private static final HalfArithmetic arithmetic =
new HalfArithmetic(new HalfSource(), new OldSource());
@Test
void testSum() {
@@ -49,4 +48,4 @@ class HalfArithmeticTest {
void testIfHasZero() {
assertTrue(arithmetic.ifHasZero(-1, 0, 1));
}
}
}
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* Test methods in HalfSource
*/
/** Test methods in HalfSource */
class HalfSourceTest {
private static final HalfSource source = new HalfSource();
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Test methods in NewArithmetic
*/
/** Test methods in NewArithmetic */
class NewArithmeticTest {
private static final NewArithmetic arithmetic = new NewArithmetic(new NewSource());
@@ -49,4 +47,4 @@ class NewArithmeticTest {
void testIfHasZero() {
assertTrue(arithmetic.ifHasZero(-1, 0, 1));
}
}
}
@@ -29,9 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* Test methods in NewSource
*/
/** Test methods in NewSource */
class NewSourceTest {
private static final NewSource source = new NewSource();
@@ -28,9 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
* Test methods in OldArithmetic
*/
/** Test methods in OldArithmetic */
class OldArithmeticTest {
private static final OldArithmetic arithmetic = new OldArithmetic(new OldSource());
@@ -43,4 +41,4 @@ class OldArithmeticTest {
void testMul() {
assertEquals(0, arithmetic.mul(-1, 0, 1));
}
}
}
@@ -28,9 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
* Test methods in OldSource
*/
/** Test methods in OldSource */
class OldSourceTest {
private static final OldSource source = new OldSource();