Browse Source

Added: Registering a User + Basic Test

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
edc3cd2c14
  1. 8
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java
  2. 20
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java
  3. 23
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

8
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java

@ -12,4 +12,12 @@ public class Customers {
}
return false;
}
public User registerUser(User user) {
return pool.putIfAbsent(user.nickName, user);
}
public User getByNickname(String nickname) {
return pool.get(nickname);
}
}

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

@ -6,4 +6,24 @@ public class User {
String nickName;
String eMail;
Birthdate birthdate;
public User(String nickName) {
this.nickName = nickName;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getNickName() {
return nickName;
}
public String geteMail() {
return eMail;
}
public Birthdate getBirthdate() {
return birthdate;
}
}

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

@ -14,7 +14,28 @@ public class CustomersTest extends TestCase {
// Then
assertTrue(nicknameIsAvailable);
}
public void test_registerUser() {
// Given
Customers customers = new Customers();
String expectedNickNameInput = "Mougli";
User expectedNewUser = new User(expectedNickNameInput);
// Add a user
customers.registerUser(expectedNewUser);
// Get the expected User
User expectedUser = customers.getByNickname(expectedNickNameInput);
assertTrue(null != expectedNewUser);
String expectedNickNameGotBack = expectedUser.nickName;
System.out.println(expectedNickNameGotBack);
// When
boolean userRegistered = expectedNickNameGotBack.equals(expectedNickNameInput);
// Then
assertTrue(userRegistered);
}
}
Loading…
Cancel
Save