diff --git a/src/main/java/CreateUser.java b/src/main/java/CreateUser.java index c078749..ff436fa 100644 --- a/src/main/java/CreateUser.java +++ b/src/main/java/CreateUser.java @@ -77,11 +77,11 @@ class CreateUser { } public String surname() { - return firstName; + return surname; } - public void surname(String firstName) { - this.firstName = firstName; + public void setSurname(String surname) { + this.surname = surname; } public boolean isStayLoggedIn() { diff --git a/src/test/java/CreateUsertTest.java b/src/test/java/CreateUsertTest.java new file mode 100644 index 0000000..5702e2a --- /dev/null +++ b/src/test/java/CreateUsertTest.java @@ -0,0 +1,29 @@ +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class CreateUsertTest { + + @Test + public void testCreateUser() { + String id = "1"; + String userName = "testUser"; + String password = "password123"; + String birthday = "2000-01-01"; + String firstName = "John"; + String surname = "Doe"; + + CreateUser user = new CreateUser(id, userName, password, birthday, firstName, surname); + + assertEquals(id, user.getId()); + assertEquals(userName, user.getUserName()); + assertEquals(birthday, user.getBirthday()); + assertEquals(firstName, user.getFirstName()); + assertEquals(surname, user.surname()); + + // Password should be hashed + assertNotEquals(password, user.getPassword()); + } + + +}