mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 06:17:55 +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:
1 parent
371439aeaa
commit
0ca162a55c
1863 files changed
+14403
-17632
No files matched your search
@@ -29,12 +29,10 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
|
||||
/**
|
||||
* The type Command.
|
||||
* Instantiates a new Command.
|
||||
* The type Command. Instantiates a new Command.
|
||||
*
|
||||
* @param fatigue the fatigue
|
||||
* @param health the health
|
||||
* @param fatigue the fatigue
|
||||
* @param health the health
|
||||
* @param nourishment the nourishment
|
||||
*/
|
||||
public record Command(Fatigue fatigue, Health health, Nourishment nourishment) {
|
||||
}
|
||||
public record Command(Fatigue fatigue, Health health, Nourishment nourishment) {}
|
||||
@@ -34,8 +34,7 @@ import lombok.Getter;
|
||||
*/
|
||||
public class Dispatcher {
|
||||
|
||||
@Getter
|
||||
private final GiantView giantView;
|
||||
@Getter private final GiantView giantView;
|
||||
private final List<Action> actions;
|
||||
|
||||
/**
|
||||
@@ -60,7 +59,7 @@ public class Dispatcher {
|
||||
/**
|
||||
* Perform an action.
|
||||
*
|
||||
* @param s the s
|
||||
* @param s the s
|
||||
* @param actionIndex the action index
|
||||
*/
|
||||
public void performAction(Command s, int actionIndex) {
|
||||
@@ -75,5 +74,4 @@ public class Dispatcher {
|
||||
public void updateView(GiantModel giantModel) {
|
||||
giantView.displayGiant(giantModel);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class GiantController {
|
||||
/**
|
||||
* Sets command to control the dispatcher.
|
||||
*
|
||||
* @param s the s
|
||||
* @param s the s
|
||||
* @param index the index
|
||||
*/
|
||||
public void setCommand(Command s, int index) {
|
||||
|
||||
@@ -29,27 +29,23 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* GiantModel contains the giant data.
|
||||
*/
|
||||
/** GiantModel contains the giant data. */
|
||||
public class GiantModel {
|
||||
|
||||
private final com.iluwatar.model.view.controller.GiantModel model;
|
||||
@Getter
|
||||
private final String name;
|
||||
@Getter private final String name;
|
||||
|
||||
/**
|
||||
* Instantiates a new Giant model.
|
||||
*
|
||||
* @param name the name
|
||||
* @param health the health
|
||||
* @param fatigue the fatigue
|
||||
* @param name the name
|
||||
* @param health the health
|
||||
* @param fatigue the fatigue
|
||||
* @param nourishment the nourishment
|
||||
*/
|
||||
GiantModel(String name, Health health, Fatigue fatigue, Nourishment nourishment) {
|
||||
this.name = name;
|
||||
this.model = new com.iluwatar.model.view.controller.GiantModel(health, fatigue,
|
||||
nourishment);
|
||||
this.model = new com.iluwatar.model.view.controller.GiantModel(health, fatigue, nourishment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +99,8 @@ public class GiantModel {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String
|
||||
.format("Giant %s, The giant looks %s, %s and %s.", name,
|
||||
model.getHealth(), model.getFatigue(), model.getNourishment());
|
||||
return String.format(
|
||||
"Giant %s, The giant looks %s, %s and %s.",
|
||||
name, model.getHealth(), model.getFatigue(), model.getNourishment());
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,7 @@ package com.iluwatar.servicetoworker;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* GiantView displays the giant.
|
||||
*/
|
||||
/** GiantView displays the giant. */
|
||||
@Slf4j
|
||||
public class GiantView {
|
||||
|
||||
|
||||
@@ -31,18 +31,14 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The type Action test.
|
||||
*/
|
||||
/** The type Action test. */
|
||||
class ActionTest {
|
||||
|
||||
/**
|
||||
* Verify if the health value is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the health value is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetHealth() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
assertEquals(Health.HEALTHY, model.getHealth());
|
||||
var messageFormat = "Giant giant1, The giant looks %s, alert and saturated.";
|
||||
@@ -53,13 +49,11 @@ class ActionTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the fatigue level is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the fatigue level is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetFatigue() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
assertEquals(Fatigue.ALERT, model.getFatigue());
|
||||
var messageFormat = "Giant giant1, The giant looks healthy, %s and saturated.";
|
||||
@@ -70,13 +64,11 @@ class ActionTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the nourishment level is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the nourishment level is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetNourishment() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
assertEquals(Nourishment.SATURATED, model.getNourishment());
|
||||
var messageFormat = "Giant giant1, The giant looks healthy, alert and %s.";
|
||||
@@ -87,13 +79,11 @@ class ActionTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update model.
|
||||
*/
|
||||
/** Test update model. */
|
||||
@Test
|
||||
void testUpdateModel() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
assertEquals(Nourishment.SATURATED, model.getNourishment());
|
||||
for (final var nourishment : Nourishment.values()) {
|
||||
|
||||
@@ -24,17 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.servicetoworker;
|
||||
|
||||
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[] {}));
|
||||
}
|
||||
}
|
||||
@@ -32,18 +32,14 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The type Dispatcher test.
|
||||
*/
|
||||
/** The type Dispatcher test. */
|
||||
class DispatcherTest {
|
||||
|
||||
/**
|
||||
* Test perform action.
|
||||
*/
|
||||
/** Test perform action. */
|
||||
@Test
|
||||
void testPerformAction() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
GiantView giantView = new GiantView();
|
||||
Dispatcher dispatcher = new Dispatcher(giantView);
|
||||
@@ -64,13 +60,10 @@ class DispatcherTest {
|
||||
|
||||
@Test
|
||||
void testUpdateView() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
GiantView giantView = new GiantView();
|
||||
Dispatcher dispatcher = new Dispatcher(giantView);
|
||||
assertDoesNotThrow(() -> dispatcher.updateView(model));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+8
-16
@@ -32,19 +32,14 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* The type Giant controller test.
|
||||
*/
|
||||
/** The type Giant controller test. */
|
||||
class GiantControllerTest {
|
||||
|
||||
/**
|
||||
* Test set command.
|
||||
*/
|
||||
/** Test set command. */
|
||||
@Test
|
||||
void testSetCommand() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
Action action = new Action(model);
|
||||
GiantView giantView = new GiantView();
|
||||
Dispatcher dispatcher = new Dispatcher(giantView);
|
||||
@@ -57,17 +52,14 @@ class GiantControllerTest {
|
||||
assertEquals(Nourishment.HUNGRY, model.getNourishment());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update view.
|
||||
*/
|
||||
/** Test update view. */
|
||||
@Test
|
||||
void testUpdateView() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
GiantView giantView = new GiantView();
|
||||
Dispatcher dispatcher = new Dispatcher(giantView);
|
||||
GiantController giantController = new GiantController(dispatcher);
|
||||
assertDoesNotThrow(() -> giantController.updateView(model));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,18 +31,14 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The type Giant model test.
|
||||
*/
|
||||
/** The type Giant model test. */
|
||||
class GiantModelTest {
|
||||
|
||||
/**
|
||||
* Verify if the health value is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the health value is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetHealth() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Health.HEALTHY, model.getHealth());
|
||||
var messageFormat = "Giant giant1, The giant looks %s, alert and saturated.";
|
||||
for (final var health : Health.values()) {
|
||||
@@ -52,13 +48,11 @@ class GiantModelTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the fatigue level is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the fatigue level is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetFatigue() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Fatigue.ALERT, model.getFatigue());
|
||||
var messageFormat = "Giant giant1, The giant looks healthy, %s and saturated.";
|
||||
for (final var fatigue : Fatigue.values()) {
|
||||
@@ -68,13 +62,11 @@ class GiantModelTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the nourishment level is set properly though the constructor and setter
|
||||
*/
|
||||
/** Verify if the nourishment level is set properly though the constructor and setter */
|
||||
@Test
|
||||
void testSetNourishment() {
|
||||
final var model = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
final var model =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
assertEquals(Nourishment.SATURATED, model.getNourishment());
|
||||
var messageFormat = "Giant giant1, The giant looks healthy, alert and %s.";
|
||||
for (final var nourishment : Nourishment.values()) {
|
||||
|
||||
@@ -31,18 +31,14 @@ import com.iluwatar.model.view.controller.Health;
|
||||
import com.iluwatar.model.view.controller.Nourishment;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* The type Giant view test.
|
||||
*/
|
||||
/** The type Giant view test. */
|
||||
class GiantViewTest {
|
||||
|
||||
/**
|
||||
* Test display giant.
|
||||
*/
|
||||
/** Test display giant. */
|
||||
@Test
|
||||
void testDispalyGiant() {
|
||||
GiantModel giantModel = new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT,
|
||||
Nourishment.SATURATED);
|
||||
GiantModel giantModel =
|
||||
new GiantModel("giant1", Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
|
||||
GiantView giantView = new GiantView();
|
||||
assertDoesNotThrow(() -> giantView.displayGiant(giantModel));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user