mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-05 14:23:52 +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:
@@ -37,16 +37,15 @@ package com.iluwatar.adapter;
|
||||
* <p>The Adapter ({@link FishingBoatAdapter}) converts the interface of the adaptee class ({@link
|
||||
* FishingBoat}) into a suitable one expected by the client ({@link RowingBoat}).
|
||||
*
|
||||
* <p>The story of this implementation is this. <br> Pirates are coming! we need a {@link
|
||||
* RowingBoat} to flee! We have a {@link FishingBoat} and our captain. We have no time to make up a
|
||||
* new ship! we need to reuse this {@link FishingBoat}. The captain needs a rowing boat which he can
|
||||
* operate. The spec is in {@link RowingBoat}. We will use the Adapter pattern to reuse {@link
|
||||
* FishingBoat}.
|
||||
* <p>The story of this implementation is this. <br>
|
||||
* Pirates are coming! we need a {@link RowingBoat} to flee! We have a {@link FishingBoat} and our
|
||||
* captain. We have no time to make up a new ship! we need to reuse this {@link FishingBoat}. The
|
||||
* captain needs a rowing boat which he can operate. The spec is in {@link RowingBoat}. We will use
|
||||
* the Adapter pattern to reuse {@link FishingBoat}.
|
||||
*/
|
||||
public final class App {
|
||||
|
||||
private App() {
|
||||
}
|
||||
private App() {}
|
||||
|
||||
/**
|
||||
* Program entry point.
|
||||
|
||||
@@ -29,7 +29,8 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Captain uses {@link RowingBoat} to sail. <br> This is the client in the pattern.
|
||||
* The Captain uses {@link RowingBoat} to sail. <br>
|
||||
* This is the client in the pattern.
|
||||
*/
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@@ -41,5 +42,4 @@ public final class Captain {
|
||||
void row() {
|
||||
rowingBoat.row();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,5 +36,4 @@ final class FishingBoat {
|
||||
void sail() {
|
||||
LOGGER.info("The fishing boat is sailing");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
/**
|
||||
* The interface expected by the client.<br> A rowing boat is rowed to move.
|
||||
* The interface expected by the client.<br>
|
||||
* A rowing boat is rowed to move.
|
||||
*/
|
||||
public interface RowingBoat {
|
||||
|
||||
void row();
|
||||
|
||||
}
|
||||
|
||||
@@ -24,17 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for the adapter pattern.
|
||||
*/
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests for the adapter pattern. */
|
||||
class AdapterPatternTest {
|
||||
|
||||
private Map<String, Object> beans;
|
||||
@@ -43,9 +41,7 @@ class AdapterPatternTest {
|
||||
|
||||
private static final String ROWING_BEAN = "captain";
|
||||
|
||||
/**
|
||||
* This method runs before the test execution and sets the bean objects in the beans Map.
|
||||
*/
|
||||
/** This method runs before the test execution and sets the bean objects in the beans Map. */
|
||||
@BeforeEach
|
||||
void setup() {
|
||||
beans = new HashMap<>();
|
||||
|
||||
@@ -24,23 +24,17 @@
|
||||
*/
|
||||
package com.iluwatar.adapter;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Tests that Adapter example runs without errors.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests that Adapter example runs without errors. */
|
||||
class AppTest {
|
||||
|
||||
/**
|
||||
* Check whether the execution of the main method in {@link App}
|
||||
* throws an exception.
|
||||
*/
|
||||
|
||||
/** 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[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user