UserUtil { public static void setUserDefaultValueForV3(Map<String, Object> userMap) { List<String> roles = new ArrayList<>(); roles.add(ProjectUtil.UserRole.PUBLIC.getValue()); userMap.put(JsonKey.ROLES, roles); userMap.put( JsonKey.COUNTRY_CODE, propertiesCache.getProperty(JsonKey.SUNBIRD_DEFAULT_COUNTRY_CODE)); userMap.put(JsonKey.PROFILE_VISIBILITY, new HashMap<String, String>()); userMap.put(JsonKey.IS_DELETED, false); userMap.put(JsonKey.CREATED_DATE, ProjectUtil.getFormattedDate()); userMap.put(JsonKey.STATUS, ProjectUtil.Status.ACTIVE.getValue()); if (StringUtils.isBlank((String) userMap.get(JsonKey.USERNAME))) { String firstName = (String) userMap.get(JsonKey.FIRST_NAME); firstName = firstName.split(" ")[0]; userMap.put(JsonKey.USERNAME, firstName + "_" + generateUniqueString(4)); } else { if (!userService.checkUsernameUniqueness((String) userMap.get(JsonKey.USERNAME), false)) { ProjectCommonException.throwClientErrorException(ResponseCode.userNameAlreadyExistError); } } } 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 setUserDefaultValueForV3() { Map<String, Object> userMap = new HashMap<String, Object>(); userMap.put(JsonKey.FIRST_NAME, "Test User"); UserUtil.setUserDefaultValueForV3(userMap); assertNotNull(userMap.get(JsonKey.USERNAME)); assertNotNull(userMap.get(JsonKey.STATUS)); assertNotNull(userMap.get(JsonKey.ROLES)); }