Browse Source

Added: Create register and check user data - Test

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
66dc3dea9c
  1. 12
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java
  2. 39
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

12
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java

@ -7,6 +7,18 @@ public class User {
String eMail; String eMail;
Birthdate birthdate; Birthdate birthdate;
public User(String firstName,
String lastName,
String nickName,
String eMail,
Birthdate birthdate) {
this.firstName = firstName;
this.lastName = lastName;
this.nickName = nickName;
this.eMail = eMail;
this.birthdate = birthdate;
}
public User(String nickName) { public User(String nickName) {
this.nickName = nickName; this.nickName = nickName;
} }

39
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

@ -120,7 +120,46 @@ public class CustomersTest extends TestCase {
} }
actualRegisteredUsers = customers.getCountOfUsers(); actualRegisteredUsers = customers.getCountOfUsers();
assertEquals(expectedRegisteredUsers, actualRegisteredUsers); assertEquals(expectedRegisteredUsers, actualRegisteredUsers);
}
public void test_createRegisterAndCheckUserData() {
// Given
Customers customers = new Customers();
String firstName = "Mia";
String lastName = "Muster";
String nickName = "harley";
String eMail = "mia@muster.de";
Birthdate birthdate = new Birthdate(30, 12, 1997);
User userToCheck = new User(firstName, lastName, nickName, eMail, birthdate);
// Register User
customers.registerUser(userToCheck);
User gotUser = customers.getByNickname(nickName);
// When
boolean foundUser = null != gotUser;
// Then
assertTrue(foundUser);
// When
boolean correctFirstName = "Mia".equals(gotUser.getFirstName());
boolean correctLastName = "Muster".equals(gotUser.getLastName());
boolean correctNickName = "harley".equals(gotUser.getNickName());
boolean correctEMail = "mia@muster.de".equals(gotUser.geteMail());
boolean correctBirthdate = birthdate.toString().equals(gotUser.birthdate.toString());
// Then
assertTrue(correctFirstName);
assertTrue(correctLastName);
assertTrue(correctNickName);
assertTrue(correctEMail);
assertTrue(correctBirthdate);
} }
} }
Loading…
Cancel
Save