diff --git a/src/test/java/CreateUserTest.java b/src/test/java/CreateUserTest.java index 49c202f..f3e4c19 100644 --- a/src/test/java/CreateUserTest.java +++ b/src/test/java/CreateUserTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; import java.io.File; import java.util.List; +import static org.junit.jupiter.api.Assertions.*; class CreateUserTest { @@ -58,7 +59,38 @@ class CreateUserTest { // Clean up - delete the test file after the test File file = new File(filename); file.delete(); + } + + @Test + public void testUpdateStayLoggedIn() { + String filename = "test_users.json"; + String id = "3"; + String userName = "testUser3"; + String password = "password789"; + String birthday = "2002-01-01"; + String firstName = "Jack"; + String surname = "Doe"; + + // Create a user + CreateUser user = new CreateUser(id, userName, password, birthday, firstName, surname); + + // Save user to JSON file + user.saveToJsonFile(filename); + + // Update stayLoggedIn flag + CreateUser.updateStayLoggedIn(filename, userName, true); + + // Read updated user from JSON file + List userList = CreateUser.readUserListFromJsonFile(filename); + + // Ensure that the stayLoggedIn flag is updated + assertTrue(userList.get(0).isStayLoggedIn()); + + // Clean up - delete the test file after the test + File file = new File(filename); + file.delete(); + } } -} +