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
@@ -24,24 +24,19 @@
*/
package com.iluwatar.doubledispatch;
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#main(String[])}
* throws an exception.
* 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#main(String[])} throws an exception.
*/
@Test
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
assertDoesNotThrow(() -> App.main(new String[] {}));
}
}
@@ -46,14 +46,18 @@ public abstract class CollisionTest<O extends GameObject> {
* Collide the tested item with the other given item and verify if the damage and fire state is as
* expected
*
* @param other The other object we have to collide with
* @param other The other object we have to collide with
* @param otherDamaged Indicates if the other object should be damaged after the collision
* @param otherOnFire Indicates if the other object should be burning after the collision
* @param thisDamaged Indicates if the test object should be damaged after the collision
* @param thisOnFire Indicates if the other object should be burning after the collision
* @param otherOnFire Indicates if the other object should be burning after the collision
* @param thisDamaged Indicates if the test object should be damaged after the collision
* @param thisOnFire Indicates if the other object should be burning after the collision
*/
void testCollision(final GameObject other, final boolean otherDamaged, final boolean otherOnFire,
final boolean thisDamaged, final boolean thisOnFire) {
void testCollision(
final GameObject other,
final boolean otherDamaged,
final boolean otherOnFire,
final boolean thisDamaged,
final boolean thisOnFire) {
Objects.requireNonNull(other);
Objects.requireNonNull(getTestedObject());
@@ -67,24 +71,33 @@ public abstract class CollisionTest<O extends GameObject> {
testOnFire(tested, other, thisOnFire);
testDamaged(tested, other, thisDamaged);
}
/**
* Test if the fire state of the target matches the expected state after colliding with the given
* object
*
* @param target The target object
* @param other The other object
* @param target The target object
* @param other The other object
* @param expectTargetOnFire The expected state of fire on the target object
*/
private void testOnFire(final GameObject target, final GameObject other, final boolean expectTargetOnFire) {
private void testOnFire(
final GameObject target, final GameObject other, final boolean expectTargetOnFire) {
final var targetName = target.getClass().getSimpleName();
final var otherName = other.getClass().getSimpleName();
final var errorMessage = expectTargetOnFire
? "Expected [" + targetName + "] to be on fire after colliding with [" + otherName + "] but it was not!"
: "Expected [" + targetName + "] not to be on fire after colliding with [" + otherName + "] but it was!";
final var errorMessage =
expectTargetOnFire
? "Expected ["
+ targetName
+ "] to be on fire after colliding with ["
+ otherName
+ "] but it was not!"
: "Expected ["
+ targetName
+ "] not to be on fire after colliding with ["
+ otherName
+ "] but it was!";
assertEquals(expectTargetOnFire, target.isOnFire(), errorMessage);
}
@@ -93,19 +106,28 @@ public abstract class CollisionTest<O extends GameObject> {
* Test if the damage state of the target matches the expected state after colliding with the
* given object
*
* @param target The target object
* @param other The other object
* @param target The target object
* @param other The other object
* @param expectedDamage The expected state of damage on the target object
*/
private void testDamaged(final GameObject target, final GameObject other, final boolean expectedDamage) {
private void testDamaged(
final GameObject target, final GameObject other, final boolean expectedDamage) {
final var targetName = target.getClass().getSimpleName();
final var otherName = other.getClass().getSimpleName();
final var errorMessage = expectedDamage
? "Expected [" + targetName + "] to be damaged after colliding with [" + otherName + "] but it was not!"
: "Expected [" + targetName + "] not to be damaged after colliding with [" + otherName + "] but it was!";
final var errorMessage =
expectedDamage
? "Expected ["
+ targetName
+ "] to be damaged after colliding with ["
+ otherName
+ "] but it was not!"
: "Expected ["
+ targetName
+ "] not to be damaged after colliding with ["
+ otherName
+ "] but it was!";
assertEquals(expectedDamage, target.isDamaged(), errorMessage);
}
}
@@ -30,10 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* FlamingAsteroidTest
*
*/
/** FlamingAsteroidTest */
class FlamingAsteroidTest extends CollisionTest<FlamingAsteroid> {
@Override
@@ -41,9 +38,7 @@ class FlamingAsteroidTest extends CollisionTest<FlamingAsteroid> {
return new FlamingAsteroid(1, 2, 3, 4);
}
/**
* Test the constructor parameters
*/
/** Test the constructor parameters */
@Test
void testConstructor() {
final var asteroid = new FlamingAsteroid(1, 2, 3, 4);
@@ -56,52 +51,27 @@ class FlamingAsteroidTest extends CollisionTest<FlamingAsteroid> {
assertEquals("FlamingAsteroid at [1,2,3,4] damaged=false onFire=true", asteroid.toString());
}
/**
* Test what happens we collide with an asteroid
*/
/** Test what happens we collide with an asteroid */
@Test
void testCollideFlamingAsteroid() {
testCollision(
new FlamingAsteroid(1, 2, 3, 4),
false, true,
false, true
);
testCollision(new FlamingAsteroid(1, 2, 3, 4), false, true, false, true);
}
/**
* Test what happens we collide with an meteoroid
*/
/** Test what happens we collide with an meteoroid */
@Test
void testCollideMeteoroid() {
testCollision(
new Meteoroid(1, 1, 3, 4),
false, false,
false, true
);
testCollision(new Meteoroid(1, 1, 3, 4), false, false, false, true);
}
/**
* Test what happens we collide with ISS
*/
/** Test what happens we collide with ISS */
@Test
void testCollideSpaceStationIss() {
testCollision(
new SpaceStationIss(1, 1, 3, 4),
true, true,
false, true
);
testCollision(new SpaceStationIss(1, 1, 3, 4), true, true, false, true);
}
/**
* Test what happens we collide with MIR
*/
/** Test what happens we collide with MIR */
@Test
void testCollideSpaceStationMir() {
testCollision(
new SpaceStationMir(1, 1, 3, 4),
true, true,
false, true
);
testCollision(new SpaceStationMir(1, 1, 3, 4), true, true, false, true);
}
}
}
@@ -29,10 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* MeteoroidTest
*
*/
/** MeteoroidTest */
class MeteoroidTest extends CollisionTest<Meteoroid> {
@Override
@@ -40,9 +37,7 @@ class MeteoroidTest extends CollisionTest<Meteoroid> {
return new Meteoroid(1, 2, 3, 4);
}
/**
* Test the constructor parameters
*/
/** Test the constructor parameters */
@Test
void testConstructor() {
final var meteoroid = new Meteoroid(1, 2, 3, 4);
@@ -55,52 +50,27 @@ class MeteoroidTest extends CollisionTest<Meteoroid> {
assertEquals("Meteoroid at [1,2,3,4] damaged=false onFire=false", meteoroid.toString());
}
/**
* Test what happens we collide with an asteroid
*/
/** Test what happens we collide with an asteroid */
@Test
void testCollideFlamingAsteroid() {
testCollision(
new FlamingAsteroid(1, 1, 3, 4),
false, true,
false, false
);
testCollision(new FlamingAsteroid(1, 1, 3, 4), false, true, false, false);
}
/**
* Test what happens we collide with an meteoroid
*/
/** Test what happens we collide with an meteoroid */
@Test
void testCollideMeteoroid() {
testCollision(
new Meteoroid(1, 1, 3, 4),
false, false,
false, false
);
testCollision(new Meteoroid(1, 1, 3, 4), false, false, false, false);
}
/**
* Test what happens we collide with ISS
*/
/** Test what happens we collide with ISS */
@Test
void testCollideSpaceStationIss() {
testCollision(
new SpaceStationIss(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationIss(1, 1, 3, 4), true, false, false, false);
}
/**
* Test what happens we collide with MIR
*/
/** Test what happens we collide with MIR */
@Test
void testCollideSpaceStationMir() {
testCollision(
new SpaceStationMir(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationMir(1, 1, 3, 4), true, false, false, false);
}
}
}
@@ -30,9 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
* Unit test for Rectangle
*/
/** Unit test for Rectangle */
class RectangleTest {
/**
@@ -48,8 +46,7 @@ class RectangleTest {
}
/**
* Test if the values passed through the constructor matches the values in the {@link
* #toString()}
* Test if the values passed through the constructor matches the values in the {@link #toString()}
*/
@Test
void testToString() {
@@ -57,9 +54,7 @@ class RectangleTest {
assertEquals("[1,2,3,4]", rectangle.toString());
}
/**
* Test if the {@link Rectangle} class can detect if it intersects with another rectangle.
*/
/** Test if the {@link Rectangle} class can detect if it intersects with another rectangle. */
@Test
void testIntersection() {
assertTrue(new Rectangle(0, 0, 1, 1).intersectsWith(new Rectangle(0, 0, 1, 1)));
@@ -67,5 +62,4 @@ class RectangleTest {
assertFalse(new Rectangle(0, 0, 1, 1).intersectsWith(new Rectangle(2, 2, 3, 3)));
assertFalse(new Rectangle(0, 0, 1, 1).intersectsWith(new Rectangle(-2, -2, -1, -1)));
}
}
@@ -29,10 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* SpaceStationIssTest
*
*/
/** SpaceStationIssTest */
class SpaceStationIssTest extends CollisionTest<SpaceStationIss> {
@Override
@@ -40,9 +37,7 @@ class SpaceStationIssTest extends CollisionTest<SpaceStationIss> {
return new SpaceStationIss(1, 2, 3, 4);
}
/**
* Test the constructor parameters
*/
/** Test the constructor parameters */
@Test
void testConstructor() {
final var iss = new SpaceStationIss(1, 2, 3, 4);
@@ -55,52 +50,27 @@ class SpaceStationIssTest extends CollisionTest<SpaceStationIss> {
assertEquals("SpaceStationIss at [1,2,3,4] damaged=false onFire=false", iss.toString());
}
/**
* Test what happens we collide with an asteroid
*/
/** Test what happens we collide with an asteroid */
@Test
void testCollideFlamingAsteroid() {
testCollision(
new FlamingAsteroid(1, 1, 3, 4),
false, true,
false, false
);
testCollision(new FlamingAsteroid(1, 1, 3, 4), false, true, false, false);
}
/**
* Test what happens we collide with an meteoroid
*/
/** Test what happens we collide with an meteoroid */
@Test
void testCollideMeteoroid() {
testCollision(
new Meteoroid(1, 1, 3, 4),
false, false,
false, false
);
testCollision(new Meteoroid(1, 1, 3, 4), false, false, false, false);
}
/**
* Test what happens we collide with ISS
*/
/** Test what happens we collide with ISS */
@Test
void testCollideSpaceStationIss() {
testCollision(
new SpaceStationIss(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationIss(1, 1, 3, 4), true, false, false, false);
}
/**
* Test what happens we collide with MIR
*/
/** Test what happens we collide with MIR */
@Test
void testCollideSpaceStationMir() {
testCollision(
new SpaceStationMir(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationMir(1, 1, 3, 4), true, false, false, false);
}
}
}
@@ -29,10 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;
/**
* SpaceStationMirTest
*
*/
/** SpaceStationMirTest */
class SpaceStationMirTest extends CollisionTest<SpaceStationMir> {
@Override
@@ -40,9 +37,7 @@ class SpaceStationMirTest extends CollisionTest<SpaceStationMir> {
return new SpaceStationMir(1, 2, 3, 4);
}
/**
* Test the constructor parameters
*/
/** Test the constructor parameters */
@Test
void testConstructor() {
final var mir = new SpaceStationMir(1, 2, 3, 4);
@@ -55,52 +50,27 @@ class SpaceStationMirTest extends CollisionTest<SpaceStationMir> {
assertEquals("SpaceStationMir at [1,2,3,4] damaged=false onFire=false", mir.toString());
}
/**
* Test what happens we collide with an asteroid
*/
/** Test what happens we collide with an asteroid */
@Test
void testCollideFlamingAsteroid() {
testCollision(
new FlamingAsteroid(1, 1, 3, 4),
false, true,
false, false
);
testCollision(new FlamingAsteroid(1, 1, 3, 4), false, true, false, false);
}
/**
* Test what happens we collide with an meteoroid
*/
/** Test what happens we collide with an meteoroid */
@Test
void testCollideMeteoroid() {
testCollision(
new Meteoroid(1, 1, 3, 4),
false, false,
false, false
);
testCollision(new Meteoroid(1, 1, 3, 4), false, false, false, false);
}
/**
* Test what happens we collide with ISS
*/
/** Test what happens we collide with ISS */
@Test
void testCollideSpaceStationIss() {
testCollision(
new SpaceStationIss(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationIss(1, 1, 3, 4), true, false, false, false);
}
/**
* Test what happens we collide with MIR
*/
/** Test what happens we collide with MIR */
@Test
void testCollideSpaceStationMir() {
testCollision(
new SpaceStationMir(1, 1, 3, 4),
true, false,
false, false
);
testCollision(new SpaceStationMir(1, 1, 3, 4), true, false, false, false);
}
}
}