UserUtil { public static void checkEmailUniqueness(String email) { String emailSetting = DataCacheHandler.getConfigSettings().get(JsonKey.EMAIL_UNIQUE); if (StringUtils.isNotBlank(emailSetting) && Boolean.parseBoolean(emailSetting)) { if (StringUtils.isNotBlank(email)) { try { email = encryptionService.encryptData(email); } catch (Exception e) { ProjectLogger.log("Exception occurred while encrypting phone number ", e); } Response result = cassandraOperation.getRecordsByIndexedProperty( userDb.getKeySpace(), userDb.getTableName(), (JsonKey.EMAIL), email); List<Map<String, Object>> userMapList = (List<Map<String, Object>>) result.get(JsonKey.RESPONSE); if (!userMapList.isEmpty()) { ProjectCommonException.throwClientErrorException( ResponseCode.emailAlreadyExistError, null); } } } } private  UserUtil(); @SuppressWarnings("unchecked") static void checkPhoneUniqueness(User user, String opType); @SuppressWarnings("unchecked") static void checkPhoneUniqueness(String phone); static boolean identifierExists(String type, String value); static void checkEmailUniqueness(String email); static Map<String, Object> validateExternalIdsAndReturnActiveUser(
      Map<String, Object> userMap); @SuppressWarnings("unchecked") static Map<String, Object> getUserFromExternalId(Map<String, Object> userMap); static String getUserIdFromExternalId(Map<String, Object> userMap); @SuppressWarnings("unchecked") static void checkEmailUniqueness(User user, String opType); static void validateUserPhoneEmailAndWebPages(User user, String operationType); static String getEncryptedData(String value); static List<Map<String, String>> copyAndConvertExternalIdsToLower(
      List<Map<String, String>> externalIds); static void storeOriginalExternalIdsValue(List<Map<String, String>> externalIds); static List<Map<String, String>> convertExternalIdsValueToLowerCase(
      List<Map<String, String>> externalIds); @SuppressWarnings("unchecked") static void checkExternalIdUniqueness(User user, String operation); static String encryptData(String value); static boolean updatePassword(Map<String, Object> userMap); static void addMaskEmailAndPhone(Map<String, Object> userMap); static void addMaskEmailAndMaskPhone(Map<String, Object> userMap); @SuppressWarnings("unchecked") static Map<String, Object> encryptUserData(Map<String, Object> userMap); static Map<String, Object> checkProfileCompleteness(Map<String, Object> userMap); static void setUserDefaultValueForV3(Map<String, Object> userMap); static String generateUniqueString(int length); static void setUserDefaultValue(Map<String, Object> userMap, String callerId); static void validateExternalIds(User user, String operationType); static void checkEmailSameOrDiff(
      Map<String, Object> userRequestMap, Map<String, Object> userDbRecord); static void validateUserExternalIds(User user); static List<Map<String, Object>> getActiveUserOrgDetails(String userId); static List<Map<String, Object>> getAllUserOrgDetails(String userId); static void toLower(Map<String, Object> userMap);  }
@Test public void checkEmailExist() { boolean response = false; try { UserUtil.checkEmailUniqueness("test@test.com"); response = true; } catch (ProjectCommonException e) { } assertTrue(response); }