Browse Source

Added: Customers class for managing Users, Test if a nickname is available

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
9061e3df65
  1. 15
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java
  2. 20
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

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

@ -0,0 +1,15 @@
package de.hs_fulda.ciip.projjpn;
import java.util.HashMap;
public class Customers {
HashMap<String, User> pool = new HashMap<String, User>();
public boolean nickNameAvailable(String nickname) {
User u = pool.get(nickname);
if (null == u) {
return true;
}
return false;
}
}

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

@ -0,0 +1,20 @@
package de.hs_fulda.ciip.projjpn;
import junit.framework.TestCase;
public class CustomersTest extends TestCase {
public void test_nicknameIsFree() {
// Given
Customers customers = new Customers();
String availableNickname = "beastMaster64";
// When
boolean nicknameIsAvailable = customers.nickNameAvailable(availableNickname);
// Then
assertTrue(nicknameIsAvailable);
}
}
Loading…
Cancel
Save