From 9061e3df654657ae41965dbcd4143ff3c5c9121d Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 03:24:08 +0100 Subject: [PATCH] Added: Customers class for managing Users, Test if a nickname is available --- .../de/hs_fulda/ciip/projjpn/Customers.java | 15 ++++++++++++++ .../hs_fulda/ciip/projjpn/CustomersTest.java | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java create mode 100644 projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java new file mode 100644 index 0000000..f495ca9 --- /dev/null +++ b/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 pool = new HashMap(); + + public boolean nickNameAvailable(String nickname) { + User u = pool.get(nickname); + if (null == u) { + return true; + } + return false; + } +} diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java new file mode 100644 index 0000000..5b6a59d --- /dev/null +++ b/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); + + } + +}