Skip to content

Commit

Permalink
Merge pull request #145 from ucsd-cse110-fa23/end2EndReqs
Browse files Browse the repository at this point in the history
feat: end-to-end testing and final refactoring (#122)
  • Loading branch information
sprestrelski authored Dec 6, 2023
2 parents 27ef719 + 5843feb commit 96b1e63
Show file tree
Hide file tree
Showing 81 changed files with 2,878 additions and 1,622 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ gradle-app.setting

# End of https://www.toptal.com/developers/gitignore/api/java,gradle
*.wav
!app/recording.wav
*.properties
.vscode/launch.json
!gradle/wrapper/gradle-wrapper.jar
!gradle/wrapper/gradle-wrapper.properties
!gradle/wrapper/gradle-wrapper.properties
*.csv
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
# CSE 110 Project Team 39 Culinary Companion Crew
PantryPals - the application that provides you with recipes that YOU have currently in your possession!

GitHub Repo: https://github.com/ucsd-cse110-fa23/cse-110-project-team-39
MS1 Project Board: https://github.com/orgs/ucsd-cse110-fa23/projects/10
MS2 Project Board: https://github.com/orgs/ucsd-cse110-fa23/projects/74

## How to run the app
1. Clone the repository
2. Change or create a `.vscode/launch.json`, and change the `vmArgs` to point to your JavaFX lib.
3. Run from `App.java`.
3. Run from `App.java`.

### Sample `launch.json`
```json
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "App",
"request": "launch",
"mainClass": "code.App",
"projectName": "app",
"vmArgs": "--module-path 'user/javafx-sdk-21/lib' --add-modules javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.web --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED --add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED"
}
]
}
```
Binary file added app/recording.wav
Binary file not shown.
22 changes: 14 additions & 8 deletions app/src/main/java/code/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@
import javafx.stage.WindowEvent;
import code.client.Model.*;
import code.client.View.*;
import code.server.BaseServer;
import code.server.AppServer;
import code.client.Controllers.*;
import javafx.scene.Scene;
import code.server.IRecipeDb;
import code.server.mocking.MockServer;

import java.io.FileReader;
import java.io.IOException;
import java.net.URISyntaxException;

public class App extends Application {
private IRecipeDb recipeDb;
private AppServer server;
private BaseServer server;

@Override
public void start(Stage primaryStage) throws Exception {
// initDb(); To use CSV file
initServer();
server.start();
// initServer();
// server.start();
drawUI(primaryStage);
}

Expand All @@ -36,18 +38,18 @@ private void drawUI(Stage primaryStage) throws IOException, URISyntaxException {
Model model = new Model();
Scene login = new Scene(view.getLoginUI().getRoot());
view.setScene(login);
Controller controller = new Controller(view, model);

ServerConnection connection = new ServerConnection(server);
Controller controller;
//123
ServerConnection connection = new ServerConnection(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);

if (connection.isOnline()) {
controller = new Controller(view, model);
// System.out.println("Server is online");
controller.addListenersToList();
} else {
// System.out.println("Server is offline");
view.goToOfflineUI();
}

primaryStage.setScene(login);
primaryStage.setTitle(AppConfig.APP_NAME);
primaryStage.setResizable(true);
Expand Down Expand Up @@ -75,6 +77,10 @@ private IRecipeDb initDb() throws IOException {
}

private void initServer() throws IOException {
server = new AppServer(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);
if (AppConfig.MOCKING_ON) {
server = new MockServer(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);
} else {
server = new AppServer(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);
}
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/code/Server.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package code;

import java.io.IOException;

import code.client.Model.AppConfig;
import code.server.AppServer;
import code.server.BaseServer;
import code.server.mocking.MockServer;

public class Server {
private static BaseServer server;

public static void main(String[] args) throws IOException {
initServer();
server.start();
}

private static void initServer() throws IOException {
if (AppConfig.MOCKING_ON) {
server = new MockServer(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);
} else {
server = new AppServer(AppConfig.SERVER_HOST, AppConfig.SERVER_PORT);
}
}

}
Loading

0 comments on commit 96b1e63

Please sign in to comment.