Skip to content

Commit

Permalink
14 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hashreds committed Dec 6, 2023
1 parent 6793a57 commit a0111b6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 22 deletions.
37 changes: 15 additions & 22 deletions app/src/test/java/cse/gradle/Feature14Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@
import java.util.List;


class Feature14Tests extends HTTPServerTests{
class Feature14Tests extends HTTPServerTests {
/* --------------------------------- UNIT TESTS --------------------------------- */
@Test
void checkLoginError() {
Server.stopServer();
@Test
void editingTypeTags() {
Recipe r1 = new Recipe("eggs, bacon", "cook for 10 minutes", "breakfast", "American breakfast");
Recipe r2 = new Recipe("salmon, salad", "cook for 20 minutes", "lunch", "Healthy Lunch");
Recipe r3 = new Recipe("potatoes", "boil the potatoes", "dinner", "boiled potatoes");
List<Recipe> rList = new ArrayList<>();
rList.add(r1);
rList.add(r2);
rList.add(r3);

Model model = new MockModel();
String response = model.performLoginRequest("test_user", "password");
String error = "Error: Server down";
assertEquals(error, response);
assertEquals(rList.get(0).getCategory(), "breakfast");
assertEquals(rList.get(1).getCategory(), "lunch");
assertEquals(rList.get(2).getCategory(), "dinner");
}


/* --------------------------------- BDD TESTS --------------------------------- */
@Test
Expand All @@ -47,18 +53,5 @@ void manipulatingTypeTagsInView() {
assertEquals(rList1.get(0).getCategory(), "breakfast");
assertEquals(rList1.get(1).getCategory(), "lunch");
assertEquals(rList1.get(2).getCategory(), "dinner");
@Test
void completeServerErrorTest() {
// login with test user
Model model = new MockModel();
String retrievedUserId = model.performLoginRequest("test_user", "password");
assertEquals(MockModel.mockUserId, retrievedUserId);

// cut connection and ask for recipe
Server.stopServer();
Recipe originalRecipe = new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes");
String response = model.postRecipe(originalRecipe);
String error = "Error: Server down";
assertEquals(error, response);
}
}
}
28 changes: 28 additions & 0 deletions app/src/test/java/cse/gradle/Feature20Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import org.junit.jupiter.api.Test;

import cse.gradle.Server.Server;

public class Feature20Tests extends HTTPServerTests{
/*
* --------------------------------- UNIT TESTS ---------------------------------
Expand All @@ -24,4 +26,30 @@ public void testLoginEndpoint() {
assertEquals(MockModel.mockUserId, retrievedUserId);
}

@Test
void checkLoginError() {
Server.stopServer();

Model model = new MockModel();
String response = model.performLoginRequest("test_user", "password");
String error = "Error: Server down";
assertEquals(error, response);
}

// BDD TEST
@Test
void completeServerErrorTest() {
// login with test user
Model model = new MockModel();
String retrievedUserId = model.performLoginRequest("test_user", "password");
assertEquals(MockModel.mockUserId, retrievedUserId);

// cut connection and ask for recipe
Server.stopServer();
Recipe originalRecipe = new Recipe("potatoes", "boil the potatoes", "brunch", "boiled potatoes");
String response = model.postRecipe(originalRecipe);
String error = "Error: Server down";
assertEquals(error, response);
}

}

0 comments on commit a0111b6

Please sign in to comment.