]> git.mxchange.org Git - jjobs-core.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 30 Aug 2016 10:07:52 +0000 (12:07 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 31 Aug 2016 19:55:13 +0000 (21:55 +0200)
- more tests added on user instance (may prevent message-less NPE somewhere else which is harder to debug)

src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java

index 5f8e990f0e6380d049608e52357d0d0a7037d0b2..a79f5499cc669a9378796cbf28c8565188c5d9ae 100644 (file)
@@ -510,6 +510,36 @@ public abstract class BaseJobsDatabaseBean extends BaseDatabaseBean {
                } else if (null == emailAddress) {
                        // Throw NPE
                        throw new NullPointerException("emailAddress is null"); //NOI18N
+               }else if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userId is null"); //NOI18N
+               } else if (user.getUserId() < 1) {
+                       // Not valid number
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
+               } else if (user.getUserName() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userName is null"); //NOI18N
+               } else if (user.getUserName().isEmpty()) {
+                       // Empty string
+                       throw new IllegalArgumentException("user.userName is empty"); //NOI18N
+               } else if (user.getUserAccountStatus() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+               } else if (user.getUserContact() == null) {
+                       // Throw it again
+                       throw new NullPointerException("user.userContact is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() == null) {
+                       // .. and again
+                       throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
+               } else if (user.getUserContact().getContactGender() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userContact.contactGender is null"); //NOI18N
                }
 
                // Prepare mail wrapper