-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Tests' of https://github.com/ucsd-cse110-fa23/cse-110-p…
…roject-team-33 into Tests
- Loading branch information
Showing
8 changed files
with
210 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cse.gradle; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
|
||
import cse.gradle.View.UserLogin; | ||
|
||
public class MockController { | ||
public boolean loginUser(String username, String password) throws IOException { | ||
// Checks if the automic login file exists; if it does, and username matches the | ||
// one in file, do automatic login | ||
if ((new File("src/main/java/cse/gradle/local/login.txt")).exists()) { | ||
File loginFile = new File("src/main/java/cse/gradle/local/login.txt"); | ||
BufferedReader reader = new BufferedReader( | ||
new FileReader(loginFile)); | ||
if (username.equals(reader.readLine())) { | ||
reader.close(); | ||
// String postResponse = model.performLoginRequest(loginFile); | ||
// if (postResponse.equals("Error: Server down")) { | ||
// appScenes.displayServerDownConstructor(); | ||
// return false; | ||
// } | ||
// reader.close(); | ||
return true; | ||
} | ||
reader.close(); | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
bob2000 | ||
2000 | ||
login |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,80 @@ | ||
// package cse.gradle; | ||
package cse.gradle; | ||
|
||
// import org.junit.jupiter.api.Disabled; | ||
// import org.junit.jupiter.api.Test; | ||
// import java.util.List; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import java.util.List; | ||
|
||
// import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
// import java.util.ArrayList; | ||
// import java.util.Date; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
|
||
// public class Feature16Tests extends HTTPServerTests { | ||
public class Feature16Tests extends HTTPServerTests { | ||
|
||
// @Test | ||
// public void sortByDateMethodTest() { | ||
// // Create a new List<Recipe> with 3 recipes | ||
// List<Recipe> recipes = new ArrayList<Recipe>(); | ||
@Test | ||
public void sortByDateMethodTest() throws InterruptedException { | ||
// Create a new List<Recipe> with 3 recipes | ||
List<Recipe> recipes = new ArrayList<Recipe>(); | ||
|
||
// recipes.add(new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast", new Date(2023,3,4))); | ||
// recipes.add(new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch")); | ||
// recipes.add(new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes")); | ||
recipes.add(new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast", new Date())); | ||
Thread.sleep(1000); | ||
recipes.add(new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch", new Date())); | ||
Thread.sleep(1000); | ||
recipes.add(new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes", new Date())); | ||
|
||
// Recipe.sortByDate(recipes, false); | ||
Recipe.sortByDate(recipes, false); | ||
|
||
// // Check that the recipes are sorted alphabetically A-Z (not case sensitive) | ||
// assert(recipes.get(0).getName().equals("American breakfast")); | ||
// assert(recipes.get(1).getName().equals("boiled potatoes")); | ||
// assert(recipes.get(2).getName().equals("Healthy Lunch")); | ||
// Check that the recipes are sorted oldest to newest | ||
assert(recipes.get(0).getName().equals("American breakfast")); | ||
assert(recipes.get(1).getName().equals("Healthy Lunch")); | ||
assert(recipes.get(2).getName().equals("boiled potatoes")); | ||
|
||
// Recipe.sortByName(recipes, true); | ||
Recipe.sortByDate(recipes, true); | ||
|
||
// // Check that the recipes are sorted alphabetically Z-A (not case sensitive) | ||
// assert(recipes.get(0).getName().equals("Healthy Lunch")); | ||
// assert(recipes.get(1).getName().equals("boiled potatoes")); | ||
// assert(recipes.get(2).getName().equals("American breakfast")); | ||
// } | ||
// Check that the recipes are sorted newest to oldest | ||
assert(recipes.get(0).getName().equals("boiled potatoes")); | ||
assert(recipes.get(1).getName().equals("Healthy Lunch")); | ||
assert(recipes.get(2).getName().equals("American breakfast")); | ||
} | ||
|
||
// @Test | ||
// public void getRecipeListAToZTest() { | ||
@Test | ||
public void getRecipeListOldToNewTest() throws InterruptedException { | ||
|
||
// // Create a new List<Recipe> with 3 recipes | ||
// List<Recipe> recipes = new ArrayList<Recipe>(); | ||
// Create a new List<Recipe> with 3 recipes | ||
List<Recipe> recipes = new ArrayList<Recipe>(); | ||
|
||
// recipes.add(new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast")); | ||
// recipes.add(new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch")); | ||
// recipes.add(new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes")); | ||
recipes.add(new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast", new Date())); | ||
Thread.sleep(1000); | ||
recipes.add(new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch", new Date())); | ||
Thread.sleep(1000); | ||
recipes.add(new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes", new Date())); | ||
|
||
// Create a new Mock Model that accesses test_user in the database | ||
Model model = new MockModel(); | ||
|
||
// // Create a new Mock Model that accesses test_user in the database | ||
// Model model = new MockModel(); | ||
// Add the recipes to the database | ||
for (Recipe recipe : recipes) { | ||
model.postRecipe(recipe); | ||
} | ||
|
||
// // Add the recipes to the database | ||
// for (Recipe recipe : recipes) { | ||
// model.postRecipe(recipe); | ||
// } | ||
// Get all the recipes from the database sorted oldest to newest | ||
String getAllResponse = model.getRecipeList("oldest-newest", ""); | ||
|
||
// // Get all the recipes from the database sorted alphabetically A-Z (not case sensitive) | ||
// String getAllResponse = model.getRecipeList("a-z", ""); | ||
// Delete the recipes from the database | ||
for (Recipe recipe : recipes) { | ||
model.deleteRecipe(recipe.getId().toString()); | ||
} | ||
|
||
// // Delete the recipes from the database | ||
// for (Recipe recipe : recipes) { | ||
// model.deleteRecipe(recipe.getId().toString()); | ||
// } | ||
// Parse the getAllResponse into a List<Recipe> | ||
List<Recipe> recipeArrayList = Recipe.parseRecipeListFromString(getAllResponse); | ||
|
||
// // Parse the getAllResponse into a List<Recipe> | ||
// List<Recipe> recipeArrayList = Recipe.parseRecipeListFromString(getAllResponse); | ||
|
||
// System.out.println("recipeArrayList: " + recipeArrayList); | ||
|
||
// // Check that the recieved recipes are sorted alphabetically A-Z (not case sensitive) | ||
// assertEquals(3, recipeArrayList.size()); | ||
// assert(recipeArrayList.get(0).getName().equals("American breakfast")); | ||
// // System.out.println(recipeArrayList.get(1).getName()); | ||
// assert(recipeArrayList.get(1).getName().equals("boiled potatoes")); | ||
// assert(recipeArrayList.get(2).getName().equals("Healthy Lunch")); | ||
// } | ||
|
||
// @Test | ||
// public void getRecipeListZToATest() { | ||
|
||
// // Create a new List<Recipe> with 3 recipes | ||
// List<Recipe> recipes = new ArrayList<Recipe>(); | ||
|
||
// recipes.add(new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast")); | ||
// recipes.add(new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch")); | ||
// recipes.add(new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes")); | ||
|
||
|
||
// // Create a new Mock Model that accesses test_user in the database | ||
// Model model = new MockModel(); | ||
|
||
// // Add the recipes to the database | ||
// for (Recipe recipe : recipes) { | ||
// model.postRecipe(recipe); | ||
// } | ||
|
||
// // Get all the recipes from the database sorted alphabetically A-Z (not case sensitive) | ||
// String getAllResponse = model.getRecipeList("z-a", ""); | ||
|
||
// // Delete the recipes from the database | ||
// for (Recipe recipe : recipes) { | ||
// model.deleteRecipe(recipe.getId().toString()); | ||
// } | ||
|
||
// // Parse the getAllResponse into a List<Recipe> | ||
// List<Recipe> recipeArrayList = Recipe.parseRecipeListFromString(getAllResponse); | ||
|
||
// System.out.println("recipeArrayList: " + recipeArrayList); | ||
System.out.println("recipeArrayList: " + recipeArrayList); | ||
|
||
// // Check that the recieved recipes are sorted alphabetically A-Z (not case sensitive) | ||
// assertEquals(3, recipeArrayList.size()); | ||
// assert(recipeArrayList.get(2).getName().equals("American breakfast")); | ||
// // System.out.println(recipeArrayList.get(1).getName()); | ||
// assert(recipeArrayList.get(1).getName().equals("boiled potatoes")); | ||
// assert(recipeArrayList.get(0).getName().equals("Healthy Lunch")); | ||
|
||
// } | ||
// } | ||
// Check that the recieved recipes are sorted alphabetically A-Z (not case sensitive) | ||
assertEquals(3, recipeArrayList.size()); | ||
Check failure on line 74 in app/src/test/java/cse/gradle/Feature16Tests.java GitHub Actions / JUnit Test ReportFeature16Tests.getRecipeListOldToNewTest()
Raw output
|
||
assert(recipes.get(0).getName().equals("American breakfast")); | ||
assert(recipes.get(1).getName().equals("Healthy Lunch")); | ||
assert(recipes.get(2).getName().equals("boiled potatoes")); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.