]> git.mxchange.org Git - juser-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 13:28:52 +0000 (14:28 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 12 Nov 2022 13:30:44 +0000 (14:30 +0100)
- added unit tests for UserUtils class (finished) based on TestNG 6.8.1
- added jcountry-core and jcore-utils as JAR dependencies as the unit tests
  require them to be around
- updated jar(s)

12 files changed:
lib/jcontacts-core.jar
lib/jcore-utils.jar
lib/jcountry-core.jar [new file with mode: 0644]
lib/jphone-core.jar [new file with mode: 0644]
lib/nblibraries.properties
lib/testng/testng-6.8.1-dist.jar [new file with mode: 0644]
nbproject/project.properties
src/org/mxchange/jusercore/model/user/LoginUser.java
src/org/mxchange/jusercore/model/utils/UserUtils.java
test/JUserCoreTestNGSuite.xml [new file with mode: 0644]
test/org/mxchange/jusercore/model/UserTestData.java [new file with mode: 0644]
test/org/mxchange/jusercore/model/utils/UserUtilsTest.java [new file with mode: 0644]

index 6a30eeeca600a5d9db5277ce5d57811dbe0c7ba7..75b7ea6bbdf48e1881533c9efbe943d1a08812ae 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
index 4fe65207a368336b1c970d3a1c23200b78708e23..6a8081ed21ee5fada3c798c55883d538b1dd62e5 100644 (file)
Binary files a/lib/jcore-utils.jar and b/lib/jcore-utils.jar differ
diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar
new file mode 100644 (file)
index 0000000..3e0cabf
Binary files /dev/null and b/lib/jcountry-core.jar differ
diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar
new file mode 100644 (file)
index 0000000..d7089bc
Binary files /dev/null and b/lib/jphone-core.jar differ
index f57e3039cd2b1303bb8eff455757cd8aeb6fdd93..df95cec3fc5a808de804dce460a6f22111dc5b9d 100644 (file)
@@ -22,3 +22,7 @@ libs.jpa20-persistence.classpath=\
     ${base}/jpa20-persistence/javax.persistence_2.1.0.v201304241213.jar
 libs.jpa20-persistence.displayName=Persistence (JPA 2.1)
 libs.jpa20-persistence.prop-maven-dependencies=org.eclipse.persistence:javax.persistence:2.1.0:jar
+libs.testng.classpath=\
+    ${base}/testng/testng-6.8.1-dist.jar
+libs.testng.displayName=TestNG 6.8.1
+libs.testng.prop-maven-dependencies=org.testng:testng:6.8.1:jar
diff --git a/lib/testng/testng-6.8.1-dist.jar b/lib/testng/testng-6.8.1-dist.jar
new file mode 100644 (file)
index 0000000..11f1304
Binary files /dev/null and b/lib/testng/testng-6.8.1-dist.jar differ
index b7d9f3ef68e900959decca847187b0e20e1d380c..e2bea734ede894b510bedc8029a5cdfcd29796aa 100644 (file)
@@ -32,6 +32,8 @@ endorsed.classpath=
 excludes=
 file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
 file.reference.jcore-utils.jar=lib/jcore-utils.jar
+file.reference.jcountry-core.jar=lib/jcountry-core.jar
+file.reference.jphone-core.jar=lib/jphone-core.jar
 includes=**
 jar.archive.disabled=${jnlp.enabled}
 jar.compress=false
@@ -39,6 +41,8 @@ jar.index=${jnlp.enabled}
 javac.classpath=\
     ${file.reference.jcontacts-core.jar}:\
     ${file.reference.jcore-utils.jar}:\
+    ${file.reference.jcountry-core.jar}:\
+    ${file.reference.jphone-core.jar}:\
     ${libs.commons-codec.classpath}:\
     ${libs.commons-lang3.classpath}:\
     ${libs.jpa20-persistence.classpath}
@@ -52,7 +56,8 @@ javac.source=1.7
 javac.target=1.7
 javac.test.classpath=\
     ${javac.classpath}:\
-    ${build.classes.dir}
+    ${build.classes.dir}:\
+    ${libs.testng.classpath}
 javac.test.processorpath=\
     ${javac.test.classpath}
 javadoc.additionalparam=
@@ -96,5 +101,7 @@ run.test.classpath=\
 source.encoding=UTF-8
 source.reference.jcontacts-core.jar=../jcontacts-core/src/
 source.reference.jcore-utils.jar=../jcore-utils/src/
+source.reference.jcountry-core.jar=../jcountry-core/src/
+source.reference.jphone-core.jar=../jphone-core/src/
 src.dir=src
 test.src.dir=test
index 134d6dc022093d1ca493520914e4fc268c93ddfe..e934e408b2f2f83e1a03e3c496c1760f72a5b894 100644 (file)
@@ -239,7 +239,7 @@ public class LoginUser implements User {
                        // ... profile mode
                        this.getUserProfileMode().compareTo(user.getUserProfileMode()),
                        // ... "must change password" flag
-                       this.getUserMustChangePassword().compareTo(user.getUserMustChangePassword()),
+                       Boolean.compare(this.getUserMustChangePassword(), user.getUserMustChangePassword()),
                        // ... confirm key
                        StringUtils.compare(this.getUserConfirmKey(), user.getUserConfirmKey())
                };
index 5d98c1dc520ab0987463a37e3c6e751aca7d9899..3a2ef573b75cdd2be4d56f19b1ad87bab97353ee 100644 (file)
@@ -24,7 +24,6 @@ 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;
 
@@ -113,7 +112,8 @@ public class UserUtils implements Serializable {
        }
 
        /**
-        * Copies all attributes from other user object to target
+        * Copies all attributes, except "entryCreated" timestamp from source user
+        * object to target
         * <p>
         * @param sourceUser Source instance
         * @param targetUser Target instance
@@ -132,22 +132,22 @@ public class UserUtils implements Serializable {
                }
 
                // Is contact set?
-               if (sourceUser.getUserContact() instanceof Contact) {
+               if (!Objects.equals(sourceUser.getUserContact(), targetUser.getUserContact())) {
                        // Copy also contact data
                        ContactUtils.copyContactData(sourceUser.getUserContact(), targetUser.getUserContact());
                }
 
                // Copy other data
+               targetUser.setUserAccountStatus(sourceUser.getUserAccountStatus());
                targetUser.setUserConfirmKey(sourceUser.getUserConfirmKey());
-               targetUser.setUserName(sourceUser.getUserName());
                targetUser.setUserEncryptedPassword(sourceUser.getUserEncryptedPassword());
-               targetUser.setUserAccountStatus(sourceUser.getUserAccountStatus());
+               targetUser.setUserEntryUpdated(sourceUser.getUserEntryUpdated());
+               targetUser.setUserName(sourceUser.getUserName());
+               targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword());
                targetUser.setUserLastLocked(sourceUser.getUserLastLocked());
                targetUser.setUserLastLockedReason(sourceUser.getUserLastLockedReason());
-               targetUser.setUserEntryUpdated(sourceUser.getUserEntryUpdated());
-               targetUser.setUserProfileMode(sourceUser.getUserProfileMode());
                targetUser.setUserLocale(sourceUser.getUserLocale());
-               targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword());
+               targetUser.setUserProfileMode(sourceUser.getUserProfileMode());
        }
 
        /**
@@ -239,6 +239,21 @@ public class UserUtils implements Serializable {
                } else if (user.getUserContact().getContactEntryCreated() == null) {
                        // .. and again
                        throw new NullPointerException("user.userContact.contactEntryCreated is null"); //NOI18N
+               } else if (user.getUserLocale() == null) {
+                       // .. and again
+                       throw new NullPointerException("user.userLocale is null"); //NOI18N
+               } else if (user.getUserContact().getContactFirstName() == null) {
+                       // .. and again
+                       throw new NullPointerException("user.userContact.contactFirstName is null"); //NOI18N
+               } else if (user.getUserContact().getContactFirstName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("user.userContact.contactFirstName is empty"); //NOI18N
+               } else if (user.getUserContact().getContactFamilyName() == null) {
+                       // .. and again
+                       throw new NullPointerException("user.userContact.contactFamilyName is null"); //NOI18N
+               } else if (user.getUserContact().getContactFamilyName().isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("user.userContact.contactFamilyName is null"); //NOI18N
                }
 
                // Init properties list
@@ -251,6 +266,7 @@ public class UserUtils implements Serializable {
                properties.setProperty("contactTitle", ""); //NOI18N
                properties.setProperty("contactStreet", ""); //NOI18N
                properties.setProperty("contactHouseNumber", ""); //NOI18N
+               properties.setProperty("contactHouseNumberExtension", ""); //NOI18N
                properties.setProperty("contactCity", ""); //NOI18N
                properties.setProperty("contactUpdated", ""); //NOI18N
                properties.setProperty("contactZipCode", ""); //NOI18N
@@ -291,6 +307,9 @@ public class UserUtils implements Serializable {
                if (user.getUserContact().getContactHouseNumber() != null) {
                        properties.setProperty("contactHouseNumber", Short.toString(user.getUserContact().getContactHouseNumber())); //NOI18N
                }
+               if (user.getUserContact().getContactHouseNumberExtension() != null) {
+                       properties.setProperty("contactHouseNumberExtension", user.getUserContact().getContactHouseNumberExtension()); //NOI18N
+               }
                if (user.getUserContact().getContactCity() != null) {
                        properties.setProperty("contactCity", user.getUserContact().getContactCity()); //NOI18N
                }
diff --git a/test/JUserCoreTestNGSuite.xml b/test/JUserCoreTestNGSuite.xml
new file mode 100644 (file)
index 0000000..ba33ee7
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<suite name="juser-core">
+
+    <!--
+    see examples at http://testng.org/doc/documentation-main.html#testng-xml
+
+    <suite-files>
+        <suite-file path="./junit-suite.xml" />
+    </suite-files>
+
+       <test name="TimeOut">
+               <classes>
+                       <class name="test.timeout.TimeOutTest" />
+                       <class name="test.timeout.TimeOutFromXmlTest"/>
+                       <class name="test.timeout.TimeOutThreadLocalSampleTest"/>
+               </classes>
+       </test>
+       -->
+    
+       <test name="All tests for juser-core">
+               <packages>
+                       <package name=".*"/>
+               </packages>
+       </test>
+
+</suite>
diff --git a/test/org/mxchange/jusercore/model/UserTestData.java b/test/org/mxchange/jusercore/model/UserTestData.java
new file mode 100644 (file)
index 0000000..952bdb3
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountryData;
+
+/**
+ * Test data class for unit tests around User classes
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class UserTestData {
+
+       public static final Country CONTACT_FAKE_COUNTRY;
+
+       public static final String CONTACT_FAMILY_NAME = "Tester"; //NOI18N
+
+       public static final String CONTACT_FIRST_NAME = "Bob"; //NOI18N
+
+       public static final Short CONTACT_HOUSE_NUMBER = 123;
+
+       public static final String USER_ENCRYPTED_PASSWORD1 = "abc123"; //NOI18N
+
+       public static final String USER_ENCRYPTED_PASSWORD2 = "xyz456"; //NOI18N
+
+       public static final String USER_NAME1 = "bar"; //NOI18N
+
+       public static final String USER_NAME2 = "foo"; //NOI18N
+
+       /**
+        * Sets some fake data
+        */
+       static {
+               // Init Country instance and set fake primary key
+               CONTACT_FAKE_COUNTRY = new CountryData();
+               CONTACT_FAKE_COUNTRY.setCountryId(1l);
+       }
+
+       /**
+        * No instance from this class is required
+        */
+       private UserTestData () {
+       }
+
+}
diff --git a/test/org/mxchange/jusercore/model/utils/UserUtilsTest.java b/test/org/mxchange/jusercore/model/utils/UserUtilsTest.java
new file mode 100644 (file)
index 0000000..d4e903a
--- /dev/null
@@ -0,0 +1,644 @@
+/*
+ * 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.utils;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
+import org.mxchange.jcontacts.model.contact.Contact;
+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.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+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;
+
+/**
+ *
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class UserUtilsTest {
+
+       /**
+        * Public constructor
+        */
+       public UserUtilsTest () {
+       }
+
+       @DataProvider (name = "different-user-provider")
+       public Object[][] createDifferentNullUser () {
+               return new Object[][]{
+                       // 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 = "left-null-user-provider")
+       public Object[][] createLeftNullUser () {
+               return new Object[][]{
+                       // Empty instances (the JPA invokes this)
+                       {
+                               null,
+                               new LoginUser()
+                       },
+                       // Instances with all required values
+                       {
+                               null,
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               )
+                       }
+               };
+       }
+
+       @DataProvider (name = "right-null-user-provider")
+       public Object[][] createRightNullUser () {
+               return new Object[][]{
+                       // Empty instances (the JPA invokes this)
+                       {
+                               new LoginUser(),
+                               null
+                       },
+                       // Instances with all required values
+                       {
+                               new LoginUser(
+                               UserTestData.USER_NAME1,
+                               ProfileMode.PUBLIC,
+                               Boolean.TRUE,
+                               UserTestData.USER_ENCRYPTED_PASSWORD1,
+                               UserAccountStatus.UNCONFIRMED,
+                               new UserContact()
+                               ),
+                               null
+                       }
+               };
+       }
+
+       @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 method UserUtils.copyUserData() when both are different User instances", dataProvider = "different-user-provider")
+       public void testCopyUserDataDifferentUser (final User user1, final User user2) {
+               // Should always not fail
+               UserUtils.copyUserData(user1, user2);
+
+               // They must be identical
+               Assert.assertEquals(user2, user1);
+       }
+
+       @Test (description = "Tests method UserUtils.copyUserData() when sourceUser is null", dataProvider = "left-null-user-provider", expectedExceptions = NullPointerException.class)
+       public void testCopyUserDataNullSource (final User user1, final User user2) {
+               // Should always throw an exception
+               UserUtils.copyUserData(user1, user2);
+       }
+
+       @Test (description = "Tests method UserUtils.copyUserData() when targetUser is null", dataProvider = "right-null-user-provider", expectedExceptions = NullPointerException.class)
+       public void testCopyUserDataNullTarget (final User user1, final User user2) {
+               // Should always throw an exception
+               UserUtils.copyUserData(user1, user2);
+       }
+
+       @Test (description = "Tests method UserUtils.copyUserData() when both are the same User", dataProvider = "same-user-provider", expectedExceptions = IllegalArgumentException.class)
+       public void testCopyUserDataSameUser (final User user1, final User user2) {
+               // Should always throw an exception
+               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
+               final Date date = new Date();
+
+               // Init user instance
+               final User user = new LoginUser();
+               user.setUserLocale(Locale.GERMANY);
+
+               // Get DateFormat instance
+               final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale());
+
+               // Should return in proper way
+               final String formatted = UserUtils.formatTimestampFromUser(user, date);
+
+               // Both should be equal
+               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 () {
+               // 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 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);
+
+               // 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);
+       }
+
+       @Test (description = "Tests method UserUtils.getAllUserFields() with an empty userName", expectedExceptions = IllegalArgumentException.class)
+       public void testGetAllUserFieldsEmptyUserName () {
+               // 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(""); //NOI18N
+
+               // Should always throw an exception
+               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 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);
+
+               // 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 () {
+               // 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());
+
+               // 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);
+
+               // 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);
+
+               // 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.contactEntryCreated", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContactEntryCreated () {
+               // Init contact instance and set neeed fields
+               final Contact contact = new UserContact();
+               contact.setContactId(1l);
+               contact.setContactPersonalTitle(PersonalTitle.MR);
+
+               // 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 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());
+
+               // 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 user.userContact.contactFirstName", expectedExceptions = NullPointerException.class)
+       public void testGetAllUserFieldsNullUserContactFirstName () {
+               // Init contact instance and set neeed fields
+               final Contact contact = new UserContact();
+               contact.setContactId(1l);
+               contact.setContactPersonalTitle(PersonalTitle.MR);
+               contact.setContactEntryCreated(new Date());
+
+               // 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);
+       }
+
+       @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);
+       }
+
+       @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();
+               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);
+       }
+
+       @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.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 all required fields set")
+       public void testGetAllUserFieldsRequired () {
+               // 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); //NOI18N
+               contact.setContactFamilyName(UserTestData.CONTACT_FAMILY_NAME); //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);
+       }
+
+       @Test (description = "Tests method UserUtils.getAllUserFields() with all required+optiona fields set")
+       public void testGetAllUserFieldsRequiredAndOptional () {
+               // 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); //NOI18N
+               contact.setContactFamilyName(UserTestData.CONTACT_FAMILY_NAME); //NOI18N
+               contact.setContactTitle("Dr."); //NOI18N
+               contact.setContactStreet("Park Street"); //NOI18N
+               contact.setContactHouseNumber(UserTestData.CONTACT_HOUSE_NUMBER);
+               contact.setContactHouseNumberExtension("a"); //NOI18N
+               contact.setContactCity("Chicago"); //NOI18N
+               contact.setContactZipCode(12345);
+               contact.setContactBirthday(new Date());
+               contact.setContactEmailAddress("bob@company.com"); //NOI18N
+               contact.setContactEntryUpdated(new Date());
+
+               // 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.setUserEntryUpdated(new Date());
+               user.setUserConfirmKey("abc123"); //NOI18N
+               user.setUserLastLockedReason("Some testing reason"); //NOI18N
+               user.setUserLastLocked(new Date());
+
+               // Should always throw an exception
+               UserUtils.getAllUserFields(user);
+       }
+
+}