Browse Source

test_Error for already existing username

remotes/origin/server
Richard Schmidt 11 months ago
parent
commit
74661efb36
  1. 19
      src/test/java/SignUpGUITest.java
  2. 9
      user.json

19
src/test/java/SignUpGUITest.java

@ -62,13 +62,30 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
assertTrue(isErrorMessageShown(signUpGUI)); assertTrue(isErrorMessageShown(signUpGUI));
} }
@Test
void testExistingUsername() {
SignUpGUI signUpGUI = new SignUpGUI();
signUpGUI.getUsernameField().setText("existinguser");
signUpGUI.getPasswordField().setText("password");
signUpGUI.getConfirmPasswordField().setText("password");
signUpGUI.getBirthdayField().setText("1990-01-01");
signUpGUI.getFirstNameField().setText("John");
signUpGUI.getSurnameField().setText("Doe");
signUpGUI.getSignUpButton().doClick(); // Simulate button click
// Make sure an error message dialog is shown
assertTrue(isErrorMessageShown(signUpGUI));
}
// Helper method to check if an error message dialog is shown // Helper method to check if an error message dialog is shown
private boolean isErrorMessageShown(JFrame frame) { private boolean isErrorMessageShown(JFrame frame) {
Component[] components = frame.getComponents(); Component[] components = frame.getComponents();
for (Component component : components) { for (Component component : components) {
if (component instanceof JOptionPane) { if (component instanceof JOptionPane) {
return false;
return false;
} }
} }
return true; return true;
} }

9
user.json

@ -34,5 +34,14 @@
"firstName": "John", "firstName": "John",
"surname": "Doe", "surname": "Doe",
"stayLoggedIn": false "stayLoggedIn": false
},
{
"id": "731fda82-6b51-4f3f-ae97-c9b01c9b4a1a",
"userName": "existinguser",
"password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
"birthday": "1990-01-01",
"firstName": "John",
"surname": "Doe",
"stayLoggedIn": false
} }
] ]
Loading…
Cancel
Save