mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-20 08: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:
@@ -28,6 +28,4 @@ package com.iluwatar.acyclicvisitor;
|
||||
* All ModemVisitor interface extends all visitor interfaces. This interface provides ease of use
|
||||
* when a visitor needs to visit all modem types.
|
||||
*/
|
||||
public interface AllModemVisitor extends ZoomVisitor, HayesVisitor {
|
||||
|
||||
}
|
||||
public interface AllModemVisitor extends ZoomVisitor, HayesVisitor {}
|
||||
|
||||
@@ -37,9 +37,7 @@ package com.iluwatar.acyclicvisitor;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program's entry point.
|
||||
*/
|
||||
/** Program's entry point. */
|
||||
public static void main(String[] args) {
|
||||
var conUnix = new ConfigureForUnixVisitor();
|
||||
var conDos = new ConfigureForDosVisitor();
|
||||
@@ -50,6 +48,6 @@ public class App {
|
||||
hayes.accept(conDos); // Hayes modem with Dos configurator
|
||||
zoom.accept(conDos); // Zoom modem with Dos configurator
|
||||
hayes.accept(conUnix); // Hayes modem with Unix configurator
|
||||
zoom.accept(conUnix); // Zoom modem with Unix configurator
|
||||
zoom.accept(conUnix); // Zoom modem with Unix configurator
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -27,8 +27,7 @@ package com.iluwatar.acyclicvisitor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* ConfigureForDosVisitor class implements both zoom's and hayes' visit method for Dos
|
||||
* manufacturer.
|
||||
* ConfigureForDosVisitor class implements both zoom's and hayes' visit method for Dos manufacturer.
|
||||
*/
|
||||
@Slf4j
|
||||
public class ConfigureForDosVisitor implements AllModemVisitor {
|
||||
|
||||
+1
-1
@@ -37,4 +37,4 @@ public class ConfigureForUnixVisitor implements ZoomVisitor {
|
||||
public void visit(Zoom zoom) {
|
||||
LOGGER.info(zoom + " used with Unix configurator.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,15 +26,11 @@ package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Hayes class implements its accept method.
|
||||
*/
|
||||
/** Hayes class implements its accept method. */
|
||||
@Slf4j
|
||||
public class Hayes implements Modem {
|
||||
|
||||
/**
|
||||
* Accepts all visitors but honors only HayesVisitor.
|
||||
*/
|
||||
/** Accepts all visitors but honors only HayesVisitor. */
|
||||
@Override
|
||||
public void accept(ModemVisitor modemVisitor) {
|
||||
if (modemVisitor instanceof HayesVisitor) {
|
||||
@@ -42,12 +38,9 @@ public class Hayes implements Modem {
|
||||
} else {
|
||||
LOGGER.info("Only HayesVisitor is allowed to visit Hayes modem");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hayes' modem's toString method.
|
||||
*/
|
||||
/** Hayes' modem's toString method. */
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Hayes modem";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* HayesVisitor interface.
|
||||
*/
|
||||
/** HayesVisitor interface. */
|
||||
public interface HayesVisitor extends ModemVisitor {
|
||||
void visit(Hayes hayes);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* //Modem abstract class.
|
||||
* converted to an interface
|
||||
*/
|
||||
/** //Modem abstract class. converted to an interface */
|
||||
public interface Modem {
|
||||
void accept(ModemVisitor modemVisitor);
|
||||
}
|
||||
|
||||
@@ -26,15 +26,11 @@ package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Zoom class implements its accept method.
|
||||
*/
|
||||
/** Zoom class implements its accept method. */
|
||||
@Slf4j
|
||||
public class Zoom implements Modem {
|
||||
|
||||
/**
|
||||
* Accepts all visitors but honors only ZoomVisitor.
|
||||
*/
|
||||
/** Accepts all visitors but honors only ZoomVisitor. */
|
||||
@Override
|
||||
public void accept(ModemVisitor modemVisitor) {
|
||||
if (modemVisitor instanceof ZoomVisitor) {
|
||||
@@ -44,9 +40,7 @@ public class Zoom implements Modem {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom modem's toString method.
|
||||
*/
|
||||
/** Zoom modem's toString method. */
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Zoom modem";
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
/**
|
||||
* ZoomVisitor interface.
|
||||
*/
|
||||
/** ZoomVisitor interface. */
|
||||
public interface ZoomVisitor extends ModemVisitor {
|
||||
void visit(Zoom zoom);
|
||||
}
|
||||
|
||||
@@ -24,25 +24,22 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
/**
|
||||
* Tests that the Acyclic Visitor example runs without errors.
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Tests that the Acyclic Visitor example runs without errors. */
|
||||
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[] {}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,12 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* Hayes test class
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Hayes test class */
|
||||
class HayesTest {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,16 +24,13 @@
|
||||
*/
|
||||
package com.iluwatar.acyclicvisitor;
|
||||
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Zoom test class
|
||||
*/
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Zoom test class */
|
||||
class ZoomTest {
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user