From 66dc3dea9ce7b67e7e83b283a788cacaa8583aea Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 05:37:26 +0100 Subject: [PATCH] Added: Create register and check user data - Test --- .../java/de/hs_fulda/ciip/projjpn/User.java | 12 ++++++ .../hs_fulda/ciip/projjpn/CustomersTest.java | 39 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java index dfac66c..3c1fc87 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/User.java @@ -7,6 +7,18 @@ public class User { String eMail; 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) { this.nickName = nickName; } 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 index 1a2bf5f..f9228c1 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java @@ -120,7 +120,46 @@ public class CustomersTest extends TestCase { } actualRegisteredUsers = customers.getCountOfUsers(); 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); + } + }