Browse Source

Added: Remove a registered user + Basic Test

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
fa83071186
  1. 4
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java
  2. 18
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

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

@ -17,6 +17,10 @@ public class Customers {
return pool.putIfAbsent(user.nickName, user); return pool.putIfAbsent(user.nickName, user);
} }
public User deleteUser(String userNickname) {
return pool.remove(userNickname);
}
public User getByNickname(String nickname) { public User getByNickname(String nickname) {
return pool.get(nickname); return pool.get(nickname);
} }

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

@ -88,4 +88,22 @@ public class CustomersTest extends TestCase {
assertTrue(userRegistered); assertTrue(userRegistered);
} }
} }
public void test_removeRegisteredUser() {
// Given
Customers customers = new Customers();
String userToRemove = "beastMaster64";
User userToRegister = new User("beastMaster64");
customers.registerUser(userToRegister);
// When
boolean userExists = !customers.nickNameAvailable(userToRemove);
assertTrue(userExists);
// Then
User removedUser = customers.deleteUser(userToRemove);
assertEquals(userToRemove, removedUser.nickName);
}
} }
Loading…
Cancel
Save