mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-31 02:20:26 +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:
@@ -27,7 +27,6 @@ package com.iluwatar.compositeentity;
|
||||
import java.util.Arrays;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Composite entity is a Java EE Software design pattern and it is used to model, represent, and
|
||||
* manage a set of interrelated persistent objects rather than representing them as individual
|
||||
@@ -36,10 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
|
||||
/**
|
||||
* An instance that a console manages two related objects.
|
||||
*/
|
||||
/** An instance that a console manages two related objects. */
|
||||
public App(String message, String signal) {
|
||||
var console = new CompositeEntity();
|
||||
console.init();
|
||||
@@ -57,6 +53,5 @@ public class App {
|
||||
public static void main(String[] args) {
|
||||
|
||||
new App("No Danger", "Green Light");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.stream.IntStream;
|
||||
* other objects. It can be an object contained in the composite entity, or, composite entity itself
|
||||
* can be the coarse-grained object which holds dependent objects.
|
||||
*/
|
||||
|
||||
public abstract class CoarseGrainedObject<T> {
|
||||
|
||||
DependentObject<T>[] dependentObjects;
|
||||
|
||||
@@ -28,7 +28,6 @@ package com.iluwatar.compositeentity;
|
||||
* Composite entity is the coarse-grained entity bean which may be the coarse-grained object, or may
|
||||
* contain a reference to the coarse-grained object.
|
||||
*/
|
||||
|
||||
public class CompositeEntity {
|
||||
|
||||
private final ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
|
||||
@@ -44,4 +43,4 @@ public class CompositeEntity {
|
||||
public void init() {
|
||||
console.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-10
@@ -24,21 +24,16 @@
|
||||
*/
|
||||
package com.iluwatar.compositeentity;
|
||||
|
||||
/**
|
||||
* A specific CoarseGrainedObject to implement a console.
|
||||
*/
|
||||
|
||||
/** A specific CoarseGrainedObject to implement a console. */
|
||||
public class ConsoleCoarseGrainedObject extends CoarseGrainedObject<String> {
|
||||
|
||||
@Override
|
||||
public String[] getData() {
|
||||
return new String[]{
|
||||
dependentObjects[0].getData(), dependentObjects[1].getData()
|
||||
};
|
||||
return new String[] {dependentObjects[0].getData(), dependentObjects[1].getData()};
|
||||
}
|
||||
|
||||
public void init() {
|
||||
dependentObjects = new DependentObject[]{
|
||||
new MessageDependentObject(), new SignalDependentObject()};
|
||||
dependentObjects =
|
||||
new DependentObject[] {new MessageDependentObject(), new SignalDependentObject()};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,4 @@ import lombok.Setter;
|
||||
public abstract class DependentObject<T> {
|
||||
|
||||
T data;
|
||||
|
||||
}
|
||||
|
||||
+2
-7
@@ -24,10 +24,5 @@
|
||||
*/
|
||||
package com.iluwatar.compositeentity;
|
||||
|
||||
/**
|
||||
* The first DependentObject to show message.
|
||||
*/
|
||||
|
||||
public class MessageDependentObject extends DependentObject<String> {
|
||||
|
||||
}
|
||||
/** The first DependentObject to show message. */
|
||||
public class MessageDependentObject extends DependentObject<String> {}
|
||||
|
||||
+2
-7
@@ -24,10 +24,5 @@
|
||||
*/
|
||||
package com.iluwatar.compositeentity;
|
||||
|
||||
/**
|
||||
* The second DependentObject to show message.
|
||||
*/
|
||||
|
||||
public class SignalDependentObject extends DependentObject<String> {
|
||||
|
||||
}
|
||||
/** The second DependentObject to show message. */
|
||||
public class SignalDependentObject extends DependentObject<String> {}
|
||||
|
||||
@@ -28,22 +28,18 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* com.iluwatar.compositeentity.App running test
|
||||
*/
|
||||
/** com.iluwatar.compositeentity.App running test */
|
||||
class AppTest {
|
||||
|
||||
/**
|
||||
* Issue: Add at least one assertion to this test case.
|
||||
* <p>
|
||||
* Solution: Inserted assertion to check whether the execution of the main method in {@link
|
||||
*
|
||||
* <p>Solution: Inserted assertion to check whether the execution of the main method in {@link
|
||||
* App#main(String[])} throws an exception.
|
||||
*/
|
||||
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
|
||||
assertDoesNotThrow(() -> App.main(new String[]{}));
|
||||
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
*/
|
||||
package com.iluwatar.compositeentity;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class PersistenceTest {
|
||||
|
||||
final static ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
|
||||
static final ConsoleCoarseGrainedObject console = new ConsoleCoarseGrainedObject();
|
||||
|
||||
@Test
|
||||
void dependentObjectChangedForPersistenceTest() {
|
||||
|
||||
Reference in New Issue
Block a user