Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created tests #44

Open
wants to merge 7 commits into
base: broken-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified AccountInfo.csv
Binary file not shown.
8 changes: 8 additions & 0 deletions Dishes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Restaurant,Name,Rating,Description,Category,Price
Quetzal,Sikil Pak,8,Pumpkin seed with roasted poblano and cotijia,Appetizer,23.00
Quetzal,Newfoundland Scallops,7,In the shell with ramp butter and sea asparagus with morita chili,Entree,38.00
Quetzal,Octopus,9,Salsa macha and corn miso butter with charred brussel sprout leaves,Entree,44.00
Don Alfonso,Il Carpaccio,10,Ontario Wagyu beef tenderloin with Dijon mustard sauce and balsamic vinegar caviar,Entree,32.00
Don Alfonso,L'Insalata Caprese,7,Cherry tomato and burrata D'Andria with arugala and oregano or pesto,Entree,28.00
Alobar,East Coast Oysters,8,Citrus and tobasco,Entree,26.00
Alobar,Chilled Lobster,9,Gem lettuce with lime aioli,Entree,40.00
2 changes: 2 additions & 0 deletions Restaurant.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Quetzal,Mexican,419 College St,1
Shousin,Japanese,3328 Yonge St,1
Yukashi,Japanese,643A Mt Pleasant Rd,1
Sushi Masaki Saito,Japanese,88 Avenue Rd,2
Olive garden,italian,college st,2,
hello,a,a,3,
Binary file modified Reviews.csv
Binary file not shown.
Binary file added accounts.csv
Binary file not shown.
Binary file added bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

public interface DishDataAccess {
boolean dishExistsByName(String identifier);
HashMap<String, List<List<String>>> getDish(String file);
List<List<String>> getDish(String file);
}
5 changes: 3 additions & 2 deletions src/main/java/APP_Business_Rules/DishMenu/DishFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public HashMap<String, List<List<String>>> createList() {
return dishes;
}
@Override
public HashMap<String, List<List<String>>> getDish(String file){
public List<List<String>> getDish(String resName){
DishFileReader fileReader = new DishFileReader(file);
return fileReader.createList();
HashMap<String, List<List<String>>> allDishes = fileReader.createList();
return allDishes.get(resName);
}

@Override
Expand Down

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/APP_Business_Rules/MenuUseCase/MenuInteractor.java

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions src/main/java/APP_Business_Rules/MenuUseCase/MenuRequestModel.java

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/APP_Business_Rules/OutputBoundary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package APP_Business_Rules;

import APP_Business_Rules.SearchUseCase.SearchResponseModel;

import java.util.ArrayList;
import java.util.HashMap;

public interface OutputBoundary {
void update(SearchResponseModel searchResponseModel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface RestaurantDataAccess {
Passes Restaurant information from the file reader to the Restaurant interactor and screens
*/
boolean existsByName(String identifier);
RestaurantGatewayModel loadRestaurant(RestaurantGatewayModel model);
RestaurantGatewayModel save(RestaurantGatewayModel model);
List<List<String>> getRes();

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean existsByName(String identifier) {
return restaurants.equals(identifier);
}
@Override
public RestaurantGatewayModel loadRestaurant(RestaurantGatewayModel model) {
public RestaurantGatewayModel save(RestaurantGatewayModel model) {
List<String> restaurantInfo = new ArrayList<>();
String resName = model.getResName();
String resCategory = model.getResCategory();
Expand All @@ -75,8 +75,8 @@ public RestaurantGatewayModel loadRestaurant(RestaurantGatewayModel model) {
for (String x : restaurantInfo) {
output.append(x);
output.append(",");
output.newLine();
}
output.newLine();
output.close();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ public RestaurantResponseModel create(RestaurantRequestModel requestModel) {
requestModel.getResLocation(), requestModel.getStars());
RestaurantGatewayModel gatewayModel= new RestaurantGatewayModel(restaurant.getName(), restaurant.getResCategory(),
restaurant.getLocation(), restaurant.getStars());
gateway.loadRestaurant(gatewayModel);
RestaurantResponseModel restaurantResponseModel = new RestaurantResponseModel(gateway.loadRestaurant(gatewayModel));
RestaurantGatewayModel saved = gateway.save(gatewayModel);
RestaurantResponseModel restaurantResponseModel = new RestaurantResponseModel(saved);
return restaurantPresenter.prepareSuccessView(restaurantResponseModel);
}

public Restaurant getRes(RestaurantRequestModel requestModel){
return restaurantFactory.create(requestModel.getResName(), requestModel.getResCategory(),
requestModel.getResLocation(), requestModel.getStars());
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
package APP_Business_Rules.SearchUseCase;

import java.util.HashMap;

public class SearchRequestModel {
/**
*Object that contains information about the search made
* @param search String entered on the search bar
* @param type type of search that could be either "Dish" or "Restaurant"
* @param category category of the searched items
* @param minRating minimum rating or number of Michelin stars of the searhed items
*/
private String search;
private String type;
private String category;
private int minRating;
private HashMap<String, Object> filter;

public SearchRequestModel(String search, String type, String category, int minRating) {
public SearchRequestModel(String search, String type, HashMap<String, Object> filter) {
this.search = search;
this.type = type;
this.category = category;
this.minRating = minRating;
this.filter = filter;
}

public String getSearch() {
Expand All @@ -29,11 +21,7 @@ public String getType() {
return type;
}

public String getCategory() {
return category;
public HashMap<String, Object> getFilter() {
return filter;
}

public int getMinRating() {
return minRating;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,19 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class SearchResponseModel {
/**
* Object that represents the items that match the search
* @param result list of items that match the search, each item is represented by a list of strings
* @param type represents the type of search made
*/
private List<List<String>> result;
private String type;

public SearchResponseModel(List<List<String>> result, String type) {
private ArrayList<HashMap<String,Object>> result;

public SearchResponseModel(ArrayList<HashMap<String, Object>> result) {
this.result = result;
this.type = type;
}

public List<List<String>> getResult() {
public ArrayList<HashMap<String, Object>> getResult() {
return result;
}

public String getType() {
return type;
}

public void add(List<String> e){
public void add(HashMap<String,Object> e){
this.result.add(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
package APP_Business_Rules.SearchUseCase;

import APP_Business_Rules.RestaurantUseCase.RestaurantDataAccess;
import APP_Business_Rules.DataAccessStorageInterface;
import APP_Business_Rules.OutputBoundary;
import Entities.Restaurant;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.HashMap;

import static java.lang.Double.compare;
import static java.lang.Double.parseDouble;

public class SearchRestaurantUseCase implements SearchInputBoundary{
/**
* Class that takes care of querying restaurants and filtering out the ones that do not match the search
* @param searchPresenter presenter that updates the UI with the restaurants that match the search
* @param dataAccess class that reads the restaurant database
*/
private SearchOutputBoundary searchPresenter;
private RestaurantDataAccess dataAccess;

public SearchRestaurantUseCase(SearchOutputBoundary searchPresenter, RestaurantDataAccess dataAccess){
private OutputBoundary searchPresenter;
private DataAccessStorageInterface dataAccess;

public SearchRestaurantUseCase(OutputBoundary searchPresenter, DataAccessStorageInterface dataAccess){
this.searchPresenter = searchPresenter;
this.dataAccess = dataAccess;
}

/**
* Function that gets all the available restaurants and keeps the ones that match the search then calls the presenter
* to update the UI
* @param searchRequestModel request model that contains all the information about the search
*/
public void Search(SearchRequestModel searchRequestModel){
List<List<String>> data = this.dataAccess.getRes(); //Might need to change the return type of accessData() to Arraylist<Object>
SearchResponseModel searchResponseModel = new SearchResponseModel(new ArrayList<>(), "Restaurant");
for (List<String> r: data){
if(r.get(0).contains(searchRequestModel.getSearch())){
if (compare(parseDouble(r.get(3)), searchRequestModel.getMinRating()) >= 0 && (Objects.equals(searchRequestModel.getCategory(), r.get(1)) || Objects.equals(searchRequestModel.getCategory(), "All"))){
searchResponseModel.add(r);
ArrayList<Restaurant> data = (ArrayList<Restaurant>) this.dataAccess.accessData(searchRequestModel.getType() + ".txt"); //Might need to change the return type of accessData() to Arraylist<Object>
SearchResponseModel searchResponseModel = new SearchResponseModel(new ArrayList<>());
for (Restaurant r: data){
if(r.getName().contains(searchRequestModel.getSearch())||r.getLocation().contains(searchRequestModel.getSearch())){
if (compare(r.getRating(), (Double) searchRequestModel.getFilter().get("minRating")) >= 0 && searchRequestModel.getFilter().get("Category") == r.getResCategory()){
HashMap<String, Object> restaurantAsAHashMap = new HashMap<String, Object>();
restaurantAsAHashMap.put("Name", r.getName());
restaurantAsAHashMap.put("Restaurant Category", r.getResCategory());
restaurantAsAHashMap.put("Location", r.getLocation());
restaurantAsAHashMap.put("Rating", r.getRating());
//Omitted dishRatings because I do not know if it will be kept
//Will format the menu into a HashMap when I get a better idea of the what is happening in the Menu code
searchResponseModel.add(restaurantAsAHashMap);
}
}
}
searchPresenter.update(searchResponseModel);
}


}
}
Loading