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:
Ilkka Seppälä
2025-03-29 19:34:27 +02:00
committed by GitHub
parent 371439aeaa
commit 0ca162a55c
1863 changed files with 14403 additions and 17632 deletions
@@ -34,8 +34,8 @@ package com.iluwatar.model.view.presenter;
* FileSelectorJframe} is the GUI and the {@link FileSelectorPresenter} is responsible to respond to
* users' actions.
*
* <p>Finally, please notice the wiring between the Presenter and the View and between the
* Presenter and the Model.
* <p>Finally, please notice the wiring between the Presenter and the View and between the Presenter
* and the Model.
*/
public class App {
@@ -43,27 +43,18 @@ import org.slf4j.LoggerFactory;
@Getter
public class FileLoader implements Serializable {
/**
* Generated serial version UID.
*/
@Serial
private static final long serialVersionUID = -4745803872902019069L;
/** Generated serial version UID. */
@Serial private static final long serialVersionUID = -4745803872902019069L;
private static final Logger LOGGER = LoggerFactory.getLogger(FileLoader.class);
/**
* Indicates if the file is loaded or not.
*/
/** Indicates if the file is loaded or not. */
private boolean loaded;
/**
* The name of the file that we want to load.
*/
/** The name of the file that we want to load. */
private String fileName;
/**
* Loads the data of the file specified.
*/
/** Loads the data of the file specified. */
public String loadData() {
var dataFileName = this.fileName;
try (var br = new BufferedReader(new FileReader(dataFileName))) {
@@ -45,45 +45,28 @@ import javax.swing.JTextField;
*/
public class FileSelectorJframe extends JFrame implements FileSelectorView, ActionListener {
/**
* Default serial version ID.
*/
@Serial
private static final long serialVersionUID = 1L;
/** Default serial version ID. */
@Serial private static final long serialVersionUID = 1L;
/**
* The "OK" button for loading the file.
*/
/** The "OK" button for loading the file. */
private final JButton ok;
/**
* The cancel button.
*/
/** The cancel button. */
private final JButton cancel;
/**
* The text field for giving the name of the file that we want to open.
*/
/** The text field for giving the name of the file that we want to open. */
private final JTextField input;
/**
* A text area that will keep the contents of the file opened.
*/
/** A text area that will keep the contents of the file opened. */
private final JTextArea area;
/**
* The Presenter component that the frame will interact with.
*/
/** The Presenter component that the frame will interact with. */
private FileSelectorPresenter presenter;
/**
* The name of the file that we want to read it's contents.
*/
/** The name of the file that we want to read it's contents. */
private String fileName;
/**
* Constructor.
*/
/** Constructor. */
public FileSelectorJframe() {
super("File Loader");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
@@ -35,20 +35,13 @@ import java.io.Serializable;
*/
public class FileSelectorPresenter implements Serializable {
/**
* Generated serial version UID.
*/
@Serial
private static final long serialVersionUID = 1210314339075855074L;
/** Generated serial version UID. */
@Serial private static final long serialVersionUID = 1210314339075855074L;
/**
* The View component that the presenter interacts with.
*/
/** The View component that the presenter interacts with. */
private final FileSelectorView view;
/**
* The Model component that the presenter interacts with.
*/
/** The Model component that the presenter interacts with. */
private FileLoader loader;
/**
@@ -69,24 +62,18 @@ public class FileSelectorPresenter implements Serializable {
this.loader = loader;
}
/**
* Starts the presenter.
*/
/** Starts the presenter. */
public void start() {
view.setPresenter(this);
view.open();
}
/**
* An "event" that fires when the name of the file to be loaded changes.
*/
/** An "event" that fires when the name of the file to be loaded changes. */
public void fileNameChanged() {
loader.setFileName(view.getFileName());
}
/**
* Ok button handler.
*/
/** Ok button handler. */
public void confirmed() {
if (loader.getFileName() == null || loader.getFileName().isEmpty()) {
view.showMessage("Please give the name of the file first!");
@@ -101,9 +88,7 @@ public class FileSelectorPresenter implements Serializable {
}
}
/**
* Cancels the file loading process.
*/
/** Cancels the file loading process. */
public void cancelled() {
view.close();
}
@@ -36,34 +36,22 @@ package com.iluwatar.model.view.presenter;
*/
public class FileSelectorStub implements FileSelectorView {
/**
* Indicates whether or not the view is opened.
*/
/** Indicates whether or not the view is opened. */
private boolean opened;
/**
* The presenter Component.
*/
/** The presenter Component. */
private FileSelectorPresenter presenter;
/**
* The current name of the file.
*/
/** The current name of the file. */
private String name;
/**
* Indicates the number of messages that were "displayed" to the user.
*/
/** Indicates the number of messages that were "displayed" to the user. */
private int numOfMessageSent;
/**
* Indicates if the data of the file where displayed or not.
*/
/** Indicates if the data of the file where displayed or not. */
private boolean dataDisplayed;
/**
* Constructor.
*/
/** Constructor. */
public FileSelectorStub() {
this.opened = false;
this.presenter = null;
@@ -117,9 +105,7 @@ public class FileSelectorStub implements FileSelectorView {
this.dataDisplayed = true;
}
/**
* Returns the number of messages that were displayed to the user.
*/
/** Returns the number of messages that were displayed to the user. */
public int getMessagesSent() {
return this.numOfMessageSent;
}
@@ -32,14 +32,10 @@ import java.io.Serializable;
*/
public interface FileSelectorView extends Serializable {
/**
* Opens the view.
*/
/** Opens the view. */
void open();
/**
* Closes the view.
*/
/** Closes the view. */
void close();
/**
@@ -24,18 +24,15 @@
*/
package com.iluwatar.model.view.presenter;
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[] {}));
}
}
@@ -28,10 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
/**
* FileLoaderTest
*
*/
/** FileLoaderTest */
class FileLoaderTest {
@Test
@@ -40,5 +37,4 @@ class FileLoaderTest {
fileLoader.setFileName("non-existing-file");
assertNull(fileLoader.loadData());
}
}
}
@@ -27,25 +27,19 @@ package com.iluwatar.model.view.presenter;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.awt.event.ActionEvent;
import org.junit.jupiter.api.Test;
/**
* FileSelectorJframeTest
*
*/
/** FileSelectorJframeTest */
class FileSelectorJframeTest {
/**
* Tests if the jframe action event is triggered without any exception.
*/
@Test
void testActionEvent() {
assertDoesNotThrow(() ->{
FileSelectorJframe jFrame = new FileSelectorJframe();
ActionEvent action = new ActionEvent("dummy", 1, "dummy");
jFrame.actionPerformed(action);
});
}
/** Tests if the jframe action event is triggered without any exception. */
@Test
void testActionEvent() {
assertDoesNotThrow(
() -> {
FileSelectorJframe jFrame = new FileSelectorJframe();
ActionEvent action = new ActionEvent("dummy", 1, "dummy");
jFrame.actionPerformed(action);
});
}
}
@@ -38,24 +38,16 @@ import org.junit.jupiter.api.Test;
*/
class FileSelectorPresenterTest {
/**
* The Presenter component.
*/
/** The Presenter component. */
private FileSelectorPresenter presenter;
/**
* The View component, implemented this time as a Stub!!!
*/
/** The View component, implemented this time as a Stub!!! */
private FileSelectorStub stub;
/**
* The Model component.
*/
/** The Model component. */
private FileLoader loader;
/**
* Initializes the components of the test case.
*/
/** Initializes the components of the test case. */
@BeforeEach
void setUp() {
this.stub = new FileSelectorStub();
@@ -64,9 +56,7 @@ class FileSelectorPresenterTest {
presenter.setLoader(loader);
}
/**
* Tests if the Presenter was successfully connected with the View.
*/
/** Tests if the Presenter was successfully connected with the View. */
@Test
void wiring() {
presenter.start();
@@ -75,9 +65,7 @@ class FileSelectorPresenterTest {
assertTrue(stub.isOpened());
}
/**
* Tests if the name of the file changes.
*/
/** Tests if the name of the file changes. */
@Test
void updateFileNameToLoader() {
var expectedFile = "Stamatis";
@@ -105,9 +93,7 @@ class FileSelectorPresenterTest {
assertEquals(1, stub.getMessagesSent());
}
/**
* Tests if we receive a confirmation when we attempt to open a file that it doesn't exist.
*/
/** Tests if we receive a confirmation when we attempt to open a file that it doesn't exist. */
@Test
void fileConfirmationWhenFileDoesNotExist() {
stub.setFileName("RandomName.txt");
@@ -120,9 +106,7 @@ class FileSelectorPresenterTest {
assertEquals(1, stub.getMessagesSent());
}
/**
* Tests if we can open the file, when it exists.
*/
/** Tests if we can open the file, when it exists. */
@Test
void fileConfirmationWhenFileExists() {
stub.setFileName("etc/data/test.txt");
@@ -134,9 +118,7 @@ class FileSelectorPresenterTest {
assertTrue(stub.dataDisplayed());
}
/**
* Tests if the view closes after cancellation.
*/
/** Tests if the view closes after cancellation. */
@Test
void cancellation() {
presenter.start();
@@ -155,5 +137,4 @@ class FileSelectorPresenterTest {
assertFalse(loader.isLoaded());
assertFalse(stub.dataDisplayed());
}
}