mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-11 02:22:34 +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:
@@ -35,9 +35,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* have their own class hierarchies. The interface of the implementations can be changed without
|
||||
* affecting the clients.
|
||||
*
|
||||
* <p>In this example we have two class hierarchies. One of weapons and another one of
|
||||
* enchantments. We can easily combine any weapon with any enchantment using composition instead of
|
||||
* creating deep class hierarchy.
|
||||
* <p>In this example we have two class hierarchies. One of weapons and another one of enchantments.
|
||||
* We can easily combine any weapon with any enchantment using composition instead of creating deep
|
||||
* class hierarchy.
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.bridge;
|
||||
|
||||
/**
|
||||
* Enchantment.
|
||||
*/
|
||||
/** Enchantment. */
|
||||
public interface Enchantment {
|
||||
|
||||
void onActivate();
|
||||
|
||||
@@ -26,9 +26,7 @@ package com.iluwatar.bridge;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* FlyingEnchantment.
|
||||
*/
|
||||
/** FlyingEnchantment. */
|
||||
@Slf4j
|
||||
public class FlyingEnchantment implements Enchantment {
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ package com.iluwatar.bridge;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Hammer.
|
||||
*/
|
||||
/** Hammer. */
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class Hammer implements Weapon {
|
||||
|
||||
@@ -26,9 +26,7 @@ package com.iluwatar.bridge;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* SoulEatingEnchantment.
|
||||
*/
|
||||
/** SoulEatingEnchantment. */
|
||||
@Slf4j
|
||||
public class SoulEatingEnchantment implements Enchantment {
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ package com.iluwatar.bridge;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Sword.
|
||||
*/
|
||||
/** Sword. */
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class Sword implements Weapon {
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.bridge;
|
||||
|
||||
/**
|
||||
* Weapon.
|
||||
*/
|
||||
/** Weapon. */
|
||||
public interface Weapon {
|
||||
|
||||
void wield();
|
||||
|
||||
@@ -24,24 +24,21 @@
|
||||
*/
|
||||
package com.iluwatar.bridge;
|
||||
|
||||
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[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ import static org.mockito.Mockito.spy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for hammer
|
||||
*/
|
||||
/** Tests for hammer */
|
||||
class HammerTest extends WeaponTest {
|
||||
|
||||
/**
|
||||
@@ -43,4 +41,4 @@ class HammerTest extends WeaponTest {
|
||||
final var hammer = spy(new Hammer(mock(FlyingEnchantment.class)));
|
||||
testBasicWeaponActions(hammer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ import static org.mockito.Mockito.spy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for sword
|
||||
*/
|
||||
/** Tests for sword */
|
||||
class SwordTest extends WeaponTest {
|
||||
|
||||
/**
|
||||
@@ -43,4 +41,4 @@ class SwordTest extends WeaponTest {
|
||||
final var sword = spy(new Sword(mock(FlyingEnchantment.class)));
|
||||
testBasicWeaponActions(sword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
/**
|
||||
* Base class for weapon tests
|
||||
*/
|
||||
/** Base class for weapon tests */
|
||||
abstract class WeaponTest {
|
||||
|
||||
/**
|
||||
@@ -54,6 +52,5 @@ abstract class WeaponTest {
|
||||
weapon.unwield();
|
||||
verify(enchantment).onDeactivate();
|
||||
verifyNoMoreInteractions(enchantment);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user