From 866807f244b3f07e13e4ece43941d62bbb6ede27 Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 05:59:07 +0100 Subject: [PATCH] Refactoring: Optimized Structure of Tests --- .../hs_fulda/ciip/projjpn/CustomersTest.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 f9228c1..92669c7 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 @@ -26,10 +26,10 @@ public class CustomersTest extends TestCase { customers.registerUser(userToRegister); // When - boolean nicknameIsTaken = !customers.nickNameAvailable(availableNickname); + boolean nicknameIsTaken = customers.nickNameAvailable(availableNickname); // Then - assertTrue(nicknameIsTaken); + assertFalse(nicknameIsTaken); } public void test_registerSingleUser() { @@ -43,7 +43,8 @@ public class CustomersTest extends TestCase { // Get the expected User User expectedUser = customers.getByNickname(expectedNickNameInput); - assertTrue(null != expectedNewUser); + // + assertNotNull(expectedNewUser); String expectedNickNameGotBack = expectedUser.nickName; // When @@ -78,7 +79,7 @@ public class CustomersTest extends TestCase { for (int i = 0; i < expectedNickNamesInput.length; i++) { // Get user foundUser = customers.getByNickname(expectedNickNamesInput[i]); - assertTrue(null != foundUser); + assertNotNull(foundUser); // When expectedNickNameGotBack = foundUser.nickName; @@ -97,8 +98,8 @@ public class CustomersTest extends TestCase { customers.registerUser(userToRegister); // When - boolean userExists = !customers.nickNameAvailable(userToRemove); - assertTrue(userExists); + boolean userExists = customers.nickNameAvailable(userToRemove); + assertFalse(userExists); // Then User removedUser = customers.deleteUser(userToRemove); @@ -139,11 +140,7 @@ public class CustomersTest extends TestCase { User gotUser = customers.getByNickname(nickName); - // When - boolean foundUser = null != gotUser; - - // Then - assertTrue(foundUser); + assertNotNull(gotUser); // When boolean correctFirstName = "Mia".equals(gotUser.getFirstName());