The ui module is responsible for the application's frontend. It is built using JavaFX and FXML. It uses FXML files and their respected controller for navigating between scenes. The frontend is responsible for displaying the recipes in the cookbook, adding a recipe, editing a recipe and deleting a recipe. The ui module requires access to the core, springboot and persistence module in order to function properly. It is set up to work with either a localy stored cookbook file or using requests to a REST-API.
- cookbook.ui - Contains the
Controller
classes for the different scenes in the application. As well as the main class for running the application. - coookbook.accessdata - Contains the logic for reading and writing to the json file. This package contains two classes, one for reading and writing to a local json file and one for reading and writing to a remote json file. Both implementing the same
CookbookAccess
interface for use in the controllers.
- CookbookApp - This class is responsible for running the application.
- AppController - This class is responsible for setting up the application and switching between scenes. Linked to the App.fxml file.
- AddRecipeController - This class is responsible for adding a recipe to the cookbook. Linked to the AddRecipe.fxml file.
- RecipeViewController - This class is responsible for displaying a recipe. Linked to the RecipeView.fxml file.
- EditRecipeController - This class is responsible for editing a recipe. Linked to the EditRecipe.fxml** file.
- LocalCookbookAccess - This class is responsible for reading and writing to the json file. Using the CookbookHandler class from the persistence module. Implements the CookbookAccess interface.
NOTE: The constructor of this class will try to read and write to the local cookbook, but if it does not find this file, ex if the app is ran after being installed through the installer created byJPackage
, it will read and write to a json file stored atUSER.HOME
. - RemoteCookbookAccess - This class is responsible for reading and writing to the json file on a remote server using the REST API from the springboot module. Implements from the CookbookAccess interface
- CookbookAppTest - Tests the App using
FxRobot
for UI testing. - LocalCookbookAccessTest - Tests the LocalCookbookAccess class.
- RemoteCookbookAccessTest - Tests the RemoteCookbookAccess class using
WireMock
.
- The
CookbookAppTest
uses FxRobot for testing the apps GUI. It provides assurance that actions in the app lead to the correct outcome. What one presses in the app should correspond to what is expected to happen. The tests are performed by using the onClick() command with the elements' CSS ids. - The
LocalCookbookAccessTest
tests that the methods defined in the CookbookAccess interface works, and can be implemented using the CookbookHandler class from the persistence module together with some additional logic. This test ensures that we can safely use the LocalCookbookAccess object if the app fails to connect to the REST-API. - In
RemoteCookbookAccessTest
we use WireMock to mock the server, defining the expected requests and responses. This test ensures that the RemoteCookbookAccess exception handling in works as intended. This test primary focus is to ensure that the RemoteCookbookAccess throws a RuntimeException if it recives a non 200(OK) response from the server. It also checks that the RemoteCookbookAccess class is able to fetch a json cookbook from the server and convert it to the right Cookbook object.
- Core
- Persistence
- WireMock
- JavaFX
This module has its own pom.xml file, which is responsible for building the module with its respected dependencies and plugins, such as JaCoCo, Checkstyle and Spotbugs, WireMock and JavaFX.