mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-20 07:26:49 +00:00
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:
@@ -28,13 +28,11 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Application test
|
||||
*/
|
||||
/** Application test */
|
||||
class AppTest {
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,37 +24,38 @@
|
||||
*/
|
||||
package crtp;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Slf4j
|
||||
public class FightTest {
|
||||
|
||||
/**
|
||||
* A fighter has signed a contract with a promotion, and he will face some other fighters. A list of opponents is ready
|
||||
* but for some reason not all of them belong to the same weight class. Let's ensure that the fighter will only face
|
||||
* opponents in the same weight class.
|
||||
* A fighter has signed a contract with a promotion, and he will face some other fighters. A list
|
||||
* of opponents is ready but for some reason not all of them belong to the same weight class.
|
||||
* Let's ensure that the fighter will only face opponents in the same weight class.
|
||||
*/
|
||||
@Test
|
||||
void testFighterCanFightOnlyAgainstSameWeightOpponents() {
|
||||
MmaBantamweightFighter fighter = new MmaBantamweightFighter("Joe", "Johnson", "The Geek", "Muay Thai");
|
||||
MmaBantamweightFighter fighter =
|
||||
new MmaBantamweightFighter("Joe", "Johnson", "The Geek", "Muay Thai");
|
||||
List<MmaFighter<?>> opponents = getOpponents();
|
||||
List<MmaFighter<?>> challenged = new ArrayList<>();
|
||||
|
||||
opponents.forEach(challenger -> {
|
||||
try {
|
||||
((MmaBantamweightFighter) challenger).fight(fighter);
|
||||
challenged.add(challenger);
|
||||
} catch (ClassCastException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
});
|
||||
opponents.forEach(
|
||||
challenger -> {
|
||||
try {
|
||||
((MmaBantamweightFighter) challenger).fight(fighter);
|
||||
challenged.add(challenger);
|
||||
} catch (ClassCastException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
assertFalse(challenged.isEmpty());
|
||||
assertTrue(challenged.stream().allMatch(c -> c instanceof MmaBantamweightFighter));
|
||||
@@ -62,13 +63,10 @@ public class FightTest {
|
||||
|
||||
private static List<MmaFighter<?>> getOpponents() {
|
||||
return List.of(
|
||||
new MmaBantamweightFighter("Ed", "Edwards", "The Problem Solver", "Judo"),
|
||||
new MmaLightweightFighter("Evan", "Evans", "Clean Coder", "Sambo"),
|
||||
new MmaHeavyweightFighter("Dave", "Davidson", "The Bug Smasher", "Kickboxing"),
|
||||
new MmaBantamweightFighter("Ray", "Raymond", "Scrum Master", "Karate"),
|
||||
new MmaHeavyweightFighter("Jack", "Jackson", "The Pragmatic", "Brazilian Jiu-Jitsu")
|
||||
);
|
||||
new MmaBantamweightFighter("Ed", "Edwards", "The Problem Solver", "Judo"),
|
||||
new MmaLightweightFighter("Evan", "Evans", "Clean Coder", "Sambo"),
|
||||
new MmaHeavyweightFighter("Dave", "Davidson", "The Bug Smasher", "Kickboxing"),
|
||||
new MmaBantamweightFighter("Ray", "Raymond", "Scrum Master", "Karate"),
|
||||
new MmaHeavyweightFighter("Jack", "Jackson", "The Pragmatic", "Brazilian Jiu-Jitsu"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user