mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-20 01:25:41 +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:
@@ -25,9 +25,7 @@
|
||||
|
||||
package com.iluwatar.virtual.proxy;
|
||||
|
||||
/**
|
||||
* The main application class that sets up and runs the Virtual Proxy pattern demo.
|
||||
*/
|
||||
/** The main application class that sets up and runs the Virtual Proxy pattern demo. */
|
||||
public class App {
|
||||
/**
|
||||
* The entry point of the application.
|
||||
@@ -36,7 +34,7 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ExpensiveObject videoObject = new VideoObjectProxy();
|
||||
videoObject.process(); // The first call creates and plays the video
|
||||
videoObject.process(); // Subsequent call uses the already created object
|
||||
videoObject.process(); // The first call creates and plays the video
|
||||
videoObject.process(); // Subsequent call uses the already created object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
*/
|
||||
package com.iluwatar.virtual.proxy;
|
||||
|
||||
/**
|
||||
* Interface for expensive object and proxy object.
|
||||
*/
|
||||
/** Interface for expensive object and proxy object. */
|
||||
public interface ExpensiveObject {
|
||||
void process();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,7 @@ package com.iluwatar.virtual.proxy;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Represents a real video object that is expensive to create and manage.
|
||||
*/
|
||||
/** Represents a real video object that is expensive to create and manage. */
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class RealVideoObject implements ExpensiveObject {
|
||||
@@ -47,4 +45,4 @@ public class RealVideoObject implements ExpensiveObject {
|
||||
public void process() {
|
||||
LOGGER.info("Processing and playing video content...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ package com.iluwatar.virtual.proxy;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* A proxy class for the real video object, providing a layer of control over the object instantiation.
|
||||
* A proxy class for the real video object, providing a layer of control over the object
|
||||
* instantiation.
|
||||
*/
|
||||
@Getter
|
||||
public class VideoObjectProxy implements ExpensiveObject {
|
||||
@@ -41,4 +42,4 @@ public class VideoObjectProxy implements ExpensiveObject {
|
||||
}
|
||||
realVideoObject.process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,17 +25,15 @@
|
||||
|
||||
package com.iluwatar.virtual.proxy;
|
||||
|
||||
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 {
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,14 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package com.iluwatar.virtual.proxy;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for RealVideoObject.
|
||||
*/
|
||||
/** Tests for RealVideoObject. */
|
||||
class RealVideoObjectTest {
|
||||
|
||||
@Test
|
||||
@@ -50,4 +49,4 @@ class RealVideoObjectTest {
|
||||
RealVideoObject realVideoObject = new RealVideoObject();
|
||||
assertDoesNotThrow(realVideoObject::process, "Process method should not throw any exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for VideoObjectProxy.
|
||||
*/
|
||||
/** Tests for VideoObjectProxy. */
|
||||
public class VideoObjectProxyTest {
|
||||
@Test
|
||||
void shouldBeInstanceOfExpensiveObject() {
|
||||
@@ -47,7 +45,7 @@ public class VideoObjectProxyTest {
|
||||
|
||||
@Test
|
||||
void processDoesNotThrowException() {
|
||||
assertDoesNotThrow(() -> new VideoObjectProxy().process(), "Process method should not throw any exception");
|
||||
assertDoesNotThrow(
|
||||
() -> new VideoObjectProxy().process(), "Process method should not throw any exception");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user