method2testcases
stringlengths
118
6.63k
### Question: TelemetryGenerator { public static String search(Map<String, Object> context, Map<String, Object> params) { if (!validateRequest(context, params)) { return ""; } String actorId = (String) context.get(JsonKey.ACTOR_ID); String actorType = (String) context.get(JsonKey.ACTOR_TYPE); Actor actor = new Actor(ac...
### Question: TelemetryGenerator { public static String log(Map<String, Object> context, Map<String, Object> params) { if (!validateRequest(context, params)) { return ""; } String actorId = (String) context.get(JsonKey.ACTOR_ID); String actorType = (String) context.get(JsonKey.ACTOR_TYPE); Actor actor = new Actor(actor...
### Question: TelemetryGenerator { public static String error(Map<String, Object> context, Map<String, Object> params) { if (!validateRequest(context, params)) { return ""; } String actorId = (String) context.get(JsonKey.ACTOR_ID); String actorType = (String) context.get(JsonKey.ACTOR_TYPE); Actor actor = new Actor(act...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String getUsernameById(String userId) { String fedUserId = getFederatedUserId(userId); try { UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); UserRepresentation ur = resource.toRepresentation()...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String deactivateUser(Map<String, Object> request, RequestContext context) { String userId = (String) request.get(JsonKey.USER_ID); makeUserActiveOrInactive(userId, false, context); return JsonKey.SUCCESS; } PublicKey getPublicKey(); @Override ...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String removeUser(Map<String, Object> request, RequestContext context) { Keycloak keycloak = KeyCloakConnectionProvider.getConnection(); String userId = (String) request.get(JsonKey.USER_ID); try { String fedUserId = getFederatedUserId(userId); ...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public boolean addUserLoginTime(String userId) { boolean response = true; try { String fedUserId = getFederatedUserId(userId); UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); UserRepresentation ur = ...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String getLastLoginTime(String userId) { String lastLoginTime = null; try { String fedUserId = getFederatedUserId(userId); UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); UserRepresentation ur...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String activateUser(Map<String, Object> request, RequestContext context) { String userId = (String) request.get(JsonKey.USER_ID); makeUserActiveOrInactive(userId, true, context); return JsonKey.SUCCESS; } PublicKey getPublicKey(); @Override Str...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public boolean isEmailVerified(String userId) { String fedUserId = getFederatedUserId(userId); UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); if (isNull(resource)) { return false; } return resource....
### Question: KeyCloakServiceImpl implements SSOManager { @Override public String setEmailVerifiedTrue(String userId) { updateEmailVerifyStatus(userId, true); return JsonKey.SUCCESS; } PublicKey getPublicKey(); @Override String verifyToken(String accessToken, RequestContext context); @Override boolean updatePassword(S...
### Question: MigrationUtils { public static boolean updateRecord( Map<String, Object> propertiesMap, String channel, String userExtId, RequestContext context) { Map<String, Object> compositeKeysMap = new HashMap<>(); compositeKeysMap.put(JsonKey.USER_EXT_ID, userExtId); compositeKeysMap.put(JsonKey.CHANNEL, channel); ...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public boolean doPasswordUpdate(String userId, String password) { boolean response = false; try { String fedUserId = getFederatedUserId(userId); UserResource resource = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); Creden...
### Question: KeyCloakServiceImpl implements SSOManager { private String getFederatedUserId(String userId) { return String.join( ":", "f", ProjectUtil.getConfigValue(JsonKey.SUNBIRD_KEYCLOAK_USER_FEDERATION_PROVIDER_ID), userId); } PublicKey getPublicKey(); @Override String verifyToken(String accessToken, RequestConte...
### Question: KeyCloakServiceImpl implements SSOManager { @Override public boolean updatePassword(String userId, String password, RequestContext context) { try { String fedUserId = getFederatedUserId(userId); UserResource ur = keycloak.realm(KeyCloakConnectionProvider.SSO_REALM).users().get(fedUserId); CredentialRepres...
### Question: KeyCloakRsaKeyFetcher { public PublicKey getPublicKeyFromKeyCloak(String url, String realm) { try { Map<String, String> valueMap = null; Decoder urlDecoder = Base64.getUrlDecoder(); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); String publicKeyString = requestKeyFromKeycloak(url, realm); if (publ...
### Question: CloudStorageUtil { public static String upload( CloudStorageType storageType, String container, String objectKey, String filePath) { IStorageService storageService = getStorageService(storageType); return storageService.upload( container, filePath, objectKey, Option.apply(false), Option.apply(1), Option.a...
### Question: MigrationUtils { public static boolean markUserAsRejected(ShadowUser shadowUser, RequestContext context) { Map<String, Object> propertiesMap = new HashMap<>(); propertiesMap.put(JsonKey.CLAIM_STATUS, ClaimStatus.REJECTED.getValue()); propertiesMap.put(JsonKey.UPDATED_ON, new Timestamp(System.currentTimeMi...
### Question: CloudStorageUtil { public static String getSignedUrl( CloudStorageType storageType, String container, String objectKey) { IStorageService storageService = getStorageService(storageType); return getSignedUrl(storageService, storageType, container, objectKey); } static String upload( CloudStorageType...
### Question: ConfigUtil { public static Config getConfigFromJsonString(String jsonString, String configType) { ProjectLogger.log("ConfigUtil: getConfigFromJsonString called", LoggerEnum.DEBUG.name()); if (null == jsonString || StringUtils.isBlank(jsonString)) { ProjectLogger.log( "ConfigUtil:getConfigFromJsonString: E...
### Question: UserProfileRequestValidator extends BaseRequestValidator { @SuppressWarnings("unchecked") public void validateProfileVisibility(Request request) { validateParam( (String) request.getRequest().get(JsonKey.USER_ID), ResponseCode.mandatoryParamsMissing, JsonKey.USER_ID); validateUserId(request, JsonKey.USER_...
### Question: RequestValidator { public static void validateRegisterClient(Request request) { if (StringUtils.isBlank((String) request.getRequest().get(JsonKey.CLIENT_NAME))) { throw createExceptionInstance(ResponseCode.invalidClientName.getErrorCode()); } } private RequestValidator(); static void validateUploadUser(M...
### Question: MigrationUtils { public static boolean updateClaimStatus( ShadowUser shadowUser, int claimStatus, RequestContext context) { Map<String, Object> propertiesMap = new WeakHashMap<>(); propertiesMap.put(JsonKey.CLAIM_STATUS, claimStatus); propertiesMap.put(JsonKey.UPDATED_ON, new Timestamp(System.currentTimeM...
### Question: RequestValidator { public static void validateUpdateClientKey(String clientId, String masterAccessToken) { validateClientId(clientId); if (StringUtils.isBlank(masterAccessToken)) { throw createExceptionInstance(ResponseCode.invalidRequestData.getErrorCode()); } } private RequestValidator(); static void v...
### Question: RequestValidator { public static void validateClientId(String clientId) { if (StringUtils.isBlank(clientId)) { throw createExceptionInstance(ResponseCode.invalidClientId.getErrorCode()); } } private RequestValidator(); static void validateUploadUser(Map<String, Object> reqObj); static void validateSyncRe...
### Question: RequestValidator { public static void validateFileUpload(Request reqObj) { if (StringUtils.isBlank((String) reqObj.get(JsonKey.CONTAINER))) { throw new ProjectCommonException( ResponseCode.storageContainerNameMandatory.getErrorCode(), ResponseCode.storageContainerNameMandatory.getErrorMessage(), ERROR_COD...
### Question: RequestValidator { public static void validateSyncRequest(Request request) { String operation = (String) request.getRequest().get(JsonKey.OPERATION_FOR); if ((null != operation) && (!operation.equalsIgnoreCase("keycloak"))) { if (request.getRequest().get(JsonKey.OBJECT_TYPE) == null) { throw new ProjectCo...
### Question: MigrationUtils { public static List<ShadowUser> getEligibleUsersById( String userId, Map<String, Object> propsMap, RequestContext context) { List<ShadowUser> shadowUsersList = new ArrayList<>(); Response response = cassandraOperation.searchValueInList( JsonKey.SUNBIRD, JsonKey.SHADOW_USER, JsonKey.USERIDS...
### Question: RequestValidator { public static void validateUpdateOrgType(Request reqObj) { if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.NAME))) { throw createExceptionInstance(ResponseCode.orgTypeMandatory.getErrorCode()); } if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.ID))) { t...
### Question: RequestValidator { public static void validateCreateOrgType(Request reqObj) { if (StringUtils.isBlank((String) reqObj.getRequest().get(JsonKey.NAME))) { throw createExceptionInstance(ResponseCode.orgTypeMandatory.getErrorCode()); } } private RequestValidator(); static void validateUploadUser(Map<String, ...
### Question: RequestValidator { public static void validateGetClientKey(String id, String type) { validateClientId(id); if (StringUtils.isBlank(type)) { throw createExceptionInstance(ResponseCode.invalidRequestData.getErrorCode()); } } private RequestValidator(); static void validateUploadUser(Map<String, Object> req...
### Question: UserRequestValidator extends BaseRequestValidator { public static boolean isGoodPassword(String password) { return password.matches(ProjectUtil.getConfigValue(JsonKey.SUNBIRD_PASS_REGEX)); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validate...
### Question: UserRequestValidator extends BaseRequestValidator { public void createUserBasicValidation(Request userRequest) { createUserBasicProfileFieldsValidation(userRequest); if (userRequest.getRequest().containsKey(JsonKey.ROLES) && null != userRequest.getRequest().get(JsonKey.ROLES) && !(userRequest.getRequest()...
### Question: UserRequestValidator extends BaseRequestValidator { public void fieldsNotAllowed(List<String> fields, Request userRequest) { for (String field : fields) { if (((userRequest.getRequest().get(field) instanceof String) && StringUtils.isNotBlank((String) userRequest.getRequest().get(field))) || (null != userR...
### Question: UserRequestValidator extends BaseRequestValidator { public void validateCreateUserV3Request(Request userRequest) { validateCreateUserRequest(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateUserCreateV3(Request userRequest);...
### Question: UserRequestValidator extends BaseRequestValidator { public void validateCreateUserV1Request(Request userRequest) { validateUserName(userRequest); validateCreateUserV3Request(userRequest); } void validateCreateUserRequest(Request userRequest); static boolean isGoodPassword(String password); void validateU...
### Question: 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.ge...
### Question: UserExternalIdentityAdapter { public static List<Map<String, String>> convertSelfDeclareFieldsToExternalIds( Map<String, Object> selfDeclaredFields) { List<Map<String, String>> externalIds = new ArrayList<>(); if (MapUtils.isNotEmpty(selfDeclaredFields)) { Map<String, String> userInfo = (Map<String, Strin...
### Question: UserExternalIdentityAdapter { public static Map<String, Object> convertExternalFieldsToSelfDeclareFields( List<Map<String, String>> externalIds) { Map<String, Object> selfDeclaredField = new HashMap<>(); if (CollectionUtils.isNotEmpty(externalIds)) { Map<String, String> userInfo = new HashMap<>(); for (Ma...
### Question: UserLookUp { public void checkPhoneUniqueness(String phone, RequestContext context) { if (StringUtils.isNotBlank(phone)) { List<Map<String, Object>> userMapList = getPhoneByType(phone, context); if (CollectionUtils.isNotEmpty(userMapList)) { ProjectCommonException.throwClientErrorException(ResponseCode.Ph...
### Question: UserRequestValidator extends BaseRequestValidator { public void validateUpdateUserRequest(Request userRequest) { if (userRequest.getRequest().containsKey(JsonKey.MANAGED_BY)) { ProjectCommonException.throwClientErrorException(ResponseCode.managedByNotAllowed); } externalIdsValidation(userRequest, JsonKey....
### Question: 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) ...
### Question: UserRequestValidator extends BaseRequestValidator { public void validateVerifyUser(Request userRequest) { if (StringUtils.isBlank((String) userRequest.getRequest().get(JsonKey.LOGIN_ID))) { ProjectCommonException.throwClientErrorException(ResponseCode.loginIdRequired); } } void validateCreateUserRequest(...
### Question: 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 String getFormattedDate(); static boolean isEmailvalid...
### Question: 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|(ex...
### Question: 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() * SALTCHA...
### Question: 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, "")...
### Question: ProjectUtil { public static String formatMessage(String exceptionMsg, Object... fieldValue) { return MessageFormat.format(exceptionMsg, fieldValue); } static String getFormattedDate(); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static Strin...
### Question: ProjectUtil { public static boolean isEmailvalid(final String email) { if (StringUtils.isBlank(email)) { return false; } Matcher matcher = pattern.matcher(email); return matcher.matches(); } static String getFormattedDate(); static boolean isEmailvalid(final String email); static String createAuthToken(S...
### Question: 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(), ...
### Question: 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 { he...
### Question: ProjectUtil { public static void createAndThrowServerError() { throw new ProjectCommonException( ResponseCode.SERVER_ERROR.getErrorCode(), ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode()); } static String getFormattedDate(); static boolean isEmailvalid(final Strin...
### Question: ProjectUtil { public static void createAndThrowInvalidUserDataException() { throw new ProjectCommonException( ResponseCode.invalidUsrData.getErrorCode(), ResponseCode.invalidUsrData.getErrorMessage(), ResponseCode.CLIENT_ERROR.getResponseCode()); } static String getFormattedDate(); static boolean isEmail...
### Question: 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, "");...
### Question: ProjectUtil { public static boolean validateCountryCode(String countryCode) { String pattern = "^(?:[+] ?){0,1}(?:[0-9] ?){1,3}"; try { Pattern patt = Pattern.compile(pattern); Matcher matcher = patt.matcher(countryCode); return matcher.matches(); } catch (RuntimeException e) { return false; } } static S...
### Question: ProjectUtil { public static boolean validateUUID(String uuidStr) { try { UUID.fromString(uuidStr); return true; } catch (Exception ex) { return false; } } static String getFormattedDate(); static boolean isEmailvalid(final String email); static String createAuthToken(String name, String source); static S...
### Question: HttpClientUtil { public static String get(String requestURL, Map<String, String> headers) { CloseableHttpResponse response = null; try { HttpGet httpGet = new HttpGet(requestURL); if (MapUtils.isNotEmpty(headers)) { for (Map.Entry<String, String> entry : headers.entrySet()) { httpGet.addHeader(entry.getKe...
### Question: HttpClientUtil { public static String post(String requestURL, String params, Map<String, String> headers) { CloseableHttpResponse response = null; try { HttpPost httpPost = new HttpPost(requestURL); if (MapUtils.isNotEmpty(headers)) { for (Map.Entry<String, String> entry : headers.entrySet()) { httpPost.a...
### Question: HttpClientUtil { public static String postFormData( String requestURL, Map<String, String> params, Map<String, String> headers) { CloseableHttpResponse response = null; try { HttpPost httpPost = new HttpPost(requestURL); if (MapUtils.isNotEmpty(headers)) { for (Map.Entry<String, String> entry : headers.en...
### Question: HttpClientUtil { public static String patch(String requestURL, String params, Map<String, String> headers) { CloseableHttpResponse response = null; try { HttpPatch httpPatch = new HttpPatch(requestURL); if (MapUtils.isNotEmpty(headers)) { for (Map.Entry<String, String> entry : headers.entrySet()) { httpPa...
### Question: Slug { public static String makeSlug(String input, boolean transliterate) { String origInput = input; String tempInputValue = ""; if (input == null) { ProjectLogger.log("Provided input value is null"); return input; } tempInputValue = input.trim(); tempInputValue = urlDecode(tempInputValue); if (translite...
### Question: Slug { public static String removeDuplicateChars(String text) { Set<Character> set = new LinkedHashSet<>(); StringBuilder ret = new StringBuilder(text.length()); if (text.length() == 0) { return ""; } for (int i = 0; i < text.length(); i++) { set.add(text.charAt(i)); } Iterator<Character> itr = set.iterat...
### Question: LogMaskServiceImpl implements DataMaskingService { public String maskEmail(String email) { if (email.indexOf("@") > 4) { return email.replaceAll("(^[^@]{4}|(?!^)\\G)[^@]", "$1*"); } else { return email.replaceAll("(^[^@]{2}|(?!^)\\G)[^@]", "$1*"); } } String maskEmail(String email); String maskPhone(Stri...
### Question: LogMaskServiceImpl implements DataMaskingService { public String maskPhone(String phone) { return phone.replaceAll("(^[^*]{9}|(?!^)\\G)[^*]", "$1*"); } String maskEmail(String email); String maskPhone(String phone); }### Answer: @Test public void maskPhone() { HashMap<String, String> phoneMaskExpectatio...
### Question: ExcelFileUtil extends FileUtil { @SuppressWarnings({"resource", "unused"}) public File writeToFile(String fileName, List<List<Object>> dataValues) { XSSFWorkbook workbook = new XSSFWorkbook(); XSSFSheet sheet = workbook.createSheet("Data"); FileOutputStream out = null; File file = null; int rownum = 0; fo...
### Question: LocationDaoImpl implements LocationDao { public SearchDTO addSortBy(SearchDTO searchDtO) { if (MapUtils.isNotEmpty(searchDtO.getAdditionalProperties()) && searchDtO.getAdditionalProperties().containsKey(JsonKey.FILTERS) && searchDtO.getAdditionalProperties().get(JsonKey.FILTERS) instanceof Map && ((Map<St...
### Question: SystemSettingDaoImpl implements SystemSettingDao { @Override public Response write(SystemSetting systemSetting, RequestContext context) { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = mapper.convertValue(systemSetting, Map.class); Response response = cassandraOperation.upsertRecord(K...
### Question: SystemSettingDaoImpl implements SystemSettingDao { @Override public SystemSetting readByField(String field, RequestContext context) { Response response = cassandraOperation.getRecordsByIndexedProperty( KEYSPACE_NAME, TABLE_NAME, JsonKey.FIELD, field, context); List<Map<String, Object>> list = (List<Map<St...
### Question: SystemSettingDaoImpl implements SystemSettingDao { public List<SystemSetting> readAll(RequestContext context) { Response response = cassandraOperation.getAllRecords(KEYSPACE_NAME, TABLE_NAME, context); List<Map<String, Object>> list = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE); List<System...
### Question: UserOrgDaoImpl implements UserOrgDao { @Override public Response updateUserOrg(UserOrg userOrg, RequestContext context) { Map<String, Object> compositeKey = new LinkedHashMap<>(2); Map<String, Object> request = mapper.convertValue(userOrg, Map.class); compositeKey.put(JsonKey.USER_ID, request.remove(JsonK...
### Question: UserConsentActor extends BaseActor { private void updateUserConsent(Request request) { Map<String, Object> consent = (Map<String, Object>) request.getRequest().getOrDefault(JsonKey.CONSENT_BODY, new HashMap<String, Object>()); String userId = (String) consent.getOrDefault(JsonKey.USER_ID, ""); if(StringUt...
### Question: OrgExternalService { public String getOrgIdFromOrgExternalIdAndProvider( String externalId, String provider, RequestContext context) { Map<String, Object> dbRequestMap = new HashMap<>(); dbRequestMap.put(JsonKey.EXTERNAL_ID, externalId.toLowerCase()); dbRequestMap.put(JsonKey.PROVIDER, provider.toLowerCas...
### Question: AdminUtilHandler { public static AdminUtilRequestPayload prepareAdminUtilPayload(List<AdminUtilRequestData> reqData){ AdminUtilRequestPayload adminUtilsReq = new AdminUtilRequestPayload(); adminUtilsReq.setId(JsonKey.EKSTEP_SIGNING_SIGN_PAYLOAD); adminUtilsReq.setVer(JsonKey.EKSTEP_SIGNING_SIGN_PAYLOAD_VE...
### Question: AdminUtilHandler { public static Map<String, Object> fetchEncryptedToken(AdminUtilRequestPayload reqObject){ Map<String, Object> data = null; ObjectMapper mapper = new ObjectMapper(); try { String body = mapper.writeValueAsString(reqObject); ProjectLogger.log( "AdminUtilHandler :: fetchEncryptedToken: req...
### Question: UserUtility { public static Map<String, Object> encryptUserData(Map<String, Object> userMap) throws Exception { return encryptSpecificUserData(userMap, userKeyToEncrypt); } private UserUtility(); static Map<String, Object> encryptUserData(Map<String, Object> userMap); @SuppressWarnings("unchecked") stati...
### Question: UserUtility { public static List<Map<String, Object>> encryptUserAddressData( List<Map<String, Object>> addressList) throws Exception { EncryptionService service = ServiceFactory.getEncryptionServiceInstance(null); for (Map<String, Object> map : addressList) { for (String key : addressKeyToEncrypt) { if (...
### Question: UserFlagUtil { public static int getFlagValue(String userFlagType, boolean flagEnabled) { int decimalValue = 0; if (userFlagType.equals(UserFlagEnum.PHONE_VERIFIED.getUserFlagType()) && flagEnabled) { decimalValue = UserFlagEnum.PHONE_VERIFIED.getUserFlagValue(); } else if (userFlagType.equals(UserFlagEnu...
### Question: UserFlagUtil { public static Map<String, Boolean> assignUserFlagValues(int flagsValue) { Map<String, Boolean> userFlagMap = new HashMap<>(); setDefaultValues(userFlagMap); if ((flagsValue & UserFlagEnum.PHONE_VERIFIED.getUserFlagValue()) == UserFlagEnum.PHONE_VERIFIED.getUserFlagValue()) { userFlagMap.put...
### Question: OTPUtil { private static String generateOTP() { String otpSize = ProjectUtil.getConfigValue(JsonKey.SUNBIRD_OTP_LENGTH); int codeDigits = StringUtils.isBlank(otpSize) ? MAXIMUM_OTP_LENGTH : Integer.valueOf(otpSize); GoogleAuthenticatorConfig config = new GoogleAuthenticatorConfig.GoogleAuthenticatorConfig...
### Question: RoleDaoImpl implements RoleDao { @SuppressWarnings("unchecked") @Override public List<Role> getRoles() { Response roleResults = getCassandraOperation().getAllRecords(Util.KEY_SPACE_NAME, TABLE_NAME, null); TypeReference<List<Role>> roleMapType = new TypeReference<List<Role>>() {}; List<Map<String, Object>...
### Question: UserLookUp { public void checkEmailUniqueness(String email, RequestContext context) { if (StringUtils.isNotBlank(email)) { List<Map<String, Object>> userMapList = getEmailByType(email, context); if (CollectionUtils.isNotEmpty(userMapList)) { ProjectCommonException.throwClientErrorException(ResponseCode.em...
### Question: EmailTemplateDaoImpl implements EmailTemplateDao { @Override public String getTemplate(String templateName, RequestContext context) { List<String> idList = new ArrayList<>(); if (StringUtils.isBlank(templateName)) { idList.add(DEFAULT_EMAIL_TEMPLATE_NAME); } else { idList.add(templateName); } Response res...
### Question: EmailTemplateDaoImpl implements EmailTemplateDao { public static EmailTemplateDao getInstance() { if (emailTemplateDao == null) { emailTemplateDao = new EmailTemplateDaoImpl(); } return emailTemplateDao; } static EmailTemplateDao getInstance(); @Override String getTemplate(String templateName, RequestCon...
### Question: OnDemandSchedulerManager extends SchedulerManager { public void triggerScheduler(String[] jobs) { String identifier = "NetOps-PC1502295457753"; for (String job : jobs) { switch (job) { case BULK_UPLOAD: case SHADOW_USER: scheduleOnDemand(identifier, job); break; default: ProjectLogger.log( "OnDemandSchedu...
### Question: UserBulkUploadRequestValidator { public static void validateUserBulkUploadRequest(Map<String, Object> userMap) { validateUserType(userMap); validateOrganisationId(userMap); } private UserBulkUploadRequestValidator(); static void validateUserBulkUploadRequest(Map<String, Object> userMap); static void vali...
### Question: FeedUtil { public static Response saveFeed( ShadowUser shadowUser, List<String> userIds, RequestContext context) { return saveFeed(shadowUser, userIds.get(0), context); } static Response saveFeed( ShadowUser shadowUser, List<String> userIds, RequestContext context); static Response saveFeed(ShadowU...
### Question: FeedServiceImpl implements IFeedService { @Override public Response insert(Feed feed, RequestContext context) { logger.info(context, "FeedServiceImpl:insert method called : "); Map<String, Object> feedData = feed.getData(); Map<String, Object> dbMap = mapper.convertValue(feed, Map.class); String feedId = ...
### Question: FeedServiceImpl implements IFeedService { @Override public Response update(Feed feed, RequestContext context) { logger.info(context, "FeedServiceImpl:update method called : "); Map<String, Object> feedData = feed.getData(); Map<String, Object> dbMap = mapper.convertValue(feed, Map.class); try { if (MapUti...
### Question: FeedServiceImpl implements IFeedService { @Override public void delete(String id, String userId, String category, RequestContext context) { logger.info(context, "FeedServiceImpl:delete method called for feedId : " + id); Map<String, String> compositeKey = new HashMap(); compositeKey.put("userid", userId);...
### Question: FeedServiceImpl implements IFeedService { @Override public List<Feed> getRecordsByUserId(Map<String, Object> properties, RequestContext context) { logger.info(context, "FeedServiceImpl:getRecordsByUserId method called : "); Response dbResponse = getCassandraInstance() .getRecordById( usrFeedDbInfo.getKeyS...
### Question: FeedServiceImpl implements IFeedService { @Override public Response search(SearchDTO searchDTO, RequestContext context) { logger.info(context, "FeedServiceImpl:search method called : "); Future<Map<String, Object>> resultF = getESInstance().search(searchDTO, ProjectUtil.EsType.userfeed.getTypeName(), cont...
### Question: KeyManager { public static PublicKey loadPublicKey(String key) throws Exception { String publicKey = new String(key.getBytes(), StandardCharsets.UTF_8); publicKey = publicKey.replaceAll("(-+BEGIN PUBLIC KEY-+)", ""); publicKey = publicKey.replaceAll("(-+END PUBLIC KEY-+)", ""); publicKey = publicKey.repla...
### Question: KeyManager { public static KeyData getPublicKey(String keyId) { return keyMap.get(keyId); } static void init(); static KeyData getPublicKey(String keyId); static PublicKey loadPublicKey(String key); }### Answer: @Test public void testGetPublicKey() { KeyData key = KeyManager.getPublicKey("keyId"); asser...
### Question: EsClientFactory { private static ElasticSearchService getRestClient() { if (restClient == null) { synchronized (EsClientFactory.class) { if (restClient == null) { restClient = new ElasticSearchRestHighImpl(); } } } return restClient; } static ElasticSearchService getInstance(String type); }### Answer: @...
### Question: EsClientFactory { public static ElasticSearchService getInstance(String type) { if (JsonKey.REST.equals(type)) { return getRestClient(); } else { ProjectLogger.log( "EsClientFactory:getInstance: value for client type provided null ", LoggerEnum.ERROR); } return null; } static ElasticSearchService getInst...
### Question: ElasticSearchRestHighImpl implements ElasticSearchService { @Override public Future<String> save( String index, String identifier, Map<String, Object> data, RequestContext context) { long startTime = System.currentTimeMillis(); Promise<String> promise = Futures.promise(); logger.info( context, "ElasticSea...
### Question: ElasticSearchRestHighImpl implements ElasticSearchService { @Override public Future<Map<String, Object>> getDataByIdentifier( String index, String identifier, RequestContext context) { long startTime = System.currentTimeMillis(); Promise<Map<String, Object>> promise = Futures.promise(); if (StringUtils.is...
### Question: Email { public String getPassword() { return password; } 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<Strin...
### Question: ElasticSearchTcpImpl implements ElasticSearchService { @Override public Future<String> save(String index, String identifier, Map<String, Object> data) { long startTime = System.currentTimeMillis(); Promise<String> promise = Futures.promise(); ProjectLogger.log( "ElasticSearchTcpImpl:save: method started a...
### Question: ElasticSearchTcpImpl implements ElasticSearchService { @Override public Future<Map<String, Object>> getDataByIdentifier(String index, String identifier) { long startTime = System.currentTimeMillis(); Promise<Map<String, Object>> promise = Futures.promise(); ProjectLogger.log( "ElasticSearchTcpImpl:getData...