From 88516ed38def3271393c3dd190c8f3980bb05509 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 30 Aug 2016 12:07:52 +0200 Subject: [PATCH] Please cherry-pick: - more tests added on user instance (may prevent message-less NPE somewhere else which is harder to debug) --- .../jjobs/database/BaseJobsDatabaseBean.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java b/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java index 5f8e990..a79f549 100644 --- a/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java +++ b/src/org/mxchange/jjobs/database/BaseJobsDatabaseBean.java @@ -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 -- 2.39.5