]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 19:09:53 +0000 (20:09 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 19:32:22 +0000 (20:32 +0100)
- added unit test case for LoginUser class (only as a POJO)
- used new EnumUtils.compare() method to compare enumerations null-safe.
  Under normal conditions, this won't be the case. The only case (currently)
  happens that a NPE is being thrown when an "empty" LoginUser object is being
  compared with an object with all required fields set (those which are not
  null or optional)
- sorted members
- enumeration's constructors can have exceptions but they cannot be tested?
- ignored some files from TestNG
- updated jar(s)

.gitignore
lib/jcore-utils.jar
src/org/mxchange/jusercore/model/user/LoginUser.java
src/org/mxchange/jusercore/model/user/profilemodes/ProfileMode.java
src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java
src/org/mxchange/jusercore/model/utils/UserUtils.java
test/org/mxchange/jusercore/model/UserTestData.java
test/org/mxchange/jusercore/model/user/LoginUserTest.java [new file with mode: 0644]
test/org/mxchange/jusercore/model/utils/UserUtilsTest.java

index cf4a7c5b0dae6e64df0a9d42472e823cbac70ce2..38d2e2c321698d93f6b1965aa7438cbab421f4f9 100644 (file)
@@ -9,3 +9,4 @@ nbproject/*~
 /*.properties
 .~lock*
 .gitcommits
+jacoco.exec-*
index 6a8081ed21ee5fada3c798c55883d538b1dd62e5..97e8674869d4b24ed517731010615099ef93c9f9 100644 (file)
Binary files a/lib/jcore-utils.jar and b/lib/jcore-utils.jar differ
index e934e408b2f2f83e1a03e3c496c1760f72a5b894..48374fc3a41410552c582b6e2351151665079c88 100644 (file)
@@ -41,7 +41,10 @@ import org.apache.commons.lang3.StringUtils;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.utils.ContactUtils;
+import org.mxchange.jcoreutils.bool.BooleanUtils;
 import org.mxchange.jcoreutils.comparable.ComparableUtils;
+import org.mxchange.jcoreutils.enums.EnumUtils;
+import org.mxchange.jcoreutils.number.SafeNumberUtils;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
@@ -162,7 +165,7 @@ public class LoginUser implements User {
        private ProfileMode userProfileMode;
 
        /**
-        * Default constructor
+        * Default constructor for JPA entity manager
         */
        public LoginUser () {
        }
@@ -230,18 +233,24 @@ public class LoginUser implements User {
 
                // Init comparitors
                final int comparitors[] = {
-                       // First contact
+                       // First account status
+                       EnumUtils.compare(this.getUserAccountStatus(), user.getUserAccountStatus()),
+                       // ... confirm key
+                       StringUtils.compare(this.getUserConfirmKey(), user.getUserConfirmKey()),
+                       // ... contact instance
                        ContactUtils.compare(this.getUserContact(), user.getUserContact()),
+                       // ... user id (primary key
+                       SafeNumberUtils.compare(this.getUserId(), user.getUserId()),
+                       // ... last locked
+                       StringUtils.compare(String.valueOf(this.getUserLastLocked()), String.valueOf(user.getUserLastLocked())),
+                       // ... last locked reason
+                       StringUtils.compare(this.getUserLastLockedReason(), user.getUserLastLockedReason()),
+                       // ... "must change password" flag
+                       BooleanUtils.compare(this.getUserMustChangePassword(), user.getUserMustChangePassword()),
                        // ... then user name (case-insensitive)
                        StringUtils.compareIgnoreCase(this.getUserName(), user.getUserName()),
-                       // ... account status
-                       this.getUserAccountStatus().compareTo(user.getUserAccountStatus()),
                        // ... profile mode
-                       this.getUserProfileMode().compareTo(user.getUserProfileMode()),
-                       // ... "must change password" flag
-                       Boolean.compare(this.getUserMustChangePassword(), user.getUserMustChangePassword()),
-                       // ... confirm key
-                       StringUtils.compare(this.getUserConfirmKey(), user.getUserConfirmKey())
+                       EnumUtils.compare(this.getUserProfileMode(), user.getUserProfileMode())
                };
 
                // Check all values
@@ -269,12 +278,16 @@ public class LoginUser implements User {
                        return false;
                } else if (!Objects.equals(this.getUserId(), user.getUserId())) {
                        return false;
-               } else if (!Objects.equals(this.getUserLocale(), user.getUserLocale())) {
+               } else if (!Objects.equals(this.getUserLastLocked(), user.getUserLastLocked())) {
                        return false;
-               } else if (!Objects.equals(this.getUserName(), user.getUserName())) {
+               } else if (!Objects.equals(this.getUserLastLockedReason(), user.getUserLastLockedReason())) {
+                       return false;
+               } else if (!Objects.equals(this.getUserLocale(), user.getUserLocale())) {
                        return false;
                } else if (!Objects.equals(this.getUserMustChangePassword(), user.getUserMustChangePassword())) {
                        return false;
+               } else if (!Objects.equals(this.getUserName(), user.getUserName())) {
+                       return false;
                } else if (!Objects.equals(this.getUserProfileMode(), user.getUserProfileMode())) {
                        return false;
                }
@@ -426,6 +439,8 @@ public class LoginUser implements User {
                hash = 83 * hash + Objects.hashCode(this.getUserConfirmKey());
                hash = 83 * hash + Objects.hashCode(this.getUserContact());
                hash = 83 * hash + Objects.hashCode(this.getUserId());
+               hash = 83 * hash + Objects.hashCode(this.getUserLastLocked());
+               hash = 83 * hash + Objects.hashCode(this.getUserLastLockedReason());
                hash = 83 * hash + Objects.hashCode(this.getUserLocale());
                hash = 83 * hash + Objects.hashCode(this.getUserMustChangePassword());
                hash = 83 * hash + Objects.hashCode(this.getUserName());
index abab3acc38368d9f05b71ff5ca254ea8775c95a9..57e706e07892adb471647b1956e4e29dc0a4af1f 100644 (file)
@@ -51,15 +51,6 @@ public enum ProfileMode implements Serializable {
         * @param messageKey Message key
         */
        private ProfileMode (final String messageKey) {
-               // Validate all parameter
-               if (null == messageKey) {
-                       // Throw NPE
-                       throw new NullPointerException("messageKey is null"); //NOI18N
-               } else if (messageKey.isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("messageKey is empty"); //NOI18N
-               }
-
                // Set all enum fields
                this.messageKey = messageKey;
        }
index 6da2179c34678ffd28e95edad50b0f13cf4ca601..54821a9c019c2948b9f7e36029674f0eb6f7ad63 100644 (file)
@@ -57,21 +57,6 @@ public enum UserAccountStatus implements Serializable {
         * @param styleClass CSS style class
         */
        private UserAccountStatus (final String messageKey, final String styleClass) {
-               // Validate parameter
-               if (null == messageKey) {
-                       // Throw NPE
-                       throw new NullPointerException("messageKey is null"); //NOI18N
-               } else if (messageKey.isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("messageKey is empty"); //NOI18N
-               } else if (null == styleClass) {
-                       // Throw NPE
-                       throw new NullPointerException("styleClass is null"); //NOI18N
-               } else if (styleClass.isEmpty()) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("styleClass is empty"); //NOI18N
-               }
-
                // Set it here
                this.messageKey = messageKey;
                this.styleClass = styleClass;
index 3a2ef573b75cdd2be4d56f19b1ad87bab97353ee..566de78cda0abf0f52b2b940d7386a6f8c827955 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Date;
 import java.util.Objects;
 import java.util.Properties;
 import java.util.Random;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.utils.ContactUtils;
 import org.mxchange.jusercore.model.user.User;
 
@@ -132,7 +133,7 @@ public class UserUtils implements Serializable {
                }
 
                // Is contact set?
-               if (!Objects.equals(sourceUser.getUserContact(), targetUser.getUserContact())) {
+               if (sourceUser.getUserContact() instanceof Contact && targetUser.getUserContact() instanceof Contact && !Objects.equals(sourceUser.getUserContact(), targetUser.getUserContact())) {
                        // Copy also contact data
                        ContactUtils.copyContactData(sourceUser.getUserContact(), targetUser.getUserContact());
                }
@@ -140,7 +141,9 @@ public class UserUtils implements Serializable {
                // Copy other data
                targetUser.setUserAccountStatus(sourceUser.getUserAccountStatus());
                targetUser.setUserConfirmKey(sourceUser.getUserConfirmKey());
+               targetUser.setUserContact(sourceUser.getUserContact());
                targetUser.setUserEncryptedPassword(sourceUser.getUserEncryptedPassword());
+               targetUser.setUserEntryCreated(sourceUser.getUserEntryCreated());
                targetUser.setUserEntryUpdated(sourceUser.getUserEntryUpdated());
                targetUser.setUserName(sourceUser.getUserName());
                targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword());
index 952bdb3f3fcdec83c808710f95ae29f7e8e1b47a..85892bc6fa0c95e858591377d21cb82b6c31683b 100644 (file)
@@ -34,6 +34,8 @@ public class UserTestData {
 
        public static final Short CONTACT_HOUSE_NUMBER = 123;
 
+       public static final String USER_CONFIRM_KEY = "zyx098"; //NOI18N
+
        public static final String USER_ENCRYPTED_PASSWORD1 = "abc123"; //NOI18N
 
        public static final String USER_ENCRYPTED_PASSWORD2 = "xyz456"; //NOI18N
diff --git a/test/org/mxchange/jusercore/model/user/LoginUserTest.java b/test/org/mxchange/jusercore/model/user/LoginUserTest.java
new file mode 100644 (file)
index 0000000..07698da
--- /dev/null
@@ -0,0 +1,466 @@
+/*
+ * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.user;
+
+import java.util.Date;
+import java.util.Locale;
+import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
+import org.mxchange.jusercore.model.UserTestData;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Testing cases for LoginUser class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class LoginUserTest {
+
+       /**
+        * Default constructor
+        */
+       public LoginUserTest () {
+       }
+
+       @DataProvider (name = "different-user-provider")
+       public Object[][] createDifferentUser () {
+               return new Object[][]{
+                       // Empty instances left versus instance with all required fiels right
+                       {
+                               new LoginUser(),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Empty instances right versus instance with all required fiels left
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser()
+                       },
+                       // Different user names
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser(
+                               UserTestData.USER_NAME2,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Different profile mode
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.INVISIBLE,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Different "must change password" flag
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.FALSE, UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Different account status
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.CONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Different contact instance
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD2,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact(
+                               PersonalTitle.MR,
+                               UserTestData.CONTACT_FIRST_NAME,
+                               UserTestData.CONTACT_FAMILY_NAME,
+                               UserTestData.CONTACT_FAKE_COUNTRY,
+                               Boolean.TRUE
+                               ))
+                       }
+               };
+       }
+
+       @DataProvider (name = "one-user-provider")
+       public Object[][] createOneUser () {
+               return new Object[][]{
+                       {
+                               // Empty instances (the JPA invokes this)
+                               new LoginUser()
+                       }, {
+                               // Instance with all required fields set
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       }
+               };
+       }
+
+       @DataProvider (name = "same-user-provider")
+       public Object[][] createSameUser () {
+               return new Object[][]{
+                       // Empty instances (the JPA invokes this)
+                       {
+                               new LoginUser(),
+                               new LoginUser()
+                       },
+                       // Instances with all required values
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ), new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       }
+               };
+       }
+
+       @Test (description = "Tests constructor with empty userEncryptedPassword set", expectedExceptions = IllegalArgumentException.class)
+       public void testEmptyUserEncryptedPassword () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  "", //NOI18N
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with an empty userName set", expectedExceptions = IllegalArgumentException.class)
+       public void testEmptyUserName () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  "", //NOI18N
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userAccountStatus set", expectedExceptions = NullPointerException.class)
+       public void testNullUserAccountStatus () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  null,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userContact set", expectedExceptions = NullPointerException.class)
+       public void testNullUserContact () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  null
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userEncryptedPassword set", expectedExceptions = NullPointerException.class)
+       public void testNullUserEncryptedPassword () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  null,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userMustChangePassword set", expectedExceptions = NullPointerException.class)
+       public void testNullUserMustChangePassword () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  ProfileMode.PUBLIC,
+                                  null,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userName set", expectedExceptions = NullPointerException.class)
+       public void testNullUserName () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  null,
+                                  ProfileMode.PUBLIC,
+                                  Boolean.TRUE,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with null userProfileMode set", expectedExceptions = NullPointerException.class)
+       public void testNullUserProfileMode () {
+               // Should throw an exception
+               final User user = new LoginUser(
+                                  UserTestData.USER_NAME1,
+                                  null,
+                                  Boolean.TRUE,
+                                  UserTestData.USER_ENCRYPTED_PASSWORD1,
+                                  UserAccountStatus.UNCONFIRMED,
+                                  new UserContact()
+                  );
+
+               // Should never be reached
+               Assert.fail("Providing a null for Parameter userName should always throw a NPE. user=" + user); //NOI18N
+       }
+
+       @Test (description = "Tests method User.compareTo() with different User instance", dataProvider = "different-user-provider")
+       public void testUserCompareToDifferentserInstance (final User user1, final User user2) {
+               // Should always be zero
+               Assert.assertNotEquals(user1.compareTo(user2), 0);
+       }
+
+       @Test (description = "Tests method User.compareTo() with different userLastLocked set", dataProvider = "same-user-provider")
+       public void testUserCompareToDifferentserLastLocked (final User user1, final User user2) {
+               // Set userLastLocked
+               user2.setUserLastLocked(new Date());
+
+               // Should always be zero
+               Assert.assertNotEquals(user1.compareTo(user2), 0);
+
+               // Set userLastLocked back to null
+               user2.setUserLastLocked(null);
+       }
+
+       @Test (description = "Tests method User.compareTo() with a null user", dataProvider = "one-user-provider", expectedExceptions = NullPointerException.class)
+       public void testUserCompareToNullUser (final User user1) {
+               // Should throw an exception
+               final int comparison = user1.compareTo(null);
+
+               // Should never be reached
+               Assert.fail("Providing a null reference to User.compareTo() should always throw a NPE. comparison=" + comparison);
+       }
+
+       @Test (description = "Tests method User.compareTo() with same User instance", dataProvider = "same-user-provider")
+       public void testUserCompareToSameUserInstance (final User user1, final User user2) {
+               // Should always be zero
+               Assert.assertEquals(user1.compareTo(user2), 0);
+       }
+
+       @Test (description = "Tests method User.equals() with same User instance", dataProvider = "one-user-provider")
+       public void testUserEqualsNullUserInstance (final User user) {
+               // Should always be false
+               Assert.assertFalse(user.equals(null));
+       }
+
+       @Test (description = "Tests method User.equals() with same User instance", dataProvider = "one-user-provider")
+       public void testUserEqualsOtherInstance (final User user) {
+               // Should always be false
+               Assert.assertFalse(user.equals(this));
+       }
+
+       @Test (description = "Tests method User.equals() with same User instance", dataProvider = "same-user-provider")
+       public void testUserEqualsSameUserInstance (final User user1, final User user2) {
+               // Should always be true
+               Assert.assertTrue(user1.equals(user2));
+       }
+
+       @Test (description = "Tests method User.equals() with different userConfirmKey set", dataProvider = "same-user-provider")
+       public void testUserEqualsToDifferentUserConfirmKey (final User user1, final User user2) {
+               // Set userConfirmKey
+               user2.setUserConfirmKey(UserTestData.USER_CONFIRM_KEY);
+
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+
+               // Set userConfirmKey back to null
+               user2.setUserConfirmKey(null);
+       }
+
+       @Test (description = "Tests method User.equals() with different userId set", dataProvider = "same-user-provider")
+       public void testUserEqualsToDifferentUserId (final User user1, final User user2) {
+               // Set userId
+               user2.setUserId(1l);
+
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+
+               // Set userId back to null
+               user2.setUserId(null);
+       }
+
+       @Test (description = "Tests method User.equals() with different User instance", dataProvider = "different-user-provider")
+       public void testUserEqualsToDifferentUserInstance (final User user1, final User user2) {
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+       }
+
+       @Test (description = "Tests method User.equals() with different userLastLocked set", dataProvider = "same-user-provider")
+       public void testUserEqualsToDifferentUserLastLocked (final User user1, final User user2) {
+               // Set userLastLocked
+               user2.setUserLastLocked(new Date());
+
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+
+               // Set userLastLocked back to null
+               user2.setUserLastLocked(null);
+       }
+
+       @Test (description = "Tests method User.equals() with different userLastLockedReason set", dataProvider = "same-user-provider")
+       public void testUserEqualsToDifferentUserLastLockedReason (final User user1, final User user2) {
+               // Set userLastLockedReason
+               user2.setUserLastLockedReason("Some test reason");
+
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+
+               // Set userLastLockedReason back to null
+               user2.setUserLastLockedReason(null);
+       }
+
+       @Test (description = "Tests method User.equals() with different userLocale set", dataProvider = "same-user-provider")
+       public void testUserEqualsToDifferentUserLocale (final User user1, final User user2) {
+               // Set userLocale
+               user2.setUserLocale(Locale.FRANCE);
+
+               // Should always be false
+               Assert.assertFalse(user1.equals(user2));
+
+               // Set userLocale back to null
+               user2.setUserLocale(null);
+       }
+
+}
index d4e903af1030f4de55e47254a528f9a21216aa4d..ae2f39d3f0ae9160ec52aefcb69ab879bd323582 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jusercore.model.utils;
 import java.text.DateFormat;
 import java.util.Date;
 import java.util.Locale;
+import java.util.Objects;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.UserContact;
 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
@@ -32,7 +33,8 @@ import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
- *
+ * Test cases for utility class UserUtils
+ * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
 public class UserUtilsTest {
@@ -46,6 +48,30 @@ public class UserUtilsTest {
        @DataProvider (name = "different-user-provider")
        public Object[][] createDifferentNullUser () {
                return new Object[][]{
+                       // Empty instances left versus instance with all required fiels right
+                       {
+                               new LoginUser(),
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       },
+                       // Empty instances right versus instance with all required fiels left
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               new LoginUser()
+                       },
                        // Different user names
                        {
                                new LoginUser(
@@ -229,7 +255,7 @@ public class UserUtilsTest {
                UserUtils.copyUserData(user1, user2);
 
                // They must be identical
-               Assert.assertEquals(user2, user1);
+               Assert.assertTrue(Objects.equals(user2, user1));
        }
 
        @Test (description = "Tests method UserUtils.copyUserData() when sourceUser is null", dataProvider = "left-null-user-provider", expectedExceptions = NullPointerException.class)
@@ -250,52 +276,6 @@ public class UserUtilsTest {
                UserUtils.copyUserData(user1, user2);
        }
 
-       @Test (description = "Tests method UserUtils.compare() when different instance is provided", dataProvider = "different-user-provider")
-       public void testUserCompareDifferent (final User user1, final User user2) {
-               // Should always be not zero
-               Assert.assertNotEquals(UserUtils.compare(user1, user2), 0);
-       }
-
-       @Test (description = "Tests method UserUtils.compare() when left User instance is null", dataProvider = "left-null-user-provider")
-       public void testUserCompareLeftNull (final User user1, final User user2) {
-               // Should always be -1
-               Assert.assertEquals(UserUtils.compare(user1, user2), -1);
-       }
-
-       @Test (description = "Tests method UserUtils.compare() when right User instance is null", dataProvider = "right-null-user-provider")
-       public void testUserCompareRightNull (final User user1, final User user2) {
-               // Should always be 1
-               Assert.assertEquals(UserUtils.compare(user1, user2), 1);
-       }
-
-       @Test (description = "Tests method UserUtils.compare() when same instance is provided", dataProvider = "same-user-provider")
-       public void testUserCompareSame (final User user1, final User user2) {
-               // Should always be zero
-               Assert.assertEquals(UserUtils.compare(user1, user2), 0);
-       }
-
-       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when user instance is null", expectedExceptions = NullPointerException.class)
-       public void testFormattedTimestampNullUser () {
-               // Should always throw an exception
-               UserUtils.formatTimestampFromUser(null, new Date());
-       }
-
-       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when date instance is null", expectedExceptions = NullPointerException.class)
-       public void testFormattedTimestampNullDate () {
-               // Init user instance
-               final User user = new LoginUser();
-               user.setUserLocale(Locale.GERMANY);
-
-               // Should always throw an exception
-               UserUtils.formatTimestampFromUser(user, null);
-       }
-
-       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when user's locale instance is null", expectedExceptions = NullPointerException.class)
-       public void testFormattedTimestampNullUserLocale () {
-               // Should always throw an exception
-               UserUtils.formatTimestampFromUser(new LoginUser(), new Date());
-       }
-
        @Test (description = "Tests method UserUtils.formatTimestampFromUser() if it returns a timestamp in formatted expected way")
        public void testFormattedTimestampFormat () {
                // Init date instance
@@ -315,54 +295,68 @@ public class UserUtilsTest {
                Assert.assertEquals(formatted, format.format(date));
        }
 
-       @Test (description = "Tests method UserUtils.generateRandomUserName() if it returns a non-empty string")
-       public void testRandomUserName () {
-               // Should not be empty
-               Assert.assertFalse(UserUtils.generateRandomUserName().isEmpty());
-       }
-
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null user", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUser () {
-               // Should always throw an exception
-               UserUtils.getAllUserFields(null);
-       }
-
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userEntryCreated", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserEntryCreated () {
+       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when date instance is null", expectedExceptions = NullPointerException.class)
+       public void testFormattedTimestampNullDate () {
                // Init user instance
                final User user = new LoginUser();
+               user.setUserLocale(Locale.GERMANY);
 
                // Should always throw an exception
-               UserUtils.getAllUserFields(user);
+               UserUtils.formatTimestampFromUser(user, null);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userId", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserId () {
-               // Init user instance and set needed fields to get pass above if() block
-               final User user = new LoginUser();
-               user.setUserEntryCreated(new Date());
+       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when user instance is null", expectedExceptions = NullPointerException.class)
+       public void testFormattedTimestampNullUser () {
+               // Should always throw an exception
+               UserUtils.formatTimestampFromUser(null, new Date());
+       }
 
+       @Test (description = "Tests method UserUtils.formatTimestampFromUser() when user's locale instance is null", expectedExceptions = NullPointerException.class)
+       public void testFormattedTimestampNullUserLocale () {
                // Should always throw an exception
-               UserUtils.getAllUserFields(user);
+               UserUtils.formatTimestampFromUser(new LoginUser(), new Date());
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with an invalid userId", expectedExceptions = IllegalArgumentException.class)
-       public void testGetAllUserFieldsInvalidUserId () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with empty user.userContact.contactFamilyName", expectedExceptions = IllegalArgumentException.class)
+       public void testGetAllUserFieldsEmptyUserContactFamilyName () {
+               // Init contact instance and set neeed fields
+               final Contact contact = new UserContact();
+               contact.setContactId(1l);
+               contact.setContactPersonalTitle(PersonalTitle.MR);
+               contact.setContactEntryCreated(new Date());
+               contact.setContactFirstName(UserTestData.CONTACT_FIRST_NAME);
+               contact.setContactFamilyName(""); //NOI18N
+
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
-               user.setUserId(-1l);
+               user.setUserId(1l);
+               user.setUserName(UserTestData.USER_NAME1);
+               user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
+               user.setUserContact(contact);
+               user.setUserLocale(Locale.GERMANY);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userName", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserName () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with an empty user.userContact.contactFirstName", expectedExceptions = IllegalArgumentException.class)
+       public void testGetAllUserFieldsEmptyUserContactFirstName () {
+               // Init contact instance and set neeed fields
+               final Contact contact = new UserContact();
+               contact.setContactId(1l);
+               contact.setContactPersonalTitle(PersonalTitle.MR);
+               contact.setContactEntryCreated(new Date());
+               contact.setContactFirstName(""); //NOI18N
+
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
                user.setUserId(1l);
+               user.setUserName(UserTestData.USER_NAME1);
+               user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
+               user.setUserContact(contact);
+               user.setUserLocale(Locale.GERMANY);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
@@ -380,76 +374,61 @@ public class UserUtilsTest {
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userAccountStatus", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserAccountStatus () {
-               // Init user instance and set needed fields to get pass above if() block
-               final User user = new LoginUser();
-               user.setUserEntryCreated(new Date());
-               user.setUserId(1l);
-               user.setUserName(UserTestData.USER_NAME1);
-
-               // Should always throw an exception
-               UserUtils.getAllUserFields(user);
-       }
+       @Test (description = "Tests method UserUtils.getAllUserFields() with an invalid userContact.contactId", expectedExceptions = IllegalArgumentException.class)
+       public void testGetAllUserFieldsInvalidUserContactId () {
+               // Init contact instance and set neeed fields
+               final Contact contact = new UserContact();
+               contact.setContactId(-1l);
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserContact () {
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
                user.setUserId(1l);
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
+               user.setUserContact(contact);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact.contactId", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserContactId () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with an invalid userId", expectedExceptions = IllegalArgumentException.class)
+       public void testGetAllUserFieldsInvalidUserId () {
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
-               user.setUserId(1l);
-               user.setUserName(UserTestData.USER_NAME1);
-               user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
-               user.setUserContact(new UserContact());
+               user.setUserId(-1l);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with an invalid userContact.contactId", expectedExceptions = IllegalArgumentException.class)
-       public void testGetAllUserFieldsInvalidUserContactId () {
-               // Init contact instance and set neeed fields
-               final Contact contact = new UserContact();
-               contact.setContactId(-1l);
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null user", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUser () {
+               // Should always throw an exception
+               UserUtils.getAllUserFields(null);
+       }
 
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userAccountStatus", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserAccountStatus () {
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
                user.setUserId(1l);
                user.setUserName(UserTestData.USER_NAME1);
-               user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
-               user.setUserContact(contact);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact.contactPersonalTitle", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserContactPersonalTitle () {
-               // Init contact instance and set neeed fields
-               final Contact contact = new UserContact();
-               contact.setContactId(1l);
-
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContact () {
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
                user.setUserId(1l);
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
-               user.setUserContact(contact);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
@@ -474,13 +453,14 @@ public class UserUtilsTest {
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userLocale", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserLocale () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with null user.userContact.contactFamilyName", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContactFamilyName () {
                // Init contact instance and set neeed fields
                final Contact contact = new UserContact();
                contact.setContactId(1l);
                contact.setContactPersonalTitle(PersonalTitle.MR);
                contact.setContactEntryCreated(new Date());
+               contact.setContactFirstName(UserTestData.CONTACT_FIRST_NAME);
 
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
@@ -489,6 +469,7 @@ public class UserUtilsTest {
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
                user.setUserContact(contact);
+               user.setUserLocale(Locale.GERMANY);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
@@ -515,36 +496,25 @@ public class UserUtilsTest {
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with an empty user.userContact.contactFirstName", expectedExceptions = IllegalArgumentException.class)
-       public void testGetAllUserFieldsEmptyUserContactFirstName () {
-               // Init contact instance and set neeed fields
-               final Contact contact = new UserContact();
-               contact.setContactId(1l);
-               contact.setContactPersonalTitle(PersonalTitle.MR);
-               contact.setContactEntryCreated(new Date());
-               contact.setContactFirstName(""); //NOI18N
-
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact.contactId", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContactId () {
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
                user.setUserEntryCreated(new Date());
                user.setUserId(1l);
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
-               user.setUserContact(contact);
-               user.setUserLocale(Locale.GERMANY);
+               user.setUserContact(new UserContact());
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with null user.userContact.contactFamilyName", expectedExceptions = NullPointerException.class)
-       public void testGetAllUserFieldsNullUserContactFamilyName () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userContact.contactPersonalTitle", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContactPersonalTitle () {
                // Init contact instance and set neeed fields
                final Contact contact = new UserContact();
                contact.setContactId(1l);
-               contact.setContactPersonalTitle(PersonalTitle.MR);
-               contact.setContactEntryCreated(new Date());
-               contact.setContactFirstName(UserTestData.CONTACT_FIRST_NAME);
 
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
@@ -553,21 +523,37 @@ public class UserUtilsTest {
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
                user.setUserContact(contact);
-               user.setUserLocale(Locale.GERMANY);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
        }
 
-       @Test (description = "Tests method UserUtils.getAllUserFields() with empty user.userContact.contactFamilyName", expectedExceptions = IllegalArgumentException.class)
-       public void testGetAllUserFieldsEmptyUserContactFamilyName () {
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userEntryCreated", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserEntryCreated () {
+               // Init user instance
+               final User user = new LoginUser();
+
+               // Should always throw an exception
+               UserUtils.getAllUserFields(user);
+       }
+
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userId", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserId () {
+               // Init user instance and set needed fields to get pass above if() block
+               final User user = new LoginUser();
+               user.setUserEntryCreated(new Date());
+
+               // Should always throw an exception
+               UserUtils.getAllUserFields(user);
+       }
+
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userLocale", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserLocale () {
                // Init contact instance and set neeed fields
                final Contact contact = new UserContact();
                contact.setContactId(1l);
                contact.setContactPersonalTitle(PersonalTitle.MR);
                contact.setContactEntryCreated(new Date());
-               contact.setContactFirstName(UserTestData.CONTACT_FIRST_NAME);
-               contact.setContactFamilyName(""); //NOI18N
 
                // Init user instance and set needed fields to get pass above if() block
                final User user = new LoginUser();
@@ -576,7 +562,17 @@ public class UserUtilsTest {
                user.setUserName(UserTestData.USER_NAME1);
                user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
                user.setUserContact(contact);
-               user.setUserLocale(Locale.GERMANY);
+
+               // Should always throw an exception
+               UserUtils.getAllUserFields(user);
+       }
+
+       @Test (description = "Tests method UserUtils.getAllUserFields() with a null userName", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserName () {
+               // Init user instance and set needed fields to get pass above if() block
+               final User user = new LoginUser();
+               user.setUserEntryCreated(new Date());
+               user.setUserId(1l);
 
                // Should always throw an exception
                UserUtils.getAllUserFields(user);
@@ -641,4 +637,34 @@ public class UserUtilsTest {
                UserUtils.getAllUserFields(user);
        }
 
+       @Test (description = "Tests method UserUtils.generateRandomUserName() if it returns a non-empty string")
+       public void testRandomUserName () {
+               // Should not be empty
+               Assert.assertFalse(UserUtils.generateRandomUserName().isEmpty());
+       }
+
+       @Test (description = "Tests method UserUtils.compare() when different instance is provided", dataProvider = "different-user-provider")
+       public void testUserCompareDifferent (final User user1, final User user2) {
+               // Should always be not zero
+               Assert.assertNotEquals(UserUtils.compare(user1, user2), 0);
+       }
+
+       @Test (description = "Tests method UserUtils.compare() when left User instance is null", dataProvider = "left-null-user-provider")
+       public void testUserCompareLeftNull (final User user1, final User user2) {
+               // Should always be -1
+               Assert.assertEquals(UserUtils.compare(user1, user2), -1);
+       }
+
+       @Test (description = "Tests method UserUtils.compare() when right User instance is null", dataProvider = "right-null-user-provider")
+       public void testUserCompareRightNull (final User user1, final User user2) {
+               // Should always be 1
+               Assert.assertEquals(UserUtils.compare(user1, user2), 1);
+       }
+
+       @Test (description = "Tests method UserUtils.compare() when same instance is provided", dataProvider = "same-user-provider")
+       public void testUserCompareSame (final User user1, final User user2) {
+               // Should always be zero
+               Assert.assertEquals(UserUtils.compare(user1, user2), 0);
+       }
+
 }