target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void extractSchemaVersionWithDescriptionWithSpaces() { Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription("9_4__Big_jump", "", "__", ""); MigrationVersion version = info.getLeft(); String description = info.getRight(); assertEquals("9.4", version.toString()); assertEquals("Big jump", description); } | public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } |
@Test public void sendEmailTest() throws MessagingException { List<String> to = new ArrayList<String>(); to.add("[email protected]"); to.add("[email protected]"); emailService.sendEmail("[email protected]", subject, "Hi how are you", to); List<Message> inbox = Mailbox.get("[email protected]"); Assert.assertTrue(inbox.size() > 0); Assert.assertEquals(subject, inbox.get(0).getSubject()); } | public boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList) { boolean sentStatus = true; try { Session session = getSession(); MimeMessage message = new MimeMessage(session); addRecipient(message, Message.RecipientType.BCC, bccList); setMessageAttribute(message, fromEmail, subject, body); sentStatus = sendEmail(session, message); } catch (Exception e) { sentStatus = false; logger.error("SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); } return sentStatus; } | Email { public boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList) { boolean sentStatus = true; try { Session session = getSession(); MimeMessage message = new MimeMessage(session); addRecipient(message, Message.RecipientType.BCC, bccList); setMessageAttribute(message, fromEmail, subject, body); sentStatus = sendEmail(session, message); } catch (Exception e) { sentStatus = false; logger.error("SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); } return sentStatus; } } | Email { public boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList) { boolean sentStatus = true; try { Session session = getSession(); MimeMessage message = new MimeMessage(session); addRecipient(message, Message.RecipientType.BCC, bccList); setMessageAttribute(message, fromEmail, subject, body); sentStatus = sendEmail(session, message); } catch (Exception e) { sentStatus = false; logger.error("SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); } return sentStatus; } Email(); Email(EmailConfig config); } | Email { public boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList) { boolean sentStatus = true; try { Session session = getSession(); MimeMessage message = new MimeMessage(session); addRecipient(message, Message.RecipientType.BCC, bccList); setMessageAttribute(message, fromEmail, subject, body); sentStatus = sendEmail(session, message); } catch (Exception e) { sentStatus = false; logger.error("SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); } return sentStatus; } Email(); Email(EmailConfig config); boolean sendMail(List<String> emailList, String subject, String body); boolean sendMail(
List<String> emailList, String subject, String body, List<String> ccEmailList); void sendAttachment(
List<String> emailList, String emailBody, String subject, String filePath); boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList); String getHost(); String getPort(); String getUserName(); String getPassword(); String getFromEmail(); } | Email { public boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList) { boolean sentStatus = true; try { Session session = getSession(); MimeMessage message = new MimeMessage(session); addRecipient(message, Message.RecipientType.BCC, bccList); setMessageAttribute(message, fromEmail, subject, body); sentStatus = sendEmail(session, message); } catch (Exception e) { sentStatus = false; logger.error("SendMail:sendMail: Exception occurred with message = " + e.getMessage(), e); } return sentStatus; } Email(); Email(EmailConfig config); boolean sendMail(List<String> emailList, String subject, String body); boolean sendMail(
List<String> emailList, String subject, String body, List<String> ccEmailList); void sendAttachment(
List<String> emailList, String emailBody, String subject, String filePath); boolean sendEmail(String fromEmail, String subject, String body, List<String> bccList); String getHost(); String getPort(); String getUserName(); String getPassword(); String getFromEmail(); } |
@Test public void testValidateForgotPasswordSuccess() { Request request = new Request(); boolean response = false; Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USERNAME, "manzarul07"); request.setRequest(requestObj); try { userRequestValidator.validateForgotPassword(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateForgotPasswordFailureWithEmptyName() { try { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USERNAME, ""); request.setRequest(requestObj); userRequestValidator.validateForgotPassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.userNameRequired.getErrorCode(), e.getCode()); } } | public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateForgotPasswordFailureWithoutName() { try { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); request.setRequest(requestObj); userRequestValidator.validateForgotPassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.userNameRequired.getErrorCode(), e.getCode()); } } | public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateForgotPassword(Request request) { if (request.getRequest().get(JsonKey.USERNAME) == null || StringUtils.isBlank((String) request.getRequest().get(JsonKey.USERNAME))) { throw new ProjectCommonException( ResponseCode.userNameRequired.getErrorCode(), ResponseCode.userNameRequired.getErrorMessage(), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateChangePasswordSuccess() { Request request = new Request(); boolean response = false; Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.NEW_PASSWORD, "password1"); requestObj.put(JsonKey.PASSWORD, "password"); request.setRequest(requestObj); try { userRequestValidator.validateChangePassword(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateChangePasswordFailureWithEmptyNewPassword() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.NEW_PASSWORD, ""); requestObj.put(JsonKey.PASSWORD, "password"); request.setRequest(requestObj); try { userRequestValidator.validateChangePassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.newPasswordEmpty.getErrorCode(), e.getCode()); } } | public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateChangePasswordFailureWithoutNewPassword() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PASSWORD, "password"); request.setRequest(requestObj); try { userRequestValidator.validateChangePassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.newPasswordRequired.getErrorCode(), e.getCode()); } } | public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateChangePasswordFailureWithSameOldPassword() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.NEW_PASSWORD, "password"); requestObj.put(JsonKey.PASSWORD, "password"); request.setRequest(requestObj); try { userRequestValidator.validateChangePassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.samePasswordError.getErrorCode(), e.getCode()); } } | public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateChangePasswordFailureWithPasswordMissing() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.NEW_PASSWORD, "password"); request.setRequest(requestObj); try { userRequestValidator.validateChangePassword(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.passwordRequired.getErrorCode(), e.getCode()); } } | public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateChangePassword(Request userRequest) { if (userRequest.getRequest().get(JsonKey.PASSWORD) == null || (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PASSWORD)))) { ProjectCommonException.throwClientErrorException(ResponseCode.passwordRequired); } if (userRequest.getRequest().get(JsonKey.NEW_PASSWORD) == null) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordRequired); } if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.NEW_PASSWORD))) { ProjectCommonException.throwClientErrorException(ResponseCode.newPasswordEmpty); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testCreateUserSuccess() { boolean response = false; Request request = initailizeRequest(); Map<String, Object> requestObj = request.getRequest(); List<String> roles = new ArrayList<String>(); roles.add("PUBLIC"); roles.add("CONTENT-CREATOR"); requestObj.put(JsonKey.ROLE, roles); List<String> language = new ArrayList<>(); language.add("English"); requestObj.put(JsonKey.LANGUAGE, language); List<Map<String, Object>> addressList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.ADDRESS_LINE1, "test"); map.put(JsonKey.CITY, "Bangalore"); map.put(JsonKey.COUNTRY, "India"); map.put(JsonKey.ADD_TYPE, "current"); addressList.add(map); requestObj.put(JsonKey.ADDRESS, addressList); List<Map<String, Object>> educationList = new ArrayList<>(); Map<String, Object> map1 = new HashMap<>(); map1.put(JsonKey.COURSE_NAME, "M.C.A"); map1.put(JsonKey.DEGREE, "Master"); map1.put(JsonKey.NAME, "CUSAT"); educationList.add(map1); requestObj.put(JsonKey.EDUCATION, educationList); List<Map<String, Object>> jobProfileList = new ArrayList<>(); map1 = new HashMap<>(); map1.put(JsonKey.JOB_NAME, "SE"); map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); jobProfileList.add(map1); requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithWrongAddType() { Request request = initailizeRequest(); Map<String, Object> requestObj = request.getRequest(); List<String> roles = new ArrayList<String>(); roles.add("PUBLIC"); roles.add("CONTENT-CREATOR"); requestObj.put(JsonKey.ROLE, roles); List<String> language = new ArrayList<>(); language.add("English"); requestObj.put(JsonKey.LANGUAGE, language); List<Map<String, Object>> addressList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.ADDRESS_LINE1, "test"); map.put(JsonKey.CITY, "Bangalore"); map.put(JsonKey.COUNTRY, "India"); map.put(JsonKey.ADD_TYPE, "lmlkmkl"); addressList.add(map); requestObj.put(JsonKey.ADDRESS, addressList); List<Map<String, Object>> educationList = new ArrayList<>(); Map<String, Object> map1 = new HashMap<>(); map1.put(JsonKey.COURSE_NAME, "M.C.A"); map1.put(JsonKey.DEGREE, "Master"); map1.put(JsonKey.NAME, "CUSAT"); educationList.add(map1); requestObj.put(JsonKey.EDUCATION, educationList); List<Map<String, Object>> jobProfileList = new ArrayList<>(); map1 = new HashMap<>(); map1.put(JsonKey.JOB_NAME, "SE"); map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); jobProfileList.add(map1); requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.addressTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void extractSchemaVersionWithLeadingZeroes() { Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription("009_4__EmailAxel", "", "__", ""); MigrationVersion version = info.getLeft(); String description = info.getRight(); assertEquals("009.4", version.toString()); assertEquals("EmailAxel", description); } | public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } |
@Test public void testValidateCreateUserFailureWithEmptyAddType() { Request request = initailizeRequest(); Map<String, Object> requestObj = request.getRequest(); List<String> roles = new ArrayList<String>(); roles.add("PUBLIC"); roles.add("CONTENT-CREATOR"); requestObj.put(JsonKey.ROLE, roles); List<String> language = new ArrayList<>(); language.add("English"); requestObj.put(JsonKey.LANGUAGE, language); List<Map<String, Object>> addressList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.ADDRESS_LINE1, "test"); map.put(JsonKey.CITY, "Bangalore"); map.put(JsonKey.COUNTRY, "India"); map.put(JsonKey.ADD_TYPE, ""); addressList.add(map); requestObj.put(JsonKey.ADDRESS, addressList); List<Map<String, Object>> educationList = new ArrayList<>(); Map<String, Object> map1 = new HashMap<>(); map1.put(JsonKey.COURSE_NAME, "M.C.A"); map1.put(JsonKey.DEGREE, "Master"); map1.put(JsonKey.NAME, "CUSAT"); educationList.add(map1); requestObj.put(JsonKey.EDUCATION, educationList); List<Map<String, Object>> jobProfileList = new ArrayList<>(); map1 = new HashMap<>(); map1.put(JsonKey.JOB_NAME, "SE"); map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); jobProfileList.add(map1); requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationSuccess() { Request request = new Request(); boolean response = false; Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL_VERIFIED, true); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationFailureWithInvalidPhone() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "+9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL_VERIFIED, true); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.invalidPhoneNumber.getErrorCode(), e.getCode()); } } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationFailureWithInvalidCountryCode() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "+9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91968"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL_VERIFIED, true); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.invalidCountryCode.getErrorCode(), e.getCode()); } } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationFailureWithEmptyPhoneVerified() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, ""); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationFailureWithPhoneVerifiedFalse() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, false); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testPhoneValidationFailureWithPhoneVerifiedNull() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.COUNTRY_CODE, "+91"); requestObj.put(JsonKey.PROVIDER, "sunbird"); requestObj.put(JsonKey.PHONE_VERIFIED, null); request.setRequest(requestObj); try { userRequestValidator.phoneValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void phoneValidation(Request userRequest) { if (!StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE))) { boolean bool = ProjectUtil.validateCountryCode( (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); if (!bool) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidCountryCode); } } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhoneNo( (String) userRequest.getRequest().get(JsonKey.PHONE), (String) userRequest.getRequest().get(JsonKey.COUNTRY_CODE)); } phoneVerifiedValidation(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testUpdateUserSuccess() { Request request = initailizeRequest(); Map<String, Object> requestObj = request.getRequest(); requestObj.remove(JsonKey.USERNAME); requestObj.put(JsonKey.USER_ID, "userId"); List<String> roles = new ArrayList<String>(); roles.add("PUBLIC"); roles.add("CONTENT-CREATOR"); requestObj.put(JsonKey.ROLE, roles); List<String> language = new ArrayList<>(); language.add("English"); requestObj.put(JsonKey.LANGUAGE, language); List<Map<String, Object>> addressList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.ADDRESS_LINE1, "test"); map.put(JsonKey.CITY, "Bangalore"); map.put(JsonKey.COUNTRY, "India"); map.put(JsonKey.ADD_TYPE, "current"); addressList.add(map); requestObj.put(JsonKey.ADDRESS, addressList); List<Map<String, Object>> educationList = new ArrayList<>(); Map<String, Object> map1 = new HashMap<>(); map1.put(JsonKey.COURSE_NAME, "M.C.A"); map1.put(JsonKey.DEGREE, "Master"); map1.put(JsonKey.NAME, "CUSAT"); educationList.add(map1); requestObj.put(JsonKey.EDUCATION, educationList); List<Map<String, Object>> jobProfileList = new ArrayList<>(); map1 = new HashMap<>(); map1.put(JsonKey.JOB_NAME, "SE"); map1.put(JsonKey.ORGANISATION_NAME, "Tarento"); jobProfileList.add(map1); requestObj.put(JsonKey.JOB_PROFILE, jobProfileList); boolean response = false; request.setRequest(requestObj); try { userRequestValidator.validateUpdateUserRequest(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey.UPDATE); phoneValidation(userRequest); updateUserBasicValidation(userRequest); validateAddressField(userRequest); validateJobProfileField(userRequest); validateEducationField(userRequest); validateUserType(userRequest); validateUserOrgField(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); } validateLocationCodes(userRequest); validateExtIdTypeAndProvider(userRequest); validateFrameworkDetails(userRequest); validateRecoveryEmailOrPhone(userRequest); } | UserRequestValidator extends BaseRequestValidator { public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey.UPDATE); phoneValidation(userRequest); updateUserBasicValidation(userRequest); validateAddressField(userRequest); validateJobProfileField(userRequest); validateEducationField(userRequest); validateUserType(userRequest); validateUserOrgField(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); } validateLocationCodes(userRequest); validateExtIdTypeAndProvider(userRequest); validateFrameworkDetails(userRequest); validateRecoveryEmailOrPhone(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey.UPDATE); phoneValidation(userRequest); updateUserBasicValidation(userRequest); validateAddressField(userRequest); validateJobProfileField(userRequest); validateEducationField(userRequest); validateUserType(userRequest); validateUserOrgField(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); } validateLocationCodes(userRequest); validateExtIdTypeAndProvider(userRequest); validateFrameworkDetails(userRequest); validateRecoveryEmailOrPhone(userRequest); } } | UserRequestValidator extends BaseRequestValidator { public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey.UPDATE); phoneValidation(userRequest); updateUserBasicValidation(userRequest); validateAddressField(userRequest); validateJobProfileField(userRequest); validateEducationField(userRequest); validateUserType(userRequest); validateUserOrgField(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); } validateLocationCodes(userRequest); validateExtIdTypeAndProvider(userRequest); validateFrameworkDetails(userRequest); validateRecoveryEmailOrPhone(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey.UPDATE); phoneValidation(userRequest); updateUserBasicValidation(userRequest); validateAddressField(userRequest); validateJobProfileField(userRequest); validateEducationField(userRequest); validateUserType(userRequest); validateUserOrgField(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROOT_ORG_ID) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.ROOT_ORG_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidRootOrganisationId); } validateLocationCodes(userRequest); validateExtIdTypeAndProvider(userRequest); validateFrameworkDetails(userRequest); validateRecoveryEmailOrPhone(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateAssignRoleSuccess() { Request request = new Request(); boolean response = false; Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USER_ID, "ORG-provider"); requestObj.put(JsonKey.EXTERNAL_ID, "EXT_ID"); requestObj.put(JsonKey.ORGANISATION_ID, "ORG_ID"); requestObj.put(JsonKey.ORG_PROVIDER, "ORG_PROVIDER"); List<String> roles = new ArrayList<>(); roles.add("PUBLIC"); requestObj.put(JsonKey.ROLES, roles); request.setRequest(requestObj); try { userRequestValidator.validateAssignRole(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateAssignRoleSuccessWithProviderAndExternalId() { Request request = new Request(); boolean response = false; Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PROVIDER, "ORG-provider"); requestObj.put(JsonKey.EXTERNAL_ID, "ORG-1233"); requestObj.put(JsonKey.USER_ID, "User1"); List<String> roles = new ArrayList<>(); roles.add("PUBLIC"); requestObj.put(JsonKey.ROLES, roles); request.setRequest(requestObj); try { userRequestValidator.validateAssignRole(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } assertEquals(true, response); } | public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateAssignRole(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.USER_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.userIdRequired); } if (request.getRequest().get(JsonKey.ROLES) == null || !(request.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } String organisationId = (String) request.getRequest().get(JsonKey.ORGANISATION_ID); String externalId = (String) request.getRequest().get(JsonKey.EXTERNAL_ID); String provider = (String) request.getRequest().get(JsonKey.PROVIDER); if (StringUtils.isBlank(organisationId) && (StringUtils.isBlank(externalId) || StringUtils.isBlank(provider))) { throw new ProjectCommonException( ResponseCode.mandatoryParamsMissing.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.mandatoryParamsMissing.getErrorMessage(), (StringFormatter.joinByOr( JsonKey.ORGANISATION_ID, StringFormatter.joinByAnd(JsonKey.EXTERNAL_ID, JsonKey.PROVIDER)))), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test(expected = CassandraMigrationException.class) public void extractSchemaVersionWithLeadingUnderscore() { MigrationInfoHelper.extractVersionAndDescription("_8_0__Description", "", "__", ""); } | public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } |
@Test public void testValidateWebPagesFailureWithEmptyWebPages() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.WEB_PAGES, new ArrayList<>()); request.setRequest(requestObj); try { userRequestValidator.validateWebPages(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.invalidWebPageData.getErrorCode(), e.getCode()); } } | @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateWebPagesFailureWithNullWebPages() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.WEB_PAGES, null); request.setRequest(requestObj); try { userRequestValidator.validateWebPages(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.invalidWebPageData.getErrorCode(), e.getCode()); } } | @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateWebPages(Request request) { if (request.getRequest().containsKey(JsonKey.WEB_PAGES)) { List<Map<String, String>> data = (List<Map<String, String>>) request.getRequest().get(JsonKey.WEB_PAGES); if (null == data || data.isEmpty()) { ProjectCommonException.throwClientErrorException(ResponseCode.invalidWebPageData); } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testCreateUserBasicValidationFailureWithoutEmailAndPhone() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.DOB, "2018-10-15"); request.setRequest(requestObj); try { userRequestValidator.createUserBasicValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.emailorPhoneorManagedByRequired.getErrorCode(), e.getCode()); } } | public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testCreateUserBasicValidationFailureWithInvalidEmail() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.DOB, "2018-10-15"); requestObj.put(JsonKey.EMAIL, "asd@as"); request.setRequest(requestObj); try { userRequestValidator.createUserBasicValidation(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.emailFormatError.getErrorCode(), e.getCode()); } } | public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest().get(JsonKey.ROLES) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.ROLES, JsonKey.LIST), ERROR_CODE); } if (userRequest.getRequest().containsKey(JsonKey.LANGUAGE) && null != userRequest.getRequest().get(JsonKey.LANGUAGE) && !(userRequest.getRequest().get(JsonKey.LANGUAGE) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.dataTypeError.getErrorMessage(), JsonKey.LANGUAGE, JsonKey.LIST), ERROR_CODE); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserRequestFailureWithInvalidLanguage() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.EMAIL, "[email protected]"); requestObj.put(JsonKey.EMAIL_VERIFIED, true); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.LANGUAGE, ""); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserRequestFailureWithInvalidAddress() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL, "[email protected]"); requestObj.put(JsonKey.EMAIL_VERIFIED, true); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.ADDRESS, ""); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidaeCreateUserRequestFailureWithInvalidEducation() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL, "[email protected]"); requestObj.put(JsonKey.EMAIL_VERIFIED, true); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.EDUCATION, ""); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserRequestFailureWithInvalidAddressType() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL, "[email protected]"); requestObj.put(JsonKey.EMAIL_VERIFIED, true); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); List<Map<String, Object>> addressList = new ArrayList<>(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.ADDRESS_LINE1, "test"); map.put(JsonKey.CITY, "Bangalore"); map.put(JsonKey.COUNTRY, "India"); map.put(JsonKey.ADD_TYPE, "localr"); addressList.add(map); requestObj.put(JsonKey.ADDRESS, addressList); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.addressTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserRequestFailureWithInvalidCountryCode() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.EMAIL, "[email protected]"); requestObj.put(JsonKey.EMAIL_VERIFIED, true); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.FIRST_NAME, "test123"); request.setRequest(requestObj); request.getRequest().put(JsonKey.COUNTRY_CODE, "+as"); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.invalidCountryCode.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserRequestFailureWithEmptyEmailAndPhone() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.USERNAME, "test123"); requestObj.put(JsonKey.PHONE, "9321234123"); requestObj.put(JsonKey.PHONE_VERIFIED, true); requestObj.put(JsonKey.FIRST_NAME, "test123"); requestObj.put(JsonKey.EMAIL, ""); requestObj.put(JsonKey.PHONE, ""); request.setRequest(requestObj); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.emailorPhoneorManagedByRequired.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test(expected = CassandraMigrationException.class) public void extractSchemaVersionWithLeadingUnderscoreAndPrefix() { MigrationInfoHelper.extractVersionAndDescription("V_8_0__Description.cql", "V", "__", ".cql"); } | public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } |
@Test public void testValidateCreateUserFailureWithInvalidEmail() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.EMAIL, "am@ds@cmo"); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.emailFormatError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithoutPhoneVerified() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE, "7894561230"); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserSuccess() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE, "7894561230"); request.getRequest().put(JsonKey.PHONE_VERIFIED, ""); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithPhoneVerifiedFalse() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE, "7894561230"); request.getRequest().put(JsonKey.PHONE_VERIFIED, false); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.phoneVerifiedError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyEducationName() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.NAME, ""); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.EDUCATION, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.educationNameError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyEducationDegree() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.NAME, "name"); map.put(JsonKey.DEGREE, ""); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.EDUCATION, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.educationDegreeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyEducationAddress() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.NAME, "name"); map.put(JsonKey.DEGREE, "degree"); Map<String, Object> address = new HashMap<>(); address.put(JsonKey.ADDRESS_LINE1, ""); map.put(JsonKey.ADDRESS, address); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.EDUCATION, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyEducationCity() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.NAME, "name"); map.put(JsonKey.DEGREE, "degree"); Map<String, Object> address = new HashMap<>(); address.put(JsonKey.ADDRESS_LINE1, "line1"); address.put(JsonKey.CITY, ""); map.put(JsonKey.ADDRESS, address); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.EDUCATION, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyJobProfile() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); request.getRequest().put(JsonKey.JOB_PROFILE, ""); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyJobName() { Request request = initailizeRequest(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.JOB_NAME, ""); map.put(JsonKey.ORG_NAME, "degree"); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.JOB_PROFILE, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.jobNameError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void extractSchemaVersionWithVUnderscorePrefix() { Pair<MigrationVersion, String> info = MigrationInfoHelper.extractVersionAndDescription( "V_8_0__Description.cql", "V_", "__", ".cql"); MigrationVersion version = info.getLeft(); String description = info.getRight(); assertEquals("8.0", version.toString()); assertEquals("Description", description); } | public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } | MigrationInfoHelper { public static Pair<MigrationVersion, String> extractVersionAndDescription( String migrationName, String prefix, String separator, String suffix) { String cleanMigrationName = migrationName.substring(prefix.length(), migrationName.length() - suffix.length()); int descriptionPos = cleanMigrationName.indexOf(separator); if (descriptionPos < 0) { throw new CassandraMigrationException( "Wrong migration name format: " + migrationName + "(It should look like this: " + prefix + "1_2" + separator + "Description" + suffix + ")"); } String version = cleanMigrationName.substring(0, descriptionPos); String description = cleanMigrationName.substring(descriptionPos + separator.length()).replaceAll("_", " "); return Pair.of(MigrationVersion.fromVersion(version), description); } private MigrationInfoHelper(); static Pair<MigrationVersion, String> extractVersionAndDescription(
String migrationName, String prefix, String separator, String suffix); } |
@Test public void testValidateCreateUserFailureWithInvalidJobProfileJoiningDate() { Request request = initailizeRequest(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.JOB_NAME, "kijklo"); map.put(JsonKey.ORG_NAME, "degree"); map.put(JsonKey.JOINING_DATE, "20-15-18"); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.JOB_PROFILE, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithInvalidJobProfileEndDate() { Request request = initailizeRequest(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.JOB_NAME, "kijklo"); map.put(JsonKey.ORG_NAME, "degree"); map.put(JsonKey.END_DATE, "20-15-18"); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.JOB_PROFILE, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dateFormatError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyJobProfileOrgName() { Request request = initailizeRequest(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.JOB_NAME, "kijklo"); map.put(JsonKey.ORG_NAME, ""); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.JOB_PROFILE, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.organisationNameError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithEmptyJobProfileCity() { Request request = initailizeRequest(); Map<String, Object> map = new HashMap<>(); map.put(JsonKey.JOB_NAME, "jabName"); map.put(JsonKey.ORG_NAME, "orgName"); Map<String, Object> address = new HashMap<>(); address.put(JsonKey.ADDRESS_LINE1, "line1"); address.put(JsonKey.CITY, ""); map.put(JsonKey.ADDRESS, address); List<Map<String, Object>> list = new ArrayList<>(); list.add(map); request.getRequest().put(JsonKey.JOB_PROFILE, list); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.addressError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateCreateUserFailureWithInvalidPhoneFormat() { Request request = new Request(); request.getRequest().put(JsonKey.EMAIL, "[email protected]"); request.getRequest().put(JsonKey.EMAIL_VERIFIED, true); request.getRequest().put(JsonKey.PHONE, "9874561230"); request.getRequest().put(JsonKey.COUNTRY_CODE, "+001"); request.getRequest().put(JsonKey.USERNAME, "98745"); request.getRequest().put(JsonKey.FIRST_NAME, "98745"); try { userRequestValidator.validateCreateUserRequest(request); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.phoneNoFormatError.getErrorCode(), e.getCode()); } } | public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateCreateUserRequest(Request userRequest) { externalIdsValidation(userRequest, JsonKey.CREATE); fieldsNotAllowed( Arrays.asList( JsonKey.REGISTERED_ORG_ID, JsonKey.ROOT_ORG_ID, JsonKey.PROVIDER, JsonKey.EXTERNAL_ID, JsonKey.EXTERNAL_ID_PROVIDER, JsonKey.EXTERNAL_ID_TYPE, JsonKey.ID_TYPE), userRequest); createUserBasicValidation(userRequest); validateUserType(userRequest); phoneValidation(userRequest); addressValidation(userRequest); educationValidation(userRequest); jobProfileValidation(userRequest); validateWebPages(userRequest); validateLocationCodes(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateVerifyUserSuccess() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.LOGIN_ID, "username@provider"); request.setRequest(requestObj); boolean response = false; try { new UserRequestValidator().validateVerifyUser(request); response = true; } catch (ProjectCommonException e) { Assert.assertNull(e); } Assert.assertTrue(response); } | public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateGerUserCountFailureWithEstCntReqTrue() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.LOGIN_ID, ""); request.setRequest(requestObj); boolean response = false; try { new UserRequestValidator().validateVerifyUser(request); response = true; } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.loginIdRequired.getErrorCode(), e.getCode()); } Assert.assertFalse(response); } | public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void validateUserCreateV3Sussess() { boolean response = true; try { Request request = new Request(); request.getRequest().put(JsonKey.FIRST_NAME, "test name"); request.getRequest().put(JsonKey.EMAIL, "[email protected]"); request.getRequest().put(JsonKey.EMAIL_VERIFIED, true); request.getRequest().put(JsonKey.PHONE, "9663890445"); request.getRequest().put(JsonKey.PHONE_VERIFIED, true); new UserRequestValidator().validateUserCreateV3(request); } catch (Exception e) { response = false; } Assert.assertTrue(response); } | public void validateUserCreateV3(Request userRequest) { validateParam( (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), ResponseCode.mandatoryParamsMissing, JsonKey.FIRST_NAME); if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); } if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); } phoneVerifiedValidation(userRequest); emailVerifiedValidation(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); } } | UserRequestValidator extends BaseRequestValidator { public void validateUserCreateV3(Request userRequest) { validateParam( (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), ResponseCode.mandatoryParamsMissing, JsonKey.FIRST_NAME); if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); } if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); } phoneVerifiedValidation(userRequest); emailVerifiedValidation(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); } } } | UserRequestValidator extends BaseRequestValidator { public void validateUserCreateV3(Request userRequest) { validateParam( (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), ResponseCode.mandatoryParamsMissing, JsonKey.FIRST_NAME); if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); } if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); } phoneVerifiedValidation(userRequest); emailVerifiedValidation(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); } } } | UserRequestValidator extends BaseRequestValidator { public void validateUserCreateV3(Request userRequest) { validateParam( (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), ResponseCode.mandatoryParamsMissing, JsonKey.FIRST_NAME); if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); } if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); } phoneVerifiedValidation(userRequest); emailVerifiedValidation(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateUserCreateV3(Request userRequest) { validateParam( (String) userRequest.getRequest().get(JsonKey.FIRST_NAME), ResponseCode.mandatoryParamsMissing, JsonKey.FIRST_NAME); if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.PHONE)) && StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.emailorPhoneorManagedByRequired); } if ((StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL)) || StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) && StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))) { ProjectCommonException.throwClientErrorException(ResponseCode.OnlyEmailorPhoneorManagedByRequired); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.MANAGED_BY))){ userRequest.getRequest().put(JsonKey.EMAIL_VERIFIED,null); userRequest.getRequest().put(JsonKey.PHONE_VERIFIED,null); } phoneVerifiedValidation(userRequest); emailVerifiedValidation(userRequest); validatePassword((String) userRequest.getRequest().get(JsonKey.PASSWORD)); if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.EMAIL))) { validateEmail((String) userRequest.getRequest().get(JsonKey.EMAIL)); } if (StringUtils.isNotBlank((String) userRequest.getRequest().get(JsonKey.PHONE))) { validatePhone((String) userRequest.getRequest().get(JsonKey.PHONE)); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateVerifyUserFailureWithEmptyId() { Request request = new Request(); Map<String, Object> requestObj = new HashMap<>(); requestObj.put(JsonKey.LOGIN_ID, ""); request.setRequest(requestObj); boolean response = false; try { userRequestValidator.validateVerifyUser(request); response = true; } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.loginIdRequired.getErrorCode(), e.getCode()); } Assert.assertFalse(response); } | public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateMandatoryFrameworkFieldsSuccess() { Request request = initailizeRequest(); request.getRequest().put(JsonKey.FRAMEWORK, createFrameWork()); boolean response = false; try { new UserRequestValidator() .validateMandatoryFrameworkFields( request.getRequest(), getSupportedFileds(), getMandatoryFields()); response = true; } catch (Exception e) { Assert.assertTrue(response); } Assert.assertTrue(response); } | @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void resolveMigrations() { CqlMigrationResolver cqlMigrationResolver = new CqlMigrationResolver( Thread.currentThread().getContextClassLoader(), new ScriptsLocation("migration/subdir"), "UTF-8"); Collection<ResolvedMigration> migrations = cqlMigrationResolver.resolveMigrations(); assertEquals(3, migrations.size()); List<ResolvedMigration> migrationList = new ArrayList<ResolvedMigration>(migrations); assertEquals("1", migrationList.get(0).getVersion().toString()); assertEquals("1.1", migrationList.get(1).getVersion().toString()); assertEquals("2.0", migrationList.get(2).getVersion().toString()); assertEquals("dir1/V1__First.cql", migrationList.get(0).getScript()); assertEquals("V1_1__Populate_table.cql", migrationList.get(1).getScript()); assertEquals("dir2/V2_0__Add_contents_table.cql", migrationList.get(2).getScript()); } | public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } |
@Test public void testValidateMandatoryFrameworkFieldValueAsString() { Request request = initailizeRequest(); Map<String, Object> frameworkMap = createFrameWork(); frameworkMap.put("medium", "hindi"); request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); boolean response = false; try { new UserRequestValidator() .validateMandatoryFrameworkFields( request.getRequest(), getSupportedFileds(), getMandatoryFields()); response = true; } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.dataTypeError.getErrorCode(), e.getCode()); } Assert.assertFalse(response); } | @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateFrameworkUnknownField() { Request request = initailizeRequest(); Map<String, Object> frameworkMap = createFrameWork(); frameworkMap.put("school", Arrays.asList("school1")); request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); boolean response = false; try { new UserRequestValidator() .validateMandatoryFrameworkFields( request.getRequest(), getSupportedFileds(), getMandatoryFields()); response = true; } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.errorUnsupportedField.getErrorCode(), e.getCode()); } Assert.assertFalse(response); } | @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateFrameworkWithEmptyValue() { Request request = initailizeRequest(); Map<String, Object> frameworkMap = createFrameWork(); frameworkMap.put("medium", Arrays.asList()); request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); boolean response = false; try { new UserRequestValidator() .validateMandatoryFrameworkFields( request.getRequest(), getSupportedFileds(), getMandatoryFields()); response = true; } catch (Exception e) { Assert.assertTrue(response); } Assert.assertTrue(response); } | @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testValidateFrameworkWithNullValue() { Request request = initailizeRequest(); Map<String, Object> frameworkMap = createFrameWork(); frameworkMap.put("medium", null); request.getRequest().put(JsonKey.FRAMEWORK, frameworkMap); boolean response = false; try { new UserRequestValidator() .validateMandatoryFrameworkFields( request.getRequest(), getSupportedFileds(), getMandatoryFields()); response = true; } catch (Exception e) { Assert.assertTrue(response); } Assert.assertTrue(response); } | @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } | UserRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateMandatoryFrameworkFields( Map<String, Object> userMap, List<String> frameworkFields, List<String> frameworkMandatoryFields) { if (userMap.containsKey(JsonKey.FRAMEWORK)) { Map<String, Object> frameworkRequest = (Map<String, Object>) userMap.get(JsonKey.FRAMEWORK); for (String field : frameworkFields) { if (CollectionUtils.isNotEmpty(frameworkMandatoryFields) && frameworkMandatoryFields.contains(field)) { if (!frameworkRequest.containsKey(field)) { validateParam(null, ResponseCode.mandatoryParamsMissing, field); } validateListParamWithPrefix(frameworkRequest, JsonKey.FRAMEWORK, field); List<String> fieldValue = (List) frameworkRequest.get(field); if (fieldValue.isEmpty()) { throw new ProjectCommonException( ResponseCode.errorMandatoryParamsEmpty.getErrorCode(), ResponseCode.errorMandatoryParamsEmpty.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, field)); } } else { if (frameworkRequest.containsKey(field) && frameworkRequest.get(field) != null && !(frameworkRequest.get(field) instanceof List)) { throw new ProjectCommonException( ResponseCode.dataTypeError.getErrorCode(), ResponseCode.dataTypeError.getErrorMessage(), ERROR_CODE, field, JsonKey.LIST); } } } List<String> frameworkRequestFieldList = frameworkRequest.keySet().stream().collect(Collectors.toList()); for (String frameworkRequestField : frameworkRequestFieldList) { if (!frameworkFields.contains(frameworkRequestField)) { throw new ProjectCommonException( ResponseCode.errorUnsupportedField.getErrorCode(), ResponseCode.errorUnsupportedField.getErrorMessage(), ERROR_CODE, StringFormatter.joinByDot(JsonKey.FRAMEWORK, frameworkRequestField)); } } } } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest); void validateCreateUserV3Request(Request userRequest); void validateCreateUserV1Request(Request userRequest); void validateCreateUserV2Request(Request userRequest); void fieldsNotAllowed(List<String> fields, Request userRequest); void phoneValidation(Request userRequest); void createUserBasicValidation(Request userRequest); @SuppressWarnings("unchecked") void validateWebPages(Request request); void validateUpdateUserRequest(Request userRequest); void externalIdsValidation(Request userRequest, String operation); void validateChangePassword(Request userRequest); void validateVerifyUser(Request userRequest); void validateAssignRole(Request request); void validateForgotPassword(Request request); void validateBulkUserData(Request userRequest); @SuppressWarnings("unchecked") void validateMandatoryFrameworkFields(
Map<String, Object> userMap,
List<String> frameworkFields,
List<String> frameworkMandatoryFields); @SuppressWarnings("unchecked") void validateFrameworkCategoryValues(
Map<String, Object> userMap, Map<String, List<Map<String, String>>> frameworkMap); void validateUserMergeRequest(
Request request, String authUserToken, String sourceUserToken); void validateCertValidationRequest(Request request); } |
@Test public void testGetContextFailureWithoutActionUrl() { Map<String, Object> templateMap = new HashMap<>(); templateMap.put(JsonKey.NAME, "userName"); VelocityContext context = ProjectUtil.getContext(templateMap); assertEquals(false, context.internalContainsKey(JsonKey.ACTION_URL)); } | public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetContextSuccessWithFromMail() { Map<String, Object> templateMap = new HashMap<>(); templateMap.put(JsonKey.ACTION_URL, "googli.com"); templateMap.put(JsonKey.NAME, "userName"); boolean envVal = !StringUtils.isBlank(System.getenv(JsonKey.EMAIL_SERVER_FROM)); boolean cacheVal = propertiesCache.getProperty(JsonKey.EMAIL_SERVER_FROM) != null; VelocityContext context = ProjectUtil.getContext(templateMap); if (envVal) { assertEquals( System.getenv(JsonKey.EMAIL_SERVER_FROM), context.internalGet(JsonKey.FROM_EMAIL)); } else if (cacheVal) { assertEquals( propertiesCache.getProperty(JsonKey.EMAIL_SERVER_FROM), context.internalGet(JsonKey.FROM_EMAIL)); } } | public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetContextSuccessWithOrgImageUrl() { Map<String, Object> templateMap = new HashMap<>(); templateMap.put(JsonKey.ACTION_URL, "googli.com"); templateMap.put(JsonKey.NAME, "userName"); boolean envVal = !StringUtils.isBlank(System.getenv(JsonKey.SUNBIRD_ENV_LOGO_URL)); boolean cacheVal = propertiesCache.getProperty(JsonKey.SUNBIRD_ENV_LOGO_URL) != null; VelocityContext context = ProjectUtil.getContext(templateMap); if (envVal) { assertEquals( System.getenv(JsonKey.SUNBIRD_ENV_LOGO_URL), context.internalGet(JsonKey.ORG_IMAGE_URL)); } else if (cacheVal) { assertEquals( propertiesCache.getProperty(JsonKey.SUNBIRD_ENV_LOGO_URL), context.internalGet(JsonKey.ORG_IMAGE_URL)); } } | public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static VelocityContext getContext(Map<String, Object> map) { propertiesCache = PropertiesCache.getInstance(); VelocityContext context = new VelocityContext(); if (StringUtils.isNotBlank((String) map.get(JsonKey.ACTION_URL))) { context.put(JsonKey.ACTION_URL, getValue(map, JsonKey.ACTION_URL)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.NAME))) { context.put(JsonKey.NAME, getValue(map, JsonKey.NAME)); } context.put(JsonKey.BODY, getValue(map, JsonKey.BODY)); String fromEmail = getFromEmail(map); if (StringUtils.isNotBlank(fromEmail)) { context.put(JsonKey.FROM_EMAIL, fromEmail); } if (StringUtils.isNotBlank((String) map.get(JsonKey.ORG_NAME))) { context.put(JsonKey.ORG_NAME, getValue(map, JsonKey.ORG_NAME)); } String logoUrl = getSunbirdLogoUrl(map); if (StringUtils.isNotBlank(logoUrl)) { context.put(JsonKey.ORG_IMAGE_URL, logoUrl); } context.put(JsonKey.ACTION_NAME, getValue(map, JsonKey.ACTION_NAME)); context.put(JsonKey.USERNAME, getValue(map, JsonKey.USERNAME)); context.put(JsonKey.TEMPORARY_PASSWORD, getValue(map, JsonKey.TEMPORARY_PASSWORD)); if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_NAME))) { context.put(JsonKey.COURSE_NAME, map.remove(JsonKey.COURSE_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.START_DATE))) { context.put(JsonKey.BATCH_START_DATE, map.remove(JsonKey.START_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.END_DATE))) { context.put(JsonKey.BATCH_END_DATE, map.remove(JsonKey.END_DATE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.BATCH_NAME))) { context.put(JsonKey.BATCH_NAME, map.remove(JsonKey.BATCH_NAME)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.FIRST_NAME))) { context.put(JsonKey.NAME, map.remove(JsonKey.FIRST_NAME)); } else { context.put(JsonKey.NAME, ""); } if (StringUtils.isNotBlank((String) map.get(JsonKey.SIGNATURE))) { context.put(JsonKey.SIGNATURE, map.remove(JsonKey.SIGNATURE)); } if (StringUtils.isNotBlank((String) map.get(JsonKey.COURSE_BATCH_URL))) { context.put(JsonKey.COURSE_BATCH_URL, map.remove(JsonKey.COURSE_BATCH_URL)); } context.put(JsonKey.ALLOWED_LOGIN, propertiesCache.getProperty(JsonKey.SUNBIRD_ALLOWED_LOGIN)); map = addCertStaticResource(map); for (Map.Entry<String, Object> entry : map.entrySet()) { context.put(entry.getKey(), entry.getValue()); } return context; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCreateAuthTokenSuccess() { String authToken = ProjectUtil.createAuthToken("test", "tset1234"); assertNotNull(authToken); } | public static String createAuthToken(String name, String source) { String data = name + source + System.currentTimeMillis(); UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); return authId.toString(); } | ProjectUtil { public static String createAuthToken(String name, String source) { String data = name + source + System.currentTimeMillis(); UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); return authId.toString(); } } | ProjectUtil { public static String createAuthToken(String name, String source) { String data = name + source + System.currentTimeMillis(); UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); return authId.toString(); } } | ProjectUtil { public static String createAuthToken(String name, String source) { String data = name + source + System.currentTimeMillis(); UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); return authId.toString(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static String createAuthToken(String name, String source) { String data = name + source + System.currentTimeMillis(); UUID authId = UUID.nameUUIDFromBytes(data.getBytes(StandardCharsets.UTF_8)); return authId.toString(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testValidatePhoneNumberFailureWithInvalidPhoneNumber() { assertFalse(ProjectUtil.validatePhoneNumber("312")); } | public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testValidatePhoneNumberSuccess() { assertTrue(ProjectUtil.validatePhoneNumber("9844016699")); } | public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean validatePhoneNumber(String phone) { String phoneNo = ""; phoneNo = phone.replace("+", ""); if (phoneNo.matches("\\d{10}")) return true; else if (phoneNo.matches("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4}")) return true; else if (phoneNo.matches("\\d{3}-\\d{3}-\\d{4}\\s(x|(ext))\\d{3,5}")) return true; else return (phoneNo.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test(expected = CassandraMigrationException.class) public void resolveMigrationsNonExisting() { CqlMigrationResolver cqlMigrationResolver = new CqlMigrationResolver( Thread.currentThread().getContextClassLoader(), new ScriptsLocation("non/existing"), "UTF-8"); cqlMigrationResolver.resolveMigrations(); } | public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } | CqlMigrationResolver implements MigrationResolver { public List<ResolvedMigration> resolveMigrations() { List<ResolvedMigration> migrations = new ArrayList<>(); Resource[] resources = scanner.scanForResources(location, CQL_MIGRATION_PREFIX, CQL_MIGRATION_SUFFIX); for (Resource resource : resources) { ResolvedMigration resolvedMigration = extractMigrationInfo(resource); resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk()); resolvedMigration.setExecutor(new CqlMigrationExecutor(resource, encoding)); migrations.add(resolvedMigration); } Collections.sort(migrations, new ResolvedMigrationComparator()); return migrations; } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } |
@Test public void testGenerateRandomPasswordSuccess() { assertNotNull(ProjectUtil.generateRandomPassword()); } | public static String generateRandomPassword() { String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); while (salt.length() < randomPasswordLength) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } String saltStr = salt.toString(); return saltStr; } | ProjectUtil { public static String generateRandomPassword() { String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); while (salt.length() < randomPasswordLength) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } String saltStr = salt.toString(); return saltStr; } } | ProjectUtil { public static String generateRandomPassword() { String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); while (salt.length() < randomPasswordLength) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } String saltStr = salt.toString(); return saltStr; } } | ProjectUtil { public static String generateRandomPassword() { String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); while (salt.length() < randomPasswordLength) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } String saltStr = salt.toString(); return saltStr; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static String generateRandomPassword() { String SALTCHARS = "abcdef12345ghijklACDEFGHmnopqrs67IJKLMNOP890tuvQRSTUwxyzVWXYZ"; StringBuilder salt = new StringBuilder(); Random rnd = new Random(); while (salt.length() < randomPasswordLength) { int index = (int) (rnd.nextFloat() * SALTCHARS.length()); salt.append(SALTCHARS.charAt(index)); } String saltStr = salt.toString(); return saltStr; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCreateCheckResponseSuccess() { Map<String, Object> responseMap = ProjectUtil.createCheckResponse("LearnerService", false, null); assertEquals(true, responseMap.get(JsonKey.Healthy)); } | public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCreateCheckResponseFailureWithException() { Map<String, Object> responseMap = ProjectUtil.createCheckResponse( "LearnerService", true, new ProjectCommonException( ResponseCode.invalidObjectType.getErrorCode(), ResponseCode.invalidObjectType.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode())); assertEquals(false, responseMap.get(JsonKey.Healthy)); assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), responseMap.get(JsonKey.ERROR)); assertEquals( ResponseCode.invalidObjectType.getErrorMessage(), responseMap.get(JsonKey.ERRORMSG)); } | public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, Object> createCheckResponse( String serviceName, boolean isError, Exception e) { Map<String, Object> responseMap = new HashMap<>(); responseMap.put(JsonKey.NAME, serviceName); if (!isError) { responseMap.put(JsonKey.Healthy, true); responseMap.put(JsonKey.ERROR, ""); responseMap.put(JsonKey.ERRORMSG, ""); } else { responseMap.put(JsonKey.Healthy, false); if (e != null && e instanceof ProjectCommonException) { ProjectCommonException commonException = (ProjectCommonException) e; responseMap.put(JsonKey.ERROR, commonException.getResponseCode()); responseMap.put(JsonKey.ERRORMSG, commonException.getMessage()); } else { responseMap.put(JsonKey.ERROR, e != null ? e.getMessage() : "CONNECTION_ERROR"); responseMap.put(JsonKey.ERRORMSG, e != null ? e.getMessage() : "Connection error"); } } return responseMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testFormatMessageSuccess() { String msg = ProjectUtil.formatMessage("Hello {0}", "user"); assertEquals("Hello user", msg); } | public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testFormatMessageFailureWithInvalidVariable() { String msg = ProjectUtil.formatMessage("Hello ", "user"); assertNotEquals("Hello user", msg); } | public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsEmailValidFailureWithWrongEmail() { boolean msg = ProjectUtil.isEmailvalid("Hello "); assertFalse(msg); } | public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsDateValidFormatSuccess() { boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", "2017-12-18"); assertTrue(bool); } | public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsDateValidFormatFailureWithEmptyDate() { boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", ""); assertFalse(bool); } | public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsDateValidFormatFailureWithInvalidDate() { boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd", "2017-12-18"); assertTrue(bool); } | public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsDateValidFormatFailureWithEmptyDateTime() { boolean bool = ProjectUtil.isDateValidFormat("yyyy-MM-dd HH:mm:ss:SSSZ", ""); assertFalse(bool); } | public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isDateValidFormat(String format, String value) { Date date = null; try { SimpleDateFormat sdf = new SimpleDateFormat(format); date = sdf.parse(value); if (!value.equals(sdf.format(date))) { date = null; } } catch (ParseException ex) { ProjectLogger.log(ex.getMessage(), ex); } return date != null; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void extractScriptName() { CqlMigrationResolver cqlMigrationResolver = new CqlMigrationResolver( Thread.currentThread().getContextClassLoader(), new ScriptsLocation("db/migration"), "UTF-8"); assertEquals( "db_0__init.cql", cqlMigrationResolver.extractScriptName( new ClassPathResource( "db/migration/db_0__init.cql", Thread.currentThread().getContextClassLoader()))); } | String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } |
@Test public void testGetEkstepHeaderSuccess() { Map<String, String> map = ProjectUtil.getEkstepHeader(); assertEquals(map.get("Content-Type"), "application/json"); assertNotNull(map.get(JsonKey.AUTHORIZATION)); } | public static Map<String, String> getEkstepHeader() { Map<String, String> headerMap = new HashMap<>(); String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); if (StringUtils.isBlank(header)) { header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); } else { header = JsonKey.BEARER + header; } headerMap.put(JsonKey.AUTHORIZATION, header); headerMap.put("Content-Type", "application/json"); return headerMap; } | ProjectUtil { public static Map<String, String> getEkstepHeader() { Map<String, String> headerMap = new HashMap<>(); String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); if (StringUtils.isBlank(header)) { header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); } else { header = JsonKey.BEARER + header; } headerMap.put(JsonKey.AUTHORIZATION, header); headerMap.put("Content-Type", "application/json"); return headerMap; } } | ProjectUtil { public static Map<String, String> getEkstepHeader() { Map<String, String> headerMap = new HashMap<>(); String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); if (StringUtils.isBlank(header)) { header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); } else { header = JsonKey.BEARER + header; } headerMap.put(JsonKey.AUTHORIZATION, header); headerMap.put("Content-Type", "application/json"); return headerMap; } } | ProjectUtil { public static Map<String, String> getEkstepHeader() { Map<String, String> headerMap = new HashMap<>(); String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); if (StringUtils.isBlank(header)) { header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); } else { header = JsonKey.BEARER + header; } headerMap.put(JsonKey.AUTHORIZATION, header); headerMap.put("Content-Type", "application/json"); return headerMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, String> getEkstepHeader() { Map<String, String> headerMap = new HashMap<>(); String header = System.getenv(JsonKey.EKSTEP_AUTHORIZATION); if (StringUtils.isBlank(header)) { header = PropertiesCache.getInstance().getProperty(JsonKey.EKSTEP_AUTHORIZATION); } else { header = JsonKey.BEARER + header; } headerMap.put(JsonKey.AUTHORIZATION, header); headerMap.put("Content-Type", "application/json"); return headerMap; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testReportTrackingStatusSuccess() { assertEquals(0, ProjectUtil.ReportTrackingStatus.NEW.getValue()); assertEquals(1, ProjectUtil.ReportTrackingStatus.GENERATING_DATA.getValue()); assertEquals(2, ProjectUtil.ReportTrackingStatus.UPLOADING_FILE.getValue()); assertEquals(3, ProjectUtil.ReportTrackingStatus.UPLOADING_FILE_SUCCESS.getValue()); assertEquals(4, ProjectUtil.ReportTrackingStatus.SENDING_MAIL.getValue()); assertEquals(5, ProjectUtil.ReportTrackingStatus.SENDING_MAIL_SUCCESS.getValue()); assertEquals(9, ProjectUtil.ReportTrackingStatus.FAILED.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testUserRoleSuccess() { assertEquals("PUBLIC", ProjectUtil.UserRole.PUBLIC.getValue()); assertEquals("CONTENT_CREATOR", ProjectUtil.UserRole.CONTENT_CREATOR.getValue()); assertEquals("CONTENT_REVIEWER", ProjectUtil.UserRole.CONTENT_REVIEWER.getValue()); assertEquals("ORG_ADMIN", ProjectUtil.UserRole.ORG_ADMIN.getValue()); assertEquals("ORG_MEMBER", ProjectUtil.UserRole.ORG_MEMBER.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testBulkProcessStatusSuccess() { assertEquals(0, ProjectUtil.BulkProcessStatus.NEW.getValue()); assertEquals(1, ProjectUtil.BulkProcessStatus.IN_PROGRESS.getValue()); assertEquals(2, ProjectUtil.BulkProcessStatus.INTERRUPT.getValue()); assertEquals(3, ProjectUtil.BulkProcessStatus.COMPLETED.getValue()); assertEquals(9, ProjectUtil.BulkProcessStatus.FAILED.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testOrgStatusSuccess() { assertEquals(new Integer(0), ProjectUtil.OrgStatus.INACTIVE.getValue()); assertEquals(new Integer(1), ProjectUtil.OrgStatus.ACTIVE.getValue()); assertEquals(new Integer(2), ProjectUtil.OrgStatus.BLOCKED.getValue()); assertEquals(new Integer(3), ProjectUtil.OrgStatus.RETIRED.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCourseMgmtStatusSuccess() { assertEquals("draft", ProjectUtil.CourseMgmtStatus.DRAFT.getValue()); assertEquals("live", ProjectUtil.CourseMgmtStatus.LIVE.getValue()); assertEquals("retired", ProjectUtil.CourseMgmtStatus.RETIRED.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testProgressStatusSuccess() { assertEquals(0, ProjectUtil.ProgressStatus.NOT_STARTED.getValue()); assertEquals(1, ProjectUtil.ProgressStatus.STARTED.getValue()); assertEquals(2, ProjectUtil.ProgressStatus.COMPLETED.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testEnvironmentSuccess() { assertEquals(1, ProjectUtil.Environment.dev.getValue()); assertEquals(2, ProjectUtil.Environment.qa.getValue()); assertEquals(3, ProjectUtil.Environment.prod.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testObjectTypesSuccess() { assertEquals("batch", ProjectUtil.ObjectTypes.batch.getValue()); assertEquals("user", ProjectUtil.ObjectTypes.user.getValue()); assertEquals("organisation", ProjectUtil.ObjectTypes.organisation.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testSourceSuccess() { assertEquals("web", ProjectUtil.Source.WEB.getValue()); assertEquals("android", ProjectUtil.Source.ANDROID.getValue()); assertEquals("ios", ProjectUtil.Source.IOS.getValue()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void extractScriptNameRootLocation() { CqlMigrationResolver cqlMigrationResolver = new CqlMigrationResolver( Thread.currentThread().getContextClassLoader(), new ScriptsLocation(""), "UTF-8"); assertEquals( "db_0__init.cql", cqlMigrationResolver.extractScriptName( new ClassPathResource( "db_0__init.cql", Thread.currentThread().getContextClassLoader()))); } | String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } | CqlMigrationResolver implements MigrationResolver { String extractScriptName(Resource resource) { if (location.getPath().isEmpty()) { return resource.getLocation(); } return resource.getLocation().substring(location.getPath().length() + 1); } CqlMigrationResolver(ClassLoader classLoader, ScriptsLocation location, String encoding); List<ResolvedMigration> resolveMigrations(); } |
@Test public void testStatusSuccess() { assertEquals(1, ProjectUtil.Status.ACTIVE.getValue()); assertEquals(0, ProjectUtil.Status.INACTIVE.getValue()); assertEquals(false, ProjectUtil.ActiveStatus.INACTIVE.getValue()); assertEquals(true, ProjectUtil.ActiveStatus.ACTIVE.getValue()); assertEquals("orgimg", ProjectUtil.AzureContainer.orgImage.getName()); assertEquals("userprofileimg", ProjectUtil.AzureContainer.userProfileImg.getName()); } | private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { private static Object getValue(Map<String, Object> map, String key) { Object value = map.get(key); map.remove(key); return value; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCreateAndThrowServerErrorSuccess() { try { ProjectUtil.createAndThrowServerError(); } catch (ProjectCommonException e) { assertEquals(ResponseCode.SERVER_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.SERVER_ERROR.getErrorCode(), e.getCode()); } } | public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } | ProjectUtil { public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } } | ProjectUtil { public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } } | ProjectUtil { public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testCreateAndThrowInvalidUserDataExceptionSuccess() { try { ProjectUtil.createAndThrowInvalidUserDataException(); } catch (ProjectCommonException e) { assertEquals(ResponseCode.CLIENT_ERROR.getResponseCode(), e.getResponseCode()); assertEquals(ResponseCode.invalidUsrData.getErrorCode(), e.getCode()); } } | public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } | ProjectUtil { public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } } | ProjectUtil { public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } } | ProjectUtil { public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetDateRangeSuccess() { int noOfDays = 7; Map<String, String> map = ProjectUtil.getDateRange(noOfDays); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -noOfDays); assertEquals(map.get("startDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); assertEquals(map.get("endDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); } | public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetDateRangeFailure() { int noOfDays = 14; Map<String, String> map = ProjectUtil.getDateRange(noOfDays); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -noOfDays); assertEquals(map.get("startDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, noOfDays); assertNotEquals(map.get("endDate"), new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); } | public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetDateRangeFailureWithZeroDays() { int noOfDays = 0; Map<String, String> map = ProjectUtil.getDateRange(noOfDays); assertNull(map.get("startDate")); assertNull(map.get("endDate")); } | public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetDateRangeFailureWithNegativeValue() { int noOfDays = -100; Map<String, String> map = ProjectUtil.getDateRange(noOfDays); assertNull(map.get("startDate")); assertNull(map.get("endDate")); } | public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static Map<String, String> getDateRange(int numDays) { Map<String, String> map = new HashMap<>(); if (numDays <= 0) { return map; } Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -numDays); map.put(STARTDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); cal.add(Calendar.DATE, -1); map.put(ENDDATE, new SimpleDateFormat(YYYY_MM_DD_FORMATTER).format(cal.getTime())); return map; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsEmailValidFailureWithInvalidFormat() { boolean bool = ProjectUtil.isEmailvalid("amit.kumartarento.com"); Assert.assertFalse(bool); } | public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testIsEmailValidSuccess() { boolean bool = ProjectUtil.isEmailvalid("[email protected]"); assertTrue(bool); } | public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
@Test public void testGetLmsUserIdSuccessWithoutFedUserId() { String userid = ProjectUtil.getLmsUserId("1234567890"); assertEquals("1234567890", userid); } | public static String getLmsUserId(String fedUserId) { String userId = fedUserId; String prefix = "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { userId = fedUserId.replace(prefix, ""); } return userId; } | ProjectUtil { public static String getLmsUserId(String fedUserId) { String userId = fedUserId; String prefix = "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { userId = fedUserId.replace(prefix, ""); } return userId; } } | ProjectUtil { public static String getLmsUserId(String fedUserId) { String userId = fedUserId; String prefix = "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { userId = fedUserId.replace(prefix, ""); } return userId; } } | ProjectUtil { public static String getLmsUserId(String fedUserId) { String userId = fedUserId; String prefix = "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { userId = fedUserId.replace(prefix, ""); } return userId; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); } | ProjectUtil { public static String getLmsUserId(String fedUserId) { String userId = fedUserId; String prefix = "f:" + getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID) + ":"; if (StringUtils.isNotBlank(fedUserId) && fedUserId.startsWith(prefix)) { userId = fedUserId.replace(prefix, ""); } return userId; } static boolean isStringNullOREmpty(String value); static String getFormattedDate(); static String formatDate(Date date); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static String getUniqueIdFromTimestamp(int environmentId); static synchronized String generateUniqueId(); static double calculatePercentage(double score, double maxScore); static AssessmentResult calcualteAssessmentResult(double percentage); static boolean isNull(Object obj); static boolean isNotNull(Object obj); static String formatMessage(String exceptionMsg, Object... fieldValue); static SimpleDateFormat getDateFormatter(); static VelocityContext getContext(Map<String, Object> map); static Map<String, Object> createCheckResponse(
String serviceName, boolean isError, Exception e); static String registertag(String tagId, String body, Map<String, String> header); static String generateRandomPassword(); static boolean validatePhoneNumber(String phone); static Map<String, String> getEkstepHeader(); static boolean validatePhone(String phNumber, String countryCode); static boolean validateCountryCode(String countryCode); static boolean validateUUID(String uuidStr); static String getSMSBody(Map<String, String> smsTemplate); static boolean isDateValidFormat(String format, String value); static void createAndThrowServerError(); static ProjectCommonException createServerError(ResponseCode responseCode); static void createAndThrowInvalidUserDataException(); static boolean isUrlvalid(String url); static String getConfigValue(String key); static String createIndex(); static boolean isNotEmptyStringArray(String[] strArray); static String convertMapToJsonString(List<Map<String, Object>> mapList); static void removeUnwantedFields(Map<String, Object> map, String... keys); static Map convertJsonStringToMap(String jsonString); static T convertToRequestPojo(Request request, Class<T> clazz); static Map<String, String> getDateRange(int numDays); static ProjectCommonException createClientException(ResponseCode responseCode); static String getLmsUserId(String fedUserId); static String getFirstNCharacterString(String originalText, int noOfChar); static Integer DEFAULT_BATCH_SIZE; static final long BACKGROUND_ACTOR_WAIT_TIME; static final String ELASTIC_DATE_FORMAT; static final String YEAR_MONTH_DATE_FORMAT; static PropertiesCache propertiesCache; static final String[] excludes; static final String[] defaultPrivateFields; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.