From 91aae9641e4c0cdb99fdb84a7229e9012a9866df Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 11 Jan 2023 18:31:43 +0530 Subject: [PATCH 01/15] Minor correction to the id prop --- .../main/java/io/mosip/resident/constant/ResidentConstants.java | 2 +- .../main/java/io/mosip/resident/validator/RequestValidator.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java index 39579947b2a..d0e5374bc29 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java @@ -81,7 +81,7 @@ private ResidentConstants() { public static final String AUTHENTICATION_MODE_CLAIM_NAME = "mosip.resident.access_token.auth_mode.claim-name"; - public static final String MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD = "mosip.resident.download.personalized.card"; + public static final String MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD_ID = "mosip.resident.download.personalized.card.id"; public static final String PASSWORD_ATTRIBUTE = "mosip.digitalcard.uincard.password"; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java b/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java index 9305d31af28..ffd6ca9d5e6 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java @@ -1072,7 +1072,7 @@ private void validateIndividualIdV2(String individualId) { public void validateDownloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO) { validateRequestType(downloadPersonalizedCardMainRequestDTO.getId(), - this.environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD), ID); + this.environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD_ID), ID); validateDate(downloadPersonalizedCardMainRequestDTO.getRequesttime()); validateString(downloadPersonalizedCardMainRequestDTO.getRequest().getHtml(), "html"); validateEncodedString(downloadPersonalizedCardMainRequestDTO.getRequest().getHtml()); From 61b0031b95d014106661f4daefd43569fbeee4dc Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 11 Jan 2023 18:34:59 +0530 Subject: [PATCH 02/15] minor refactoring --- .../io/mosip/resident/controller/DownloadCardController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index 18a53bba69a..136e78f99f8 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -107,7 +107,7 @@ public ResponseEntity downloadPersonalizedCard(@Validated @RequestBody M } catch (InvalidInputException e) { throw new ResidentServiceException(e.getErrorCode(), e.getErrorText(), e, Map.of(ResidentConstants.HTTP_STATUS_CODE, HttpStatus.BAD_REQUEST, ResidentConstants.REQ_RES_ID, - environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD))); + environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD_ID))); } Tuple2 tupleResponse = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO); InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(tupleResponse.getT1())); From dda1b456df42f51fa73ef3e6493587f578b43d52 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 11 Jan 2023 18:38:29 +0530 Subject: [PATCH 03/15] Fix missing code in refactoring --- .../main/java/io/mosip/resident/validator/RequestValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java b/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java index 8fd8f3a5080..46eb7636538 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/validator/RequestValidator.java @@ -1072,7 +1072,7 @@ private void validateIndividualIdV2(String individualId) { public void validateDownloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO) { validateRequestType(downloadPersonalizedCardMainRequestDTO.getId(), - this.environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD), ID); + this.environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD_ID), ID); validateVersion(downloadPersonalizedCardMainRequestDTO.getVersion()); validateDate(downloadPersonalizedCardMainRequestDTO.getRequesttime()); validateString(downloadPersonalizedCardMainRequestDTO.getRequest().getHtml(), "html"); From e866dd12cb2bb6814ca251e76b9f2c69857bbe39 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Thu, 12 Jan 2023 19:31:52 +0530 Subject: [PATCH 04/15] Added timezone logger --- resident/resident-service/pom.xml | 21 +++---- .../controller/ResidentController.java | 61 ++++++++++--------- .../controller/ResidentControllerTest.java | 3 +- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/resident/resident-service/pom.xml b/resident/resident-service/pom.xml index 7b77ec2863b..bf38ae52854 100644 --- a/resident/resident-service/pom.xml +++ b/resident/resident-service/pom.xml @@ -59,25 +59,13 @@ io.mosip.kernel kernel-openid-bridge-api ${kernel-openid-bridge-api.version} - provided - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - org.apache.commons - commons-lang3 + io.mosip.kernel + kernel-core - - io.mosip.kernel - kernel-openid-bridge-api - 1.2.1-SNAPSHOT - provided - org.springframework.boot spring-boot-starter-web @@ -103,6 +91,11 @@ json-simple ${googlecode.json-simple.version} + + io.mosip.kernel + kernel-core + ${kernel.core.version} + io.mosip.kernel kernel-logger-logback diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index bec24358698..9f6269db9ae 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -1,6 +1,36 @@ package io.mosip.resident.controller; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; +import java.util.TimeZone; + +import javax.validation.Valid; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.core.io.InputStreamResource; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + import com.fasterxml.jackson.core.type.TypeReference; + import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.http.ResponseFilter; import io.mosip.kernel.core.http.ResponseWrapper; @@ -53,35 +83,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.core.io.InputStreamResource; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; import reactor.util.function.Tuple2; -import javax.validation.Valid; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; - @RestController @Tag(name = "resident-controller", description = "Resident Controller") public class ResidentController { @@ -316,8 +319,10 @@ public ResponseWrapper> getServiceHistory(@Pa @RequestParam(name = "sortType", required = false) String sortType, @RequestParam(name = "serviceType", required = false) String serviceType, @RequestParam(name = "statusFilter", required = false) String statusFilter, - @RequestParam(name = "searchText", required = false) String searchText) + @RequestParam(name = "searchText", required = false) String searchText, + TimeZone timezone) throws ResidentServiceCheckedException, ApisResourceAccessException { + logger.info("TimeZone: " + timezone.getDisplayName() + timezone.getID()); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "getServiceHistory")); validator.validateOnlyLanguageCode(langCode); validator.validateServiceHistoryRequest(fromDate, toDate, sortType, serviceType, statusFilter); diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java index 3744f0a0209..85c16c3f84d 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java @@ -18,6 +18,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.TimeZone; import javax.crypto.SecretKey; @@ -356,7 +357,7 @@ public void testGetServiceHistorySuccess() throws Exception { Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(response); residentController.getServiceHistory("eng", 1, 12, LocalDate.parse("2022-06-10"), LocalDate.parse("2022-06-10"), SortType.ASC.toString(), - ServiceType.AUTHENTICATION_REQUEST.name(), null, null); + ServiceType.AUTHENTICATION_REQUEST.name(), null, null, TimeZone.getDefault()); mockMvc.perform(MockMvcRequestBuilders.get("/service-history/eng").contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()); } From 608982efdc1aee28fd137c6ccef93332c7eec85f Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Thu, 12 Jan 2023 20:21:26 +0530 Subject: [PATCH 05/15] Minor correction --- .../java/io/mosip/resident/controller/ResidentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index 1f7af03d687..fa3d247fa3f 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -328,7 +328,7 @@ public ResponseWrapper> getServiceHistory(@Pa @RequestParam(name = "searchText", required = false) String searchText, TimeZone timezone) throws ResidentServiceCheckedException, ApisResourceAccessException { - logger.info("TimeZone: " + timezone.getDisplayName() + timezone.getID()); + logger.info("TimeZone: " + timezone.getDisplayName() + " : " + timezone.getID()); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "getServiceHistory")); validator.validateOnlyLanguageCode(langCode); validator.validateServiceHistoryRequest(fromDate, toDate, sortType, serviceType, statusFilter); From c0c27dd99ad61e85a8df9cb3cba66b389c8b3328 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Thu, 12 Jan 2023 20:25:24 +0530 Subject: [PATCH 06/15] Pom correction --- resident/resident-service/pom.xml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resident/resident-service/pom.xml b/resident/resident-service/pom.xml index bf38ae52854..a1fcc37a557 100644 --- a/resident/resident-service/pom.xml +++ b/resident/resident-service/pom.xml @@ -66,6 +66,17 @@ + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.apache.commons + commons-lang3 + + + org.springframework.boot spring-boot-starter-web @@ -91,11 +102,6 @@ json-simple ${googlecode.json-simple.version} - - io.mosip.kernel - kernel-core - ${kernel.core.version} - io.mosip.kernel kernel-logger-logback From ba8391cf897cb2846730bb5a172b23c63a13b5a3 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 19:02:51 +0530 Subject: [PATCH 07/15] Added timezone based timestamp responses for related APIs --- .../mosip/resident/constant/RequestType.java | 20 ++--- .../resident/constant/ResidentConstants.java | 6 +- .../controller/AcknowledgementController.java | 6 +- .../controller/DownloadCardController.java | 6 +- .../controller/ResidentController.java | 22 +++--- .../controller/ResidentVidController.java | 5 +- .../service/AcknowledgementService.java | 2 +- .../resident/service/DownloadCardService.java | 2 +- .../resident/service/ResidentService.java | 4 +- .../resident/service/ResidentVidService.java | 4 +- .../impl/AcknowledgementServiceImpl.java | 6 +- .../service/impl/DownloadCardServiceImpl.java | 8 +- .../service/impl/ResidentServiceImpl.java | 24 +++--- .../service/impl/ResidentVidServiceImpl.java | 17 +++-- .../io/mosip/resident/util/TemplateUtil.java | 73 +++++++++---------- .../java/io/mosip/resident/util/Utilitiy.java | 11 ++- .../AcknowledgmentControllerTest.java | 4 +- .../DownloadCardControllerTest.java | 2 +- .../controller/ResidentControllerTest.java | 6 +- .../service/AcknowledgmentServiceTest.java | 34 ++++----- .../test/service/DownloadCardServiceTest.java | 14 ++-- .../ResidentServiceGetEventStatusTest.java | 22 +++--- .../ResidentServiceGetServiceHistoryTest.java | 50 ++++++------- .../resident/test/util/TemplateUtilTest.java | 36 ++++----- 24 files changed, 201 insertions(+), 183 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/constant/RequestType.java b/resident/resident-service/src/main/java/io/mosip/resident/constant/RequestType.java index 170b31a2dbe..0792ce9201b 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/constant/RequestType.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/constant/RequestType.java @@ -1,15 +1,17 @@ package io.mosip.resident.constant; -import io.mosip.resident.dto.NotificationTemplateVariableDTO; -import io.mosip.resident.util.TemplateUtil; -import org.apache.commons.lang3.function.TriFunction; -import reactor.util.function.Tuple2; - import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.BiFunction; +import org.apache.commons.lang3.function.TriFunction; + +import io.mosip.resident.dto.NotificationTemplateVariableDTO; +import io.mosip.resident.function.QuadFunction; +import io.mosip.resident.util.TemplateUtil; +import reactor.util.function.Tuple2; + /** * The Enum RequestType. * @@ -73,7 +75,7 @@ public enum RequestType { DEFAULT("Default", TemplateUtil::getDefaultTemplateVariables, List.of(), List.of(), List.of(), "", TemplateUtil::getNotificationCommonTemplateVariables, null); - private TriFunction, String>> ackTemplateVariablesFunction; + private QuadFunction, String>> ackTemplateVariablesFunction; private List successStatusList; private List failureStatusList; private List inProgressStatusList; @@ -83,7 +85,7 @@ public enum RequestType { private String name; - private RequestType(String name, TriFunction, String>> ackTemplateVariablesFunction, + private RequestType(String name, QuadFunction, String>> ackTemplateVariablesFunction, List successStatusList, List failureStatusList, List inProgressStatusList, String featureName, BiFunction> notificationTemplateVariablesFunction, @@ -149,8 +151,8 @@ public String getSummaryTemplateCodeProperty(TemplateType templateType) { return "resident.template.summary." + templateType.getType() + "." + getFeatureName(); } - public Tuple2, String> getAckTemplateVariables(TemplateUtil templateUtil, String eventId, String languageCode) { - return ackTemplateVariablesFunction.apply(templateUtil, eventId, languageCode); + public Tuple2, String> getAckTemplateVariables(TemplateUtil templateUtil, String eventId, String languageCode, Integer timeZoneOffset) { + return ackTemplateVariablesFunction.apply(templateUtil, eventId, languageCode, timeZoneOffset); } public Map getNotificationTemplateVariables(TemplateUtil templateUtil, NotificationTemplateVariableDTO dto) { diff --git a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java index 37f90a96371..de21c89486e 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java @@ -8,7 +8,8 @@ */ public class ResidentConstants { - private ResidentConstants() { + public static final int UTC_TIMEZONE_OFFSET = 0; + private ResidentConstants() { } public static final String OBJECT_STORE_ACCOUNT_NAME = "mosip.resident.object.store.account-name"; @@ -178,7 +179,8 @@ private ResidentConstants() { public static final String ACTION_PERFORMED = "actionPerformed"; public static final String VID_TYPE = "vidType"; public static final String MASKED_VID = "*masked VID*"; - public static final String ACK_DATE_TIME_PATTERN = "resident.ack.datetime.pattern"; + public static final String UI_DATE_TIME_PATTERN = "resident.ui.datetime.pattern"; + public static final String FILENAME_DATETIME_PATTERN = "resident.filename.datetime.pattern"; public static final String NO_ID = "NO_ID"; public static final String NO_ID_TYPE = "NO_ID_TYPE"; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java index e6ff84940eb..88d1006aaa6 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java @@ -22,6 +22,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import java.io.ByteArrayInputStream; @@ -61,14 +62,15 @@ public class AcknowledgementController { @GetMapping("/ack/download/pdf/event/{eventId}/language/{languageCode}") public ResponseEntity getAcknowledgement(@PathVariable("eventId") String eventId, - @PathVariable("languageCode") String languageCode) throws ResidentServiceCheckedException, IOException { + @PathVariable("languageCode") String languageCode, + @RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceCheckedException, IOException { logger.debug("AcknowledgementController::acknowledgement()::entry"); InputStreamResource resource = null; String featureName = null; try { auditUtil.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.GET_ACKNOWLEDGEMENT_DOWNLOAD_URL, "acknowledgement")); requestValidator.validateEventIdLanguageCode(eventId, languageCode); - byte[] pdfBytes = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] pdfBytes = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, timeZoneOffset); resource = new InputStreamResource(new ByteArrayInputStream(pdfBytes)); auditUtil.setAuditRequestDto(EventEnum.GET_ACKNOWLEDGEMENT_DOWNLOAD_URL_SUCCESS); logger.debug("AcknowledgementController::acknowledgement()::exit"); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index 2742142fd02..ea60ac682fc 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import java.io.ByteArrayInputStream; @@ -125,9 +126,10 @@ public ResponseEntity downloadPersonalizedCard(@Validated @RequestBody M } @GetMapping("/request-card/vid/{VID}") - public ResponseEntity requestVidCard(@PathVariable("VID") String vid) throws BaseCheckedException { + public ResponseEntity requestVidCard(@PathVariable("VID") String vid, + @RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws BaseCheckedException { requestValidator.validateDownloadCardVid(vid); - Tuple2, String> tupleResponse = downloadCardService.getVidCardEventId(vid); + Tuple2, String> tupleResponse = downloadCardService.getVidCardEventId(vid, timeZoneOffset); return ResponseEntity.ok() .header(ResidentConstants.EVENT_ID, tupleResponse.getT2()) .body(tupleResponse.getT1()); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index 1d70f65ad6c..d4297cde136 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -5,6 +5,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.TimeZone; @@ -12,6 +13,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Required; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.core.io.InputStreamResource; @@ -26,6 +28,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -84,7 +87,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import reactor.util.function.Tuple2; -import java.util.Map; @RestController @Tag(name = "resident-controller", description = "Resident Controller") @@ -300,12 +302,13 @@ public ResponseWrapper reqAuthHistory( @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) public ResponseWrapper checkAidStatus(@PathVariable(name = "event-id") String eventId, - @RequestParam(name = "langCode") String languageCode) throws ResidentServiceCheckedException { + @RequestParam(name = "langCode") String languageCode, + @RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceCheckedException { audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "checkAidStatus")); logger.debug("checkAidStatus controller entry"); validator.validateEventIdLanguageCode(eventId, languageCode); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.CHECK_AID_STATUS_REQUEST, eventId)); - ResponseWrapper responseWrapper = residentService.getEventStatus(eventId, languageCode); + ResponseWrapper responseWrapper = residentService.getEventStatus(eventId, languageCode, timeZoneOffset); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.CHECK_AID_STATUS_REQUEST_SUCCESS, eventId)); return responseWrapper; } @@ -327,17 +330,17 @@ public ResponseWrapper> getServiceHistory(@Pa @RequestParam(name = "serviceType", required = false) String serviceType, @RequestParam(name = "statusFilter", required = false) String statusFilter, @RequestParam(name = "searchText", required = false) String searchText, - TimeZone timezone) + @RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { - logger.info("TimeZone: " + timezone.getDisplayName() + " : " + timezone.getID()); + logger.info("TimeZone-offset: " + timeZoneOffset); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.VALIDATE_REQUEST, "getServiceHistory")); validator.validateOnlyLanguageCode(langCode); validator.validateServiceHistoryRequest(fromDate, toDate, sortType, serviceType, statusFilter); audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.GET_SERVICE_HISTORY, "getServiceHistory")); ResponseWrapper> responseWrapper = residentService.getServiceHistory( - pageStart, pageFetch, fromDate, toDate, serviceType, sortType, statusFilter, searchText, langCode); + pageStart, pageFetch, fromDate, toDate, serviceType, sortType, statusFilter, searchText, langCode, timeZoneOffset); return responseWrapper; - } + } @Deprecated @ResponseFilter @@ -597,14 +600,15 @@ public ResponseEntity downLoadServiceHistory( @RequestParam(name = "serviceType", required = false) String serviceType, @RequestParam(name = "statusFilter", required = false) String statusFilter, @RequestParam(name = "searchText", required = false) String searchText, - @RequestParam(name = "languageCode", required = false) String languageCode) + @RequestParam(name = "languageCode", required = false) String languageCode, + @RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException, IOException { logger.debug("ResidentController::serviceHistory::pdf"); audit.setAuditRequestDto( EventEnum.getEventEnumWithValue(EventEnum.DOWNLOAD_SERVICE_HISTORY, "acknowledgement")); validator.validateOnlyLanguageCode(languageCode); ResponseWrapper> responseWrapper = residentService.getServiceHistory( - pageStart, pageFetch, fromDate, toDate, serviceType, sortType, statusFilter, searchText, languageCode); + pageStart, pageFetch, fromDate, toDate, serviceType, sortType, statusFilter, searchText, languageCode, timeZoneOffset); logger.debug("after response wrapper size of " + responseWrapper.getResponse().getData().size()); byte[] pdfBytes = residentService.downLoadServiceHistory(responseWrapper, languageCode, eventReqDateTime, fromDate, toDate, serviceType, statusFilter); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentVidController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentVidController.java index 9220c14fead..dfae6e1172f 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentVidController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentVidController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RestController; import io.mosip.kernel.core.exception.ServiceError; @@ -264,11 +265,11 @@ private String getResidentIndividualId() throws ApisResourceAccessException { @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) - public ResponseWrapper retrieveVids() throws ResidentServiceException, ApisResourceAccessException, ResidentServiceCheckedException { + public ResponseWrapper retrieveVids(@RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceException, ApisResourceAccessException, ResidentServiceCheckedException { logger.debug("ResidentVidController::retrieveVids()::entry"); auditUtil.setAuditRequestDto(EventEnum.GET_VIDS); String residentIndividualId = getResidentIndividualId(); - ResponseWrapper>> retrieveVids = residentVidService.retrieveVids(residentIndividualId); + ResponseWrapper>> retrieveVids = residentVidService.retrieveVids(residentIndividualId, timeZoneOffset); auditUtil.setAuditRequestDto(EventEnum.GET_VIDS_SUCCESS); logger.debug("ResidentVidController::retrieveVids()::exit"); return retrieveVids; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/AcknowledgementService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/AcknowledgementService.java index 16e6c475dab..2c5bdbdf15c 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/AcknowledgementService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/AcknowledgementService.java @@ -9,5 +9,5 @@ * @Author Kamesh Shekhar Prasad */ public interface AcknowledgementService { - byte[] getAcknowledgementPDF(String eventId, String languageCode) throws ResidentServiceCheckedException, IOException; + byte[] getAcknowledgementPDF(String eventId, String languageCode, int timeZoneOffset) throws ResidentServiceCheckedException, IOException; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java index c26e20f0b32..d8c3358a585 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java @@ -22,7 +22,7 @@ public interface DownloadCardService { Tuple2 downloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO); - Tuple2, String> getVidCardEventId(String vid) throws BaseCheckedException; + Tuple2, String> getVidCardEventId(String vid, int timeZoneOffset) throws BaseCheckedException; ResponseWrapper getIndividualIdStatus(String vid) throws ApisResourceAccessException, IOException; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java index f0a2ee02a0e..4e2e65187e6 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java @@ -63,7 +63,7 @@ AidStatusResponseDTO getAidStatus(AidStatusRequestDTO reqDto) ResponseWrapper> getServiceHistory(Integer pageStart, Integer pageFetch, LocalDate fromDateTime, LocalDate toDateTime, String serviceType, String sortType, - String searchColumn, String searchText, String langCode) throws ResidentServiceCheckedException, ApisResourceAccessException; + String searchColumn, String searchText, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException; byte[] downloadCard(String individualId, String idType) throws ResidentServiceCheckedException; @@ -73,7 +73,7 @@ AidStatusResponseDTO getAidStatus(AidStatusRequestDTO reqDto, boolean performOtp String checkAidStatus(String aid) throws ResidentServiceCheckedException; - ResponseWrapper getEventStatus(String id, String eventId) + ResponseWrapper getEventStatus(String id, String eventId, int timeZoneOffset) throws ResidentServiceCheckedException; ResponseWrapper getnotificationCount(String Id); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentVidService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentVidService.java index e4c2563d90d..49b536f1dd0 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentVidService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentVidService.java @@ -25,7 +25,7 @@ public interface ResidentVidService { public String getVidPolicy() throws ResidentServiceCheckedException; - public ResponseWrapper>> retrieveVids(String residentIndividualId) throws ResidentServiceCheckedException, ApisResourceAccessException; + public ResponseWrapper>> retrieveVids(String residentIndividualId, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException; public Optional getPerpatualVid(String uin) throws ResidentServiceCheckedException, ApisResourceAccessException; @@ -36,7 +36,7 @@ public Tuple2, String> revokeVidV2(BaseVid String vid, String indivudalId) throws OtpValidationFailedException, ResidentServiceCheckedException, ApisResourceAccessException; - ResponseWrapper>> retrieveVidsfromUin(String uin) + ResponseWrapper>> retrieveVidsfromUin(String uin, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java index d71bc6bbafd..a50ca6cadb0 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java @@ -63,7 +63,7 @@ public void idTemplateManagerPostConstruct() { private Utilitiy utilitiy; @Override - public byte[] getAcknowledgementPDF(String eventId, String languageCode) throws ResidentServiceCheckedException, IOException { + public byte[] getAcknowledgementPDF(String eventId, String languageCode, int timeZoneOffset) throws ResidentServiceCheckedException, IOException { logger.debug("AcknowledgementServiceImpl::getAcknowledgementPDF()::entry"); Optional residentTransactionEntity = residentTransactionRepository @@ -74,13 +74,13 @@ public byte[] getAcknowledgementPDF(String eventId, String languageCode) throws } else { throw new ResidentServiceCheckedException(ResidentErrorCode.EVENT_STATUS_NOT_FOUND); } - String requestProperty = RequestType.valueOf(requestTypeCode).getAckTemplateVariables(templateUtil, eventId, languageCode).getT2(); + String requestProperty = RequestType.valueOf(requestTypeCode).getAckTemplateVariables(templateUtil, eventId, languageCode, timeZoneOffset).getT2(); ResponseWrapper responseWrapper = proxyMasterdataServiceImpl. getAllTemplateBylangCodeAndTemplateTypeCode(languageCode, requestProperty); Map templateResponse = new LinkedHashMap<>((Map) responseWrapper.getResponse()); String fileText = (String) templateResponse.get(ResidentConstants.FILE_TEXT); Map templateVariables = RequestType.valueOf(requestTypeCode) - .getAckTemplateVariables(templateUtil, eventId, languageCode).getT1(); + .getAckTemplateVariables(templateUtil, eventId, languageCode, timeZoneOffset).getT1(); InputStream stream = new ByteArrayInputStream(fileText.getBytes(StandardCharsets.UTF_8)); InputStream templateValue = templateManager.merge(stream, convertMapValueFromStringToObject(templateVariables)); logger.debug("AcknowledgementServiceImpl::getAcknowledgementPDF()::exit"); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java index 692133c7036..03e77cc9773 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java @@ -319,7 +319,7 @@ private List getAttributeList(String individualId) throws IOException, A } @Override - public Tuple2, String> getVidCardEventId(String vid) throws BaseCheckedException { + public Tuple2, String> getVidCardEventId(String vid, int timeZoneOffset) throws BaseCheckedException { ResponseWrapper responseWrapper= new ResponseWrapper<>(); VidDownloadCardResponseDto vidDownloadCardResponseDto = new VidDownloadCardResponseDto(); String eventId = ResidentConstants.NOT_AVAILABLE; @@ -344,7 +344,7 @@ public Tuple2, String> getVidCardEve credentialReqestDto.setIssuer(environment.getProperty(ResidentConstants.CREDENTIAL_ISSUER)); credentialReqestDto.setEncrypt(Boolean.parseBoolean(environment.getProperty(ResidentConstants.CREDENTIAL_ENCRYPTION_FLAG))); credentialReqestDto.setEncryptionKey(environment.getProperty(ResidentConstants.CREDENTIAL_ENCRYPTION_KEY)); - Map additionalAttributes = getVidDetails(vid, uinForVid); + Map additionalAttributes = getVidDetails(vid, uinForVid, timeZoneOffset); credentialReqestDto.setAdditionalData(additionalAttributes); requestDto.setId(this.environment.getProperty(ResidentConstants.CREDENTIAL_REQUEST_SERVICE_ID)); requestDto.setRequest(credentialReqestDto); @@ -420,12 +420,12 @@ private ResidentTransactionEntity insertDataForVidCard(String vid, String uin) t return residentTransactionEntity; } - private Map getVidDetails(String vid, String uin) throws ResidentServiceCheckedException, ApisResourceAccessException, IOException { + private Map getVidDetails(String vid, String uin, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException, IOException { Map additionalAttributes = new HashMap<>(); String name=null; ResponseWrapper>> vidResponse = null; if(uin!=null){ - vidResponse =vidService.retrieveVids(uin); + vidResponse =vidService.retrieveVids(uin, timeZoneOffset); name = getFullName(uin); } if (vidResponse!=null){ diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java index f3200d021ae..cc7704c3493 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java @@ -221,7 +221,7 @@ public class ResidentServiceImpl implements ResidentService { private TemplateUtil templateUtil; @Autowired - private Utilitiy utility; + public Utilitiy utility; @Autowired private Utilities utilities; @@ -1530,7 +1530,7 @@ public ResponseWrapper getAuthLockStatus(String in @Override public ResponseWrapper> getServiceHistory(Integer pageStart, Integer pageFetch, LocalDate fromDateTime, LocalDate toDateTime, String serviceType, String sortType, - String statusFilter, String searchText, String langCode) + String statusFilter, String searchText, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { if (pageStart == null) { @@ -1558,7 +1558,7 @@ public ResponseWrapper> getServiceHistory(Int ResponseWrapper> serviceHistoryResponseDtoList = getServiceHistoryDetails( sortType, pageStart, pageFetch, fromDateTime, toDateTime, serviceType, statusFilter, searchText, - langCode); + langCode, timeZoneOffset); return serviceHistoryResponseDtoList; } @@ -1666,12 +1666,12 @@ private DigitalCardStatusResponseDto getDigitalCardStatus(String individualId) private ResponseWrapper> getServiceHistoryDetails(String sortType, Integer pageStart, Integer pageFetch, LocalDate fromDateTime, LocalDate toDateTime, - String serviceType, String statusFilter, String searchText, String langCode) + String serviceType, String statusFilter, String searchText, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { ResponseWrapper> responseWrapper = new ResponseWrapper<>(); String idaToken = identityServiceImpl.getResidentIdaToken(); responseWrapper.setResponse(getServiceHistoryResponse(sortType, pageStart, pageFetch, idaToken, statusFilter, - searchText, fromDateTime, toDateTime, serviceType, langCode)); + searchText, fromDateTime, toDateTime, serviceType, langCode, timeZoneOffset)); responseWrapper.setId(serviceHistoryId); responseWrapper.setVersion(serviceHistoryVersion); responseWrapper.setResponsetime(LocalDateTime.now()); @@ -1681,7 +1681,7 @@ private ResponseWrapper> getServiceHistoryDet public PageDto getServiceHistoryResponse(String sortType, Integer pageStart, Integer pageFetch, String idaToken, String statusFilter, String searchText, LocalDate fromDateTime, - LocalDate toDateTime, String serviceType, String langCode) + LocalDate toDateTime, String serviceType, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException { String nativeQueryString = getDynamicNativeQueryString(sortType, idaToken, pageStart, pageFetch, statusFilter, searchText, fromDateTime, toDateTime, serviceType); @@ -1695,7 +1695,7 @@ public PageDto getServiceHistoryResponse(String sortT BigInteger count = (BigInteger) nativeQuery2.getSingleResult(); int size = count.intValue(); return new PageDto<>(pageStart, pageFetch, size, (size / pageFetch) + 1, - convertResidentEntityListToServiceHistoryDto(residentTransactionEntityList, langCode)); + convertResidentEntityListToServiceHistoryDto(residentTransactionEntityList, langCode, timeZoneOffset)); } public String getDynamicNativeQueryString(String sortType, String idaToken, Integer pageStart, Integer pageFetch, @@ -1835,7 +1835,7 @@ private Collection convertListOfRequestTypeToListOfString(List convertResidentEntityListToServiceHistoryDto( - List residentTransactionEntityList, String langCode) + List residentTransactionEntityList, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException { List serviceHistoryResponseDtoList = new ArrayList<>(); for (ResidentTransactionEntity residentTransactionEntity : residentTransactionEntityList) { @@ -1849,9 +1849,9 @@ private List convertResidentEntityListToServiceHistor serviceHistoryResponseDto.setEventStatus(statusCode); if (residentTransactionEntity.getUpdDtimes() != null && residentTransactionEntity.getUpdDtimes().isAfter(residentTransactionEntity.getCrDtimes())) { - serviceHistoryResponseDto.setTimeStamp(residentTransactionEntity.getUpdDtimes().toString()); + serviceHistoryResponseDto.setTimeStamp(utility.formatWithOffsetForUI(timeZoneOffset, residentTransactionEntity.getUpdDtimes())); } else { - serviceHistoryResponseDto.setTimeStamp(residentTransactionEntity.getCrDtimes().toString()); + serviceHistoryResponseDto.setTimeStamp(utility.formatWithOffsetForUI(timeZoneOffset, residentTransactionEntity.getCrDtimes())); } if (serviceType.isPresent()) { if (!serviceType.get().equals(ServiceType.ALL.name())) { @@ -1980,7 +1980,7 @@ public String checkAidStatus(String aid) throws ResidentServiceCheckedException } @Override - public ResponseWrapper getEventStatus(String eventId, String languageCode) + public ResponseWrapper getEventStatus(String eventId, String languageCode, int timeZoneOffset) throws ResidentServiceCheckedException { logger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), "ResidentServiceImpl::getEventStatus()::Start"); @@ -2005,7 +2005,7 @@ public ResponseWrapper getEventStatus(String eventId, St Optional serviceType = ServiceType.getServiceTypeFromRequestType(requestType); Map eventStatusMap; - eventStatusMap = requestType.getAckTemplateVariables(templateUtil, eventId, languageCode).getT1(); + eventStatusMap = requestType.getAckTemplateVariables(templateUtil, eventId, languageCode, timeZoneOffset).getT1(); EventStatusResponseDTO eventStatusResponseDTO = new EventStatusResponseDTO(); eventStatusResponseDTO.setEventId(eventId); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java index eae4f6eee1d..22c24bb0201 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java @@ -75,6 +75,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.TimeZone; import java.util.stream.Collectors; @Component @@ -625,7 +626,7 @@ private ResidentTransactionEntity createResidentTransEntity(String vid, String i } private String getVidTypeFromVid(String vid, String indivudalId) throws ResidentServiceCheckedException, ApisResourceAccessException { - ResponseWrapper>> vids = retrieveVids(indivudalId); + ResponseWrapper>> vids = retrieveVids(indivudalId, ResidentConstants.UTC_TIMEZONE_OFFSET); return vids.getResponse().stream() .filter(map -> ((String)map.get(TemplateVariablesConstants.VID)).equals(vid)) .map(map -> (String)map.get(TemplateVariablesConstants.VID_TYPE)) @@ -703,14 +704,14 @@ public String getVidPolicy() throws ResidentServiceCheckedException { } @Override - public ResponseWrapper>> retrieveVids(String residentIndividualId) throws ResidentServiceCheckedException, ApisResourceAccessException { + public ResponseWrapper>> retrieveVids(String residentIndividualId, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { IdentityDTO identityDTO = identityServiceImpl.getIdentity(residentIndividualId); String uin = identityDTO.getUIN(); - return retrieveVidsfromUin(uin); + return retrieveVidsfromUin(uin, timeZoneOffset); } @Override - public ResponseWrapper>> retrieveVidsfromUin(String uin) throws ResidentServiceCheckedException, ApisResourceAccessException { + public ResponseWrapper>> retrieveVidsfromUin(String uin, int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { ResponseWrapper response; try { response = (ResponseWrapper) residentServiceRestClient.getApi( @@ -727,7 +728,7 @@ public ResponseWrapper>> retrieveVidsfromUin(String uin) thro LinkedHashMap lhm = new LinkedHashMap(map); getMaskedVid(lhm); getRefIdHash(lhm); - normalizeExpiryTime(lhm); + normalizeExpiryTime(lhm, timeZoneOffset); return lhm; }) .collect(Collectors.toList()); @@ -740,7 +741,7 @@ public ResponseWrapper>> retrieveVidsfromUin(String uin) thro } - private void normalizeExpiryTime(LinkedHashMap lhm) { + private void normalizeExpiryTime(LinkedHashMap lhm, int timeZoneOffset) { Object expiryTimeObj = lhm.get(EXPIRY_TIMESTAMP); if(expiryTimeObj instanceof String) { String expiryTime = String.valueOf(expiryTimeObj); @@ -748,6 +749,8 @@ private void normalizeExpiryTime(LinkedHashMap lhm) { //For the big expiry time, assume no expiry time, so set to null if(expiryLocalDateTime.getYear() >= 9999) { lhm.put(EXPIRY_TIMESTAMP, null); + } else { + lhm.put(EXPIRY_TIMESTAMP, utility.formatWithOffsetForUI(timeZoneOffset, expiryLocalDateTime)) ; } } } @@ -781,7 +784,7 @@ private Map getRefIdHash(Map map) { } public Optional getPerpatualVid(String uin) throws ResidentServiceCheckedException, ApisResourceAccessException { - ResponseWrapper>> vidResp = retrieveVidsfromUin(uin); + ResponseWrapper>> vidResp = retrieveVidsfromUin(uin, ResidentConstants.UTC_TIMEZONE_OFFSET); List> vids = vidResp.getResponse(); if(vids != null && !vids.isEmpty()) { return vids.stream() diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java index 693b0745c28..7f8d613abd3 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java @@ -31,8 +31,6 @@ import reactor.util.function.Tuples; import java.io.IOException; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -66,8 +64,7 @@ public class TemplateUtil { @Autowired private ResidentServiceImpl residentService; - @Autowired - private Environment env; + @Autowired Environment env; @Autowired private ResidentCredentialServiceImpl residentCredentialServiceImpl; @@ -87,7 +84,7 @@ public class TemplateUtil { * @return the ack template variables for authentication request */ - public Map getCommonTemplateVariables(String eventId, String languageCode) { + public Map getCommonTemplateVariables(String eventId, String languageCode, Integer timeZoneOffset) { Map templateVariables = new HashMap<>(); templateVariables.put(TemplateVariablesConstants.EVENT_ID, eventId); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); @@ -98,7 +95,7 @@ public Map getCommonTemplateVariables(String eventId, String lan templateVariables.put(TemplateVariablesConstants.SUMMARY, replaceNullWithEmptyString( residentTransactionEntity.getRequestSummary())); templateVariables.put(TemplateVariablesConstants.TIMESTAMP, - truncateMilliSecondInTimeStampString(residentTransactionEntity.getCrDtimes())); + utilitiy.formatWithOffsetForUI(timeZoneOffset, residentTransactionEntity.getCrDtimes())); templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_REQUEST_LINK, utilitiy.createTrackServiceRequestLink(eventId)); templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_LINK, utilitiy.createTrackServiceRequestLink(eventId)); templateVariables.put(TemplateVariablesConstants.PURPOSE, residentTransactionEntity.getPurpose()); @@ -115,10 +112,6 @@ public Map getCommonTemplateVariables(String eventId, String lan return templateVariables; } - private String truncateMilliSecondInTimeStampString(LocalDateTime localDateTime) { - return localDateTime.format( - DateTimeFormatter.ofPattern(Objects.requireNonNull(this.env.getProperty(ResidentConstants.ACK_DATE_TIME_PATTERN)))); - } public String getDescriptionTemplateVariablesForAuthenticationRequest(String eventId, String fileText){ return fileText; } @@ -182,8 +175,8 @@ public String getDescriptionTemplateVariablesForSecureMyId(String eventId, Strin return fileText; } - public Tuple2, String> getDefaultTemplateVariables(String eventId, String languageCode){ - return Tuples.of(getCommonTemplateVariables(eventId, languageCode), ""); + public Tuple2, String> getDefaultTemplateVariables(String eventId, String languageCode, Integer timeZoneOffset){ + return Tuples.of(getCommonTemplateVariables(eventId, languageCode, timeZoneOffset), ""); } public String replaceNullWithEmptyString(String input) { @@ -201,7 +194,7 @@ private ResidentTransactionEntity getEntityFromEventId(String eventId) { } public String getFeatureName(String eventId){ - Map templateVariables = getCommonTemplateVariables(eventId, null); + Map templateVariables = getCommonTemplateVariables(eventId, null, ResidentConstants.UTC_TIMEZONE_OFFSET); return templateVariables.get(TemplateVariablesConstants.EVENT_TYPE); } @@ -222,8 +215,8 @@ private String getEventStatusForRequestType(String requestType) { return eventStatus; } - public Tuple2, String> getAckTemplateVariablesForCredentialShare(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForCredentialShare(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); templateVariables.put(TemplateVariablesConstants.PARTNER_NAME, residentTransactionEntity.getRequestedEntityName()); templateVariables.put(TemplateVariablesConstants.PARTNER_LOGO, getPartnerLogo(residentTransactionEntity.getRequestedEntityId())); @@ -231,8 +224,8 @@ public Tuple2, String> getAckTemplateVariablesForCredentialS this.env.getProperty(ResidentConstants.ACK_SHARE_CREDENTIAL_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForAuthenticationRequest(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForAuthenticationRequest(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); templateVariables.put(TemplateVariablesConstants.PARTNER_NAME, residentTransactionEntity.getRequestedEntityName()); templateVariables.put(TemplateVariablesConstants.PARTNER_LOGO, getPartnerLogo(residentTransactionEntity.getRequestedEntityId())); @@ -240,16 +233,16 @@ public Tuple2, String> getAckTemplateVariablesForAuthenticat this.env.getProperty(ResidentConstants.ACK_AUTHENTICATION_REQUEST_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForDownloadPersonalizedCard(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForDownloadPersonalizedCard(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( getEntityFromEventId(eventId), languageCode)); return Tuples.of(templateVariables, Objects.requireNonNull( this.env.getProperty(ResidentConstants.ACK_DOWNLOAD_PERSONALIZED_CARD_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForOrderPhysicalCard(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForOrderPhysicalCard(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( residentTransactionEntity, languageCode)); @@ -263,8 +256,8 @@ public Tuple2, String> getAckTemplateVariablesForOrderPhysi this.env.getProperty(ResidentConstants.ACK_ORDER_PHYSICAL_CARD_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForGetMyId(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForGetMyId(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( getEntityFromEventId(eventId), languageCode)); templateVariables.remove(TemplateVariablesConstants.ATTRIBUTE_LIST); @@ -272,20 +265,20 @@ public Tuple2, String> getAckTemplateVariablesForGetMyId(Str this.env.getProperty(ResidentConstants.ACK_GET_MY_ID_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForBookAnAppointment(String eventId, String languageCode) { + public Tuple2, String> getAckTemplateVariablesForBookAnAppointment(String eventId, String languageCode, Integer timeZoneOffset) { return Tuples.of(Collections.emptyMap(), ""); } - public Tuple2, String> getAckTemplateVariablesForUpdateMyUin(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForUpdateMyUin(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( getEntityFromEventId(eventId), languageCode)); return Tuples.of(templateVariables, Objects.requireNonNull( this.env.getProperty(ResidentConstants.ACK_UPDATE_MY_UIN_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForGenerateVid(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForGenerateVid(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( residentTransactionEntity, languageCode)); @@ -308,8 +301,8 @@ public String getPurposeFromResidentTransactionEntityLangCode(ResidentTransactio return purpose; } - public Tuple2, String> getAckTemplateVariablesForRevokeVid(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForRevokeVid(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); ResidentTransactionEntity residentTransactionEntity = getEntityFromEventId(eventId); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( residentTransactionEntity, languageCode)); @@ -319,20 +312,20 @@ public Tuple2, String> getAckTemplateVariablesForRevokeVid(S this.env.getProperty(ResidentConstants.ACK_MANAGE_MY_VID_TEMPLATE_PROPERTY))); } - public Map getAckTemplateVariablesForVerifyPhoneEmail(String eventId) { - return getCommonTemplateVariables(eventId, ""); + public Map getAckTemplateVariablesForVerifyPhoneEmail(String eventId, Integer timeZoneOffset) { + return getCommonTemplateVariables(eventId, "", timeZoneOffset); } - public Tuple2, String> getAckTemplateVariablesForAuthTypeLockUnlock(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForAuthTypeLockUnlock(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.remove(TemplateVariablesConstants.ATTRIBUTE_LIST); templateVariables.put(ResidentConstants.AUTH_TYPES, templateVariables.get(TemplateVariablesConstants.PURPOSE)); return Tuples.of(templateVariables, Objects.requireNonNull( this.env.getProperty(ResidentConstants.ACK_AUTH_TYPE_LOCK_UNLOCK_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForVidCardDownload(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForVidCardDownload(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.put(TemplateVariablesConstants.PURPOSE, getPurposeFromResidentTransactionEntityLangCode( getEntityFromEventId(eventId), languageCode)); templateVariables.remove(TemplateVariablesConstants.ATTRIBUTE_LIST); @@ -340,12 +333,12 @@ public Tuple2, String> getAckTemplateVariablesForVidCardDow this.env.getProperty(ResidentConstants.ACK_VID_CARD_DOWNLOAD_TEMPLATE_PROPERTY))); } - public Tuple2, String> getAckTemplateVariablesForSendOtp(String eventId, String languageCode) { - return Tuples.of(getCommonTemplateVariables(eventId, languageCode), ""); + public Tuple2, String> getAckTemplateVariablesForSendOtp(String eventId, String languageCode, Integer timeZoneOffset) { + return Tuples.of(getCommonTemplateVariables(eventId, languageCode, timeZoneOffset), ""); } - public Tuple2, String> getAckTemplateVariablesForValidateOtp(String eventId, String languageCode) { - Map templateVariables = getCommonTemplateVariables(eventId, languageCode); + public Tuple2, String> getAckTemplateVariablesForValidateOtp(String eventId, String languageCode, Integer timeZoneOffset) { + Map templateVariables = getCommonTemplateVariables(eventId, languageCode, timeZoneOffset); templateVariables.put(ResidentConstants.CHANNEL, replaceNullWithEmptyString( getEntityFromEventId(eventId).getAttributeList())); return Tuples.of(templateVariables, Objects.requireNonNull( diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java index 38b52d07d11..5cf45a8f436 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java @@ -457,11 +457,11 @@ public byte[] signPdf(InputStream in, String password) { } public String getFileName(String eventId, String propertyName){ - String dateTimePattern = this.env.getProperty(DATETIME_PATTERN); if(eventId!=null && propertyName.contains("{" + TemplateVariablesConstants.EVENT_ID + "}")){ propertyName = propertyName.replace("{" +TemplateVariablesConstants.EVENT_ID+ "}", eventId); } if(propertyName.contains("{" + TemplateVariablesConstants.TIMESTAMP + "}")){ + String dateTimePattern = this.env.getProperty(ResidentConstants.FILENAME_DATETIME_PATTERN); propertyName = propertyName.replace("{" +TemplateVariablesConstants.TIMESTAMP+ "}", DateUtils .getUTCCurrentDateTimeString(Objects.requireNonNull(dateTimePattern))); } @@ -522,4 +522,13 @@ else if(featureName.equalsIgnoreCase(RequestType.AUTH_TYPE_LOCK_UNLOCK.toString( public String getRefIdHash(String individualId) throws NoSuchAlgorithmException { return HMACUtils2.digestAsPlainText(individualId.getBytes()); } + + public String formatDateTimeForUI(LocalDateTime localDateTime) { + return localDateTime.format( + DateTimeFormatter.ofPattern(Objects.requireNonNull(env.getProperty(ResidentConstants.UI_DATE_TIME_PATTERN)))); + } + + public String formatWithOffsetForUI(int timeZoneOffset, LocalDateTime localDateTime) { + return formatDateTimeForUI(localDateTime.minusMinutes(timeZoneOffset)); + } } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java index fc52c2182e7..0bc1e0ccbe7 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java @@ -90,8 +90,8 @@ public void setup() throws Exception { @Test public void testCreateRequestGenerationSuccess() throws Exception { Mockito.when(templateUtil.getFeatureName(Mockito.anyString())).thenReturn(RequestType.AUTHENTICATION_REQUEST.toString()); - Mockito.when(acknowledgementService.getAcknowledgementPDF(Mockito.anyString(), Mockito.anyString())).thenReturn("test".getBytes()); - ResponseEntity response = acknowledgementController.getAcknowledgement("bf42d76e-b02e-48c8-a17a-6bb842d85ea9", "eng"); + Mockito.when(acknowledgementService.getAcknowledgementPDF(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("test".getBytes()); + ResponseEntity response = acknowledgementController.getAcknowledgement("bf42d76e-b02e-48c8-a17a-6bb842d85ea9", "eng", 0); assertEquals(response.getStatusCode(), responseEntity.getStatusCode()); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java index 500cc60bc31..d10233df04e 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java @@ -147,7 +147,7 @@ public void testRequestVidCard() throws Exception { VidDownloadCardResponseDto vidDownloadCardResponseDto = new VidDownloadCardResponseDto(); vidDownloadCardResponseDto.setStatus("success"); vidDownloadCardResponseDtoResponseWrapper.setResponse(vidDownloadCardResponseDto); - Mockito.when(downloadCardService.getVidCardEventId(Mockito.any())) + Mockito.when(downloadCardService.getVidCardEventId(Mockito.any(), Mockito.anyInt())) .thenReturn(Tuples.of(vidDownloadCardResponseDtoResponseWrapper, "12345")); mockMvc.perform(MockMvcRequestBuilders.get("/request-card/vid/9086273859467431")).andExpect(status().isOk()); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java index 7a383cedfda..d86ecf2fe2e 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java @@ -354,10 +354,10 @@ public void testRequestAuthUnLockBadRequest() throws Exception { public void testGetServiceHistorySuccess() throws Exception { ResponseWrapper> response = new ResponseWrapper<>(); Mockito.when(residentService.getServiceHistory(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), - Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(response); + Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyInt())).thenReturn(response); residentController.getServiceHistory("eng", 1, 12, LocalDate.parse("2022-06-10"), LocalDate.parse("2022-06-10"), SortType.ASC.toString(), - ServiceType.AUTHENTICATION_REQUEST.name(), null, null, TimeZone.getDefault()); + ServiceType.AUTHENTICATION_REQUEST.name(), null, null, 0); mockMvc.perform(MockMvcRequestBuilders.get("/service-history/eng").contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()); } @@ -521,7 +521,7 @@ public void testCheckAidStatus() throws Exception { @Test @WithUserDetails("reg-admin") public void testGetCredentialRequestStatusSuccess() throws Exception { - residentController.checkAidStatus("17", "eng"); + residentController.checkAidStatus("17", "eng", 0); when(residentService.checkAidStatus("17")).thenReturn("PROCESSED"); this.mockMvc.perform(get("/events/86c2ad43-e2a4-4952-bafc-d97ad1e5e453/?langCode=eng")) .andExpect(status().isOk()); diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java index a539049ceb8..ca08b7fa515 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java @@ -113,7 +113,7 @@ public void setup() throws Exception { residentTransactionEntity.get().setRequestTypeCode(RequestType.SHARE_CRED_WITH_PARTNER.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); Mockito.when(proxyMasterdataServiceImpl.getAllTemplateBylangCodeAndTemplateTypeCode(Mockito.anyString(), Mockito.anyString())).thenReturn(responseWrapper); - Mockito.when(RequestType.SHARE_CRED_WITH_PARTNER.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.SHARE_CRED_WITH_PARTNER.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); ReflectionTestUtils.setField(acknowledgementService, "templateManagerBuilder", templateManagerBuilder); templateManagerBuilder.encodingType(ENCODE_TYPE).enableCache(false).resourceLoader(CLASSPATH).build(); @@ -130,67 +130,67 @@ public void setup() throws Exception { @Test public void testAcknowledgementServiceTest() throws ResidentServiceCheckedException, IOException { - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeGenerateVidTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.GENERATE_VID.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.GENERATE_VID.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.GENERATE_VID.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeRevokeVidTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.REVOKE_VID.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.REVOKE_VID.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.REVOKE_VID.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeOrderPhysicalCardTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.ORDER_PHYSICAL_CARD.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.ORDER_PHYSICAL_CARD.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.ORDER_PHYSICAL_CARD.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeDownloadPersonalizedCardTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.DOWNLOAD_PERSONALIZED_CARD.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.DOWNLOAD_PERSONALIZED_CARD.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.DOWNLOAD_PERSONALIZED_CARD.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeUpdateMyUinTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.UPDATE_MY_UIN.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.UPDATE_MY_UIN.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.UPDATE_MY_UIN.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test public void testAcknowledgementServiceRequestTypeSecureMyIdTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.AUTH_TYPE_LOCK_UNLOCK.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.AUTH_TYPE_LOCK_UNLOCK.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.AUTH_TYPE_LOCK_UNLOCK.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @@ -198,17 +198,17 @@ public void testAcknowledgementServiceRequestTypeSecureMyIdTest() throws Residen public void testAcknowledgmentBadEventIdTest() throws ResidentServiceCheckedException, IOException { residentTransactionEntity = Optional.empty(); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } @Test(expected = ResidentServiceCheckedException.class) public void testAcknowledgmentBadRequestTypeTest() throws ResidentServiceCheckedException, IOException { - Mockito.when(RequestType.GET_MY_ID.getAckTemplateVariables(templateUtil, eventId, languageCode)). + Mockito.when(RequestType.GET_MY_ID.getAckTemplateVariables(templateUtil, eventId, languageCode, 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.GET_MY_ID.toString()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(Optional.empty()); - byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode); + byte[] actualResult = acknowledgementService.getAcknowledgementPDF(eventId, languageCode, 0); assertNotNull(actualResult); } } \ No newline at end of file diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java index 66ee90912c0..c43cf248fb7 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java @@ -282,13 +282,13 @@ public void testGetVidCardEventId() throws BaseCheckedException { residentCredentialResponseDto.setRequestId("123"); responseWrapper.setResponse(residentCredentialResponseDto); Mockito.when(residentServiceRestClient.postApi(any(), any(), any(), any())).thenReturn(responseWrapper); - assertEquals("12345", downloadCardService.getVidCardEventId("123").getT2()); + assertEquals("12345", downloadCardService.getVidCardEventId("123", 0).getT2()); } @Test(expected = ResidentServiceCheckedException.class) public void testGetVidCardEventIdNestedIf() throws BaseCheckedException, IOException { Mockito.when(utilities.getUinByVid(Mockito.anyString())).thenReturn("123456789"); - downloadCardService.getVidCardEventId("123"); + downloadCardService.getVidCardEventId("123", 0); } @Test(expected = ResidentServiceCheckedException.class) @@ -304,7 +304,7 @@ public void testGetVidCardEventIdFailed() throws BaseCheckedException { ResidentErrorCode.VID_REQUEST_CARD_FAILED.getErrorMessage()))); responseWrapper.setResponse(residentCredentialResponseDto); Mockito.when(residentServiceRestClient.postApi(any(), any(), any(), any())).thenReturn(responseWrapper); - downloadCardService.getVidCardEventId("123"); + downloadCardService.getVidCardEventId("123", 0); } @Test(expected = ApisResourceAccessException.class) @@ -313,7 +313,7 @@ public void testGetVidCardEventIdApisResourceAccessException() throws BaseChecke VidDownloadCardResponseDto vidDownloadCardResponseDto = new VidDownloadCardResponseDto(); vidDownloadCardResponseDtoResponseWrapper.setResponse(vidDownloadCardResponseDto); Mockito.when(residentServiceRestClient.postApi(any(), any(), any(), any())).thenThrow(new ApisResourceAccessException()); - downloadCardService.getVidCardEventId("123"); + downloadCardService.getVidCardEventId("123", 0); } @Test(expected = BaseCheckedException.class) @@ -322,7 +322,7 @@ public void testGetVidCardEventIdResidentServiceCheckedException() throws BaseCh VidDownloadCardResponseDto vidDownloadCardResponseDto = new VidDownloadCardResponseDto(); vidDownloadCardResponseDtoResponseWrapper.setResponse(vidDownloadCardResponseDto); Mockito.when(utilities.getUinByVid(Mockito.anyString())).thenThrow(new IOException()); - downloadCardService.getVidCardEventId("123"); + downloadCardService.getVidCardEventId("123", 0); } @Test @@ -350,8 +350,8 @@ public void testGetVidCardEventIdWithVidDetails() throws BaseCheckedException { vidDetails.put("transactionCount", "1234343434"); vidList.add(vidDetails); vidResponse.setResponse(vidList); - Mockito.when(vidService.retrieveVids(Mockito.anyString())).thenReturn(vidResponse); - assertEquals("12345", downloadCardService.getVidCardEventId("123").getT2()); + Mockito.when(vidService.retrieveVids(Mockito.anyString(), Mockito.anyInt())).thenReturn(vidResponse); + assertEquals("12345", downloadCardService.getVidCardEventId("123", 0).getT2()); } @Test diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetEventStatusTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetEventStatusTest.java index 684ac077d41..52dd26d3f80 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetEventStatusTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetEventStatusTest.java @@ -102,7 +102,7 @@ public void setup() throws ResidentServiceCheckedException, ApisResourceAccessEx templateVariables.put("authenticationMode", "OTP"); templateVariables.put("partnerName", "partnerName"); templateVariables.put("purpose", "authentication"); - Mockito.when(requestType.getAckTemplateVariables(templateUtil, Mockito.anyString(), Mockito.anyString())).thenReturn(Tuples.of(templateVariables, "")); + Mockito.when(requestType.getAckTemplateVariables(templateUtil, Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn(Tuples.of(templateVariables, "")); Mockito.when(identityServiceImpl.getResidentIndvidualId()).thenReturn("123456789"); Mockito.when(identityServiceImpl.getResidentIdaToken()).thenReturn("123456789"); Mockito.doNothing().when(audit).setAuditRequestDto(Mockito.any()); @@ -117,21 +117,21 @@ public void setup() throws ResidentServiceCheckedException, ApisResourceAccessEx @Test public void getEventStatusTest() throws ResidentServiceCheckedException { - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } @Test public void getEventStatusTestVid() throws ResidentServiceCheckedException { Mockito.when(validator.validateVid(Mockito.anyString())).thenReturn(true); - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } @Test public void getEventStatusTestUIN() throws ResidentServiceCheckedException { Mockito.when(validator.validateUin(Mockito.anyString())).thenReturn(true); - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } @@ -139,7 +139,7 @@ public void getEventStatusTestUIN() throws ResidentServiceCheckedException { public void getEventStatusTestEventStatusFailure() throws ResidentServiceCheckedException { residentTransactionEntity.get().setStatusCode(EventStatusFailure.AUTHENTICATION_FAILED.name()); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } @@ -147,34 +147,34 @@ public void getEventStatusTestEventStatusFailure() throws ResidentServiceChecked public void getEventStatusTestEventStatusPending() throws ResidentServiceCheckedException{ residentTransactionEntity.get().setStatusCode("in-progress"); Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(residentTransactionEntity); - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } @Test(expected = ResidentServiceCheckedException.class) public void getEventStatusTestException() throws ResidentServiceCheckedException { Mockito.when(residentTransactionRepository.findById(Mockito.anyString())).thenReturn(Optional.empty()); - residentService.getEventStatus(eventId, langCode); + residentService.getEventStatus(eventId, langCode, 0); } @Test(expected = EidNotBelongToSessionException.class) public void getEventStatusNestedIfTest() throws ResidentServiceCheckedException, ApisResourceAccessException { Mockito.when(identityServiceImpl.getResidentIdaToken()).thenReturn("abcd"); - residentService.getEventStatus(eventId, langCode); + residentService.getEventStatus(eventId, langCode, 0); } @Test(expected = ResidentServiceCheckedException.class) public void getEventStatusThrowsExceptionTest() throws ResidentServiceCheckedException, ApisResourceAccessException { Mockito.when(identityServiceImpl.getResidentIdaToken()).thenThrow(new ApisResourceAccessException()); - residentService.getEventStatus(eventId, langCode); + residentService.getEventStatus(eventId, langCode, 0); } @Test public void getEventStatusServiceTypeNotMappedTest() throws ResidentServiceCheckedException { - Mockito.when(RequestType.SEND_OTP.getAckTemplateVariables(templateUtil, eventId, "eng")). + Mockito.when(RequestType.SEND_OTP.getAckTemplateVariables(templateUtil, eventId, "eng", 0)). thenReturn(Tuples.of(templateVariables, "acknowledgement-order-a-physical-card")); residentTransactionEntity.get().setRequestTypeCode(RequestType.SEND_OTP.name()); - ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode); + ResponseWrapper resultResponseWrapper =residentService.getEventStatus(eventId, langCode, 0); assert resultResponseWrapper.getResponse().getEventId().equals(eventId); } } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetServiceHistoryTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetServiceHistoryTest.java index 85e103d0f8d..c6514391b2d 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetServiceHistoryTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceGetServiceHistoryTest.java @@ -145,8 +145,8 @@ public void testGetServiceHistorySuccess() throws ResidentServiceCheckedExceptio pageSize = 3; fromDate = LocalDate.now(); toDate = LocalDate.now(); - assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, LocalDate.now(), LocalDate.now(), serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, LocalDate.now(), LocalDate.now(), serviceType, "DESC", statusFilter, searchText, "eng").getResponse().getPageSize()); + assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, LocalDate.now(), LocalDate.now(), serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, LocalDate.now(), LocalDate.now(), serviceType, "DESC", statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test @@ -154,42 +154,42 @@ public void testGetServiceHistoryDateNullCheck() throws ResidentServiceCheckedEx pageStart = 2; pageSize = 3; - assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, "DESC", statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, "DESC", statusFilter, searchText, "eng").getResponse().getPageSize()); + assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, "DESC", statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(3, residentServiceImpl.getServiceHistory(pageStart, pageSize, null, null, serviceType, "DESC", statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test public void testGetServiceHistoryNullCheck() throws ResidentServiceCheckedException, ApisResourceAccessException { - assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); + assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test(expected = ResidentServiceCheckedException.class) public void testGetServiceHistoryCheckedException() throws ResidentServiceCheckedException, ApisResourceAccessException { Integer pageStart = 1; Integer pageSize = 1; - Mockito.when(residentServiceImpl.getServiceHistory( -1, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng")).thenThrow(ResidentServiceCheckedException.class); - Mockito.when(residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng")).thenThrow(ResidentServiceCheckedException.class); - Mockito.when(residentServiceImpl.getServiceHistory( pageStart, 1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng")).thenThrow(ResidentServiceCheckedException.class); - assertEquals(0, residentServiceImpl.getServiceHistory( -1, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(0, residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); + Mockito.when(residentServiceImpl.getServiceHistory( -1, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0)).thenThrow(ResidentServiceCheckedException.class); + Mockito.when(residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0)).thenThrow(ResidentServiceCheckedException.class); + Mockito.when(residentServiceImpl.getServiceHistory( pageStart, 1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0)).thenThrow(ResidentServiceCheckedException.class); + assertEquals(0, residentServiceImpl.getServiceHistory( -1, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(0, residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test(expected = ResidentServiceCheckedException.class) public void testGetServiceHistoryNegativeResidentServiceCheckedException() throws ResidentServiceCheckedException, ApisResourceAccessException { Integer pageStart = 1; - Mockito.when(residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng")).thenThrow(ResidentServiceCheckedException.class); - assertEquals(0, residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); + Mockito.when(residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0)).thenThrow(ResidentServiceCheckedException.class); + assertEquals(0, residentServiceImpl.getServiceHistory( pageStart, -1, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test public void testPageSizeCheck() throws ResidentServiceCheckedException, ApisResourceAccessException { pageSize = 10; pageStart = 1; - assertEquals(10, residentServiceImpl.getServiceHistory(null, null, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(10, residentServiceImpl.getServiceHistory(null, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); - assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, null, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng").getResponse().getPageSize()); + assertEquals(10, residentServiceImpl.getServiceHistory(null, null, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(10, residentServiceImpl.getServiceHistory(null, pageSize, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); + assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, null, fromDate, toDate, serviceType, sortType, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test @@ -197,7 +197,7 @@ public void testSortTypeNullCheck() throws ResidentServiceCheckedException, Apis pageStart = 1; pageSize = 10; assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, - null, statusFilter, searchText, "eng").getResponse().getPageSize()); + null, statusFilter, searchText, "eng", 0).getResponse().getPageSize()); } @Test @@ -211,21 +211,21 @@ public void testServiceHistoryWithDifferentParameters() throws ResidentServiceCh statusFilter = "SUCCESS"; searchText = "a"; assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, sortType, - statusFilter, searchText, "eng").getResponse().getPageSize()); + statusFilter, searchText, "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, "ALL", sortType, - statusFilter, searchText, "eng").getResponse().getPageSize()); + statusFilter, searchText, "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, sortType, - statusFilter, null, "eng").getResponse().getPageSize()); + statusFilter, null, "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, "ALL", sortType, - statusFilter, null, "eng").getResponse().getPageSize()); + statusFilter, null, "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, serviceType, sortType, - null, "a", "eng").getResponse().getPageSize()); + null, "a", "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, "ALL", sortType, - null, "a", "eng").getResponse().getPageSize()); + null, "a", "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, null, sortType, - statusFilter, "a", "eng").getResponse().getPageSize()); + statusFilter, "a", "eng", 0).getResponse().getPageSize()); assertEquals(10, residentServiceImpl.getServiceHistory(pageStart, pageSize, fromDate, toDate, "ALL", sortType, - null, "a", "eng").getResponse().getPageSize()); + null, "a", "eng", 0).getResponse().getPageSize()); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java index 6cbbb0891d5..56ff0699da3 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java @@ -97,25 +97,25 @@ public void setUp() throws ApisResourceAccessException { @Test public void getAckTemplateVariablesForAuthenticationRequest() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForAuthenticationRequest(eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForAuthenticationRequest(eventId, "eng", 0).getT1(); assertEquals(EventStatus.SUCCESS.getStatus(),ackTemplateVariables.get(TemplateVariablesConstants.EVENT_STATUS)); } @Test public void getAckTemplateVariablesForCredentialShare() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForCredentialShare( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForCredentialShare( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForDownloadPersonalizedCard() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForDownloadPersonalizedCard( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForDownloadPersonalizedCard( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForOrderPhysicalCard() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForOrderPhysicalCard( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForOrderPhysicalCard( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @@ -123,56 +123,56 @@ public void getAckTemplateVariablesForOrderPhysicalCard() { public void getAckTemplateVariablesForOrderPhysicalCardPaymentFailed() { residentTransactionEntity.setStatusCode(EventStatusFailure.PAYMENT_FAILED.name()); Mockito.when(residentTransactionRepository.findById(eventId)).thenReturn(java.util.Optional.ofNullable(residentTransactionEntity)); - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForOrderPhysicalCard( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForOrderPhysicalCard( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForGetMyId() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForGetMyId( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForGetMyId( eventId, "eng", 0).getT1(); assertEquals(eventId,ackTemplateVariables.get(TemplateVariablesConstants.EVENT_ID)); } @Test public void getAckTemplateVariablesForBookAnAppointment() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForBookAnAppointment( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForBookAnAppointment( eventId, "eng", 0).getT1(); assertEquals(Collections.emptyMap(),ackTemplateVariables); } @Test public void getAckTemplateVariablesForUpdateMyUin() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForUpdateMyUin( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForUpdateMyUin( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForGenerateVid() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForGenerateVid( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForGenerateVid( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForRevokeVid() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForRevokeVid( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForRevokeVid( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test public void getAckTemplateVariablesForVerifyPhoneOrEmail() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForVerifyPhoneEmail( eventId); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForVerifyPhoneEmail( eventId, 0); assertEquals(eventId,ackTemplateVariables.get(TemplateVariablesConstants.EVENT_ID)); } @Test public void getAckTemplateVariablesForAuthLock() { - Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForAuthTypeLockUnlock( eventId, "eng").getT1(); + Map ackTemplateVariables = templateUtil.getAckTemplateVariablesForAuthTypeLockUnlock( eventId, "eng", 0).getT1(); assertEquals(OTP,ackTemplateVariables.get(TemplateVariablesConstants.AUTHENTICATION_MODE)); } @Test(expected = ResidentServiceException.class) public void getCommonTemplateVariablesTestBadEventId() { Mockito.when(residentTransactionRepository.findById(eventId)).thenReturn(java.util.Optional.empty()); - templateUtil.getCommonTemplateVariables(eventId, ""); + templateUtil.getCommonTemplateVariables(eventId, "", 0); } @Test @@ -184,7 +184,7 @@ public void getFeatureNameTest() { public void getCommonTemplateVariablesTestFailedEventStatus() { residentTransactionEntity.setStatusCode(EventStatusFailure.AUTHENTICATION_FAILED.name()); Mockito.when(residentTransactionRepository.findById(eventId)).thenReturn(java.util.Optional.ofNullable(residentTransactionEntity)); - assertEquals(EventStatus.FAILED.getStatus(),templateUtil.getCommonTemplateVariables(eventId, "eng").get( + assertEquals(EventStatus.FAILED.getStatus(),templateUtil.getCommonTemplateVariables(eventId, "eng", 0).get( TemplateVariablesConstants.EVENT_STATUS )); } @@ -193,24 +193,24 @@ public void getCommonTemplateVariablesTestFailedEventStatus() { public void getCommonTemplateVariablesTestInProgressEventStatus() { residentTransactionEntity.setStatusCode(EventStatusInProgress.OTP_REQUESTED.name()); Mockito.when(residentTransactionRepository.findById(eventId)).thenReturn(java.util.Optional.ofNullable(residentTransactionEntity)); - assertEquals(EventStatus.IN_PROGRESS.getStatus(),templateUtil.getCommonTemplateVariables(eventId, "eng").get( + assertEquals(EventStatus.IN_PROGRESS.getStatus(),templateUtil.getCommonTemplateVariables(eventId, "eng", 0).get( TemplateVariablesConstants.EVENT_STATUS )); } @Test public void getAckTemplateVariablesForVidCardDownloadTest() { - assertEquals(2,templateUtil.getAckTemplateVariablesForVidCardDownload(eventId, "eng").size()); + assertEquals(2,templateUtil.getAckTemplateVariablesForVidCardDownload(eventId, "eng", 0).size()); } @Test public void getAckTemplateVariablesForSendOtpTest() { - assertEquals(eventId,templateUtil.getAckTemplateVariablesForSendOtp(eventId, "eng").getT1().get(TemplateVariablesConstants.EVENT_ID)); + assertEquals(eventId,templateUtil.getAckTemplateVariablesForSendOtp(eventId, "eng", 0).getT1().get(TemplateVariablesConstants.EVENT_ID)); } @Test public void getAckTemplateVariablesForValidateOtpTest() { - assertEquals(eventId,templateUtil.getAckTemplateVariablesForValidateOtp(eventId, "eng").getT1().get(TemplateVariablesConstants.EVENT_ID)); + assertEquals(eventId,templateUtil.getAckTemplateVariablesForValidateOtp(eventId, "eng", 0).getT1().get(TemplateVariablesConstants.EVENT_ID)); } @Test From 6daf6f20bb8b97d5ef6329617bad499949eb66d9 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:14:04 +0530 Subject: [PATCH 08/15] Test fixes --- .../java/io/mosip/resident/constant/ResidentConstants.java | 2 +- .../src/test/java/io/mosip/resident/test/util/UtilityTest.java | 3 +++ .../resident-service/src/test/resources/application.properties | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java index de21c89486e..b779e451cc0 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/constant/ResidentConstants.java @@ -180,7 +180,7 @@ private ResidentConstants() { public static final String VID_TYPE = "vidType"; public static final String MASKED_VID = "*masked VID*"; public static final String UI_DATE_TIME_PATTERN = "resident.ui.datetime.pattern"; - public static final String FILENAME_DATETIME_PATTERN = "resident.filename.datetime.pattern"; + public static final String FILENAME_DATETIME_PATTERN = "resident.filename.datetime.pattern"; public static final String NO_ID = "NO_ID"; public static final String NO_ID_TYPE = "NO_ID_TYPE"; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java index 93d57d72614..371fca8f74f 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java @@ -55,6 +55,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) @@ -93,6 +94,8 @@ public void setUp() throws IOException, ApisResourceAccessException { identity = JsonUtil.readValue(idJsonString, JSONObject.class); ReflectionTestUtils.setField(utility, "configServerFileStorageURL", "url"); ReflectionTestUtils.setField(utility, "residentIdentityJson", "json"); + when(env.getProperty("resident.ui.datetime.pattern")).thenReturn("yyyy-MM-dd"); + when(env.getProperty("resident.filename.datetime.pattern")).thenReturn("yyyy-MM-dd"); } @Test diff --git a/resident/resident-service/src/test/resources/application.properties b/resident/resident-service/src/test/resources/application.properties index 1e46a0d0d2a..f9fecf0fad5 100644 --- a/resident/resident-service/src/test/resources/application.properties +++ b/resident/resident-service/src/test/resources/application.properties @@ -66,6 +66,8 @@ resident.authhistory.id=mosip.resident.authhistory mosip.resident.service.status.check.id=mosip.registration.status mosip.resident.service.status.check.version=1.0 resident.datetime.pattern=yyyy-MM-dd'T'HH:mm:ss.SSS'Z' +resident.filename.datetime.pattern=yyyy-MM-dd_HH-mm-ss +resident.ui.datetime.pattern=yyyy-MM-dd HH:mm:ss auth.types.allowed=otp,bio-FIR,bio-IIR,bio-FACE resident.center.id=10008 resident.machine.id=20007 From 35c10c365fcf462eb4d2d390c14d2986b0b00cf2 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:24:17 +0530 Subject: [PATCH 09/15] Test fix --- .../src/main/java/io/mosip/resident/util/Utilitiy.java | 1 + 1 file changed, 1 insertion(+) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java index 95be543a243..8e019a75d00 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java @@ -532,6 +532,7 @@ public String formatWithOffsetForUI(int timeZoneOffset, LocalDateTime localDateT public String formatWithOffsetForFileName(int timeZoneOffset, LocalDateTime localDateTime) { return formatDateTimeForPattern(localDateTime.minusMinutes(timeZoneOffset), Objects.requireNonNull(env.getProperty(ResidentConstants.FILENAME_DATETIME_PATTERN))); + } public String getClientIp(HttpServletRequest req) { logger.debug("Utilitiy::getClientIp()::entry"); From e833f3f1cba72c9aeeaaa792cd5cc0f9b297439a Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:34:30 +0530 Subject: [PATCH 10/15] Fix to filename pattern --- .../src/main/java/io/mosip/resident/util/Utilitiy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java index 8e019a75d00..d2980c7055d 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java @@ -461,7 +461,7 @@ public String getFileName(String eventId, String propertyName, int timeZoneOffse propertyName = propertyName.replace("{" +TemplateVariablesConstants.EVENT_ID+ "}", eventId); } if(propertyName.contains("{" + TemplateVariablesConstants.TIMESTAMP + "}")){ - propertyName = propertyName.replace("{" +TemplateVariablesConstants.TIMESTAMP+ "}", formatWithOffsetForUI(timeZoneOffset, DateUtils.getUTCCurrentDateTime())); + propertyName = propertyName.replace("{" +TemplateVariablesConstants.TIMESTAMP+ "}", formatWithOffsetForFileName(timeZoneOffset, DateUtils.getUTCCurrentDateTime())); } return propertyName; } From ecfa1d1c171e5705b03983fdc8a6c26a2fc9008c Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:39:00 +0530 Subject: [PATCH 11/15] Added missing file --- .../mosip/resident/function/QuadFunction.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 resident/resident-service/src/main/java/io/mosip/resident/function/QuadFunction.java diff --git a/resident/resident-service/src/main/java/io/mosip/resident/function/QuadFunction.java b/resident/resident-service/src/main/java/io/mosip/resident/function/QuadFunction.java new file mode 100644 index 00000000000..008078bb01d --- /dev/null +++ b/resident/resident-service/src/main/java/io/mosip/resident/function/QuadFunction.java @@ -0,0 +1,27 @@ +package io.mosip.resident.function; + +/** + * + * @author Loganathan Sekar + * + * @param Type Argument 1 + * @param Type Argument 2 + * @param Type Argument 3 + * @param Type Argument 4 + * @param Return type + */ +@FunctionalInterface +public interface QuadFunction { + + /** + * Applies this function to the given arguments. + * + * @param t the first function argument + * @param u the second function argument + * @param v the third function argument + * @param w the fourth function argument + * @return the function result + */ + R apply(T t, U u, V v, W w); + +} From 84a22a99f099234caf306c41ebcca55317fec994 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:42:34 +0530 Subject: [PATCH 12/15] Refactored to fix utility class name --- .../io/mosip/resident/aspect/LoginCheck.java | 4 +- .../java/io/mosip/resident/config/Config.java | 4 +- .../controller/AcknowledgementController.java | 4 +- .../DownLoadMasterDataController.java | 4 +- .../controller/DownloadCardController.java | 4 +- .../controller/ProxyAuditController.java | 4 +- .../controller/ResidentController.java | 4 +- .../resident/service/NotificationService.java | 4 +- .../impl/AcknowledgementServiceImpl.java | 4 +- .../AuthTransactionCallBackServiceImpl.java | 4 +- .../impl/DownLoadMasterDataServiceImpl.java | 4 +- .../service/impl/DownloadCardServiceImpl.java | 4 +- .../service/impl/IdentityServiceImpl.java | 4 +- .../service/impl/OrderCardServiceImpl.java | 4 +- .../service/impl/ProxyOtpServiceImpl.java | 4 +- .../impl/ResidentConfigServiceImpl.java | 6 +-- .../impl/ResidentCredentialServiceImpl.java | 14 +++---- .../service/impl/ResidentOtpServiceImpl.java | 4 +- .../service/impl/ResidentServiceImpl.java | 42 +++++++++---------- .../service/impl/ResidentVidServiceImpl.java | 30 ++++++------- .../service/impl/VerificationServiceImpl.java | 4 +- .../io/mosip/resident/util/TemplateUtil.java | 2 +- .../util/{Utilitiy.java => Utility.java} | 4 +- .../impl/ResidentOtpServiceImplTest.java | 4 +- .../resident/test/aspect/LoginCheckTest.java | 4 +- .../AcknowledgmentControllerTest.java | 4 +- .../DownloadCardControllerTest.java | 4 +- .../DownloadMasterdataControllerTest.java | 4 +- .../controller/GrievanceControllerTest.java | 4 +- .../controller/ProxyAuditControllerTest.java | 4 +- .../controller/ProxyOtpControllerTest.java | 4 +- .../controller/ResidentOtpControllerTest.java | 4 +- .../service/AcknowledgmentServiceTest.java | 4 +- .../AuthTransactionCallbackServiceTest.java | 4 +- .../test/service/DownloadCardServiceTest.java | 4 +- .../DownloadmasterDataServiceImplTest.java | 4 +- .../test/service/IdentityServiceTest.java | 4 +- .../test/service/NotificationServiceTest.java | 4 +- .../test/service/OrderCardServiceTest.java | 4 +- .../service/ProxyOtpServiceImpllTest.java | 4 +- .../ResidentCredentialServiceTest.java | 4 +- .../ResidentServiceDownloadCardTest.java | 4 +- ...esidentServiceRequestTypeAuthLockTest.java | 4 +- .../service/ResidentServiceResUpdateTest.java | 4 +- .../ResidentVerificationServiceTest.java | 4 +- .../test/service/ResidentVidServiceTest.java | 4 +- .../resident/test/util/TemplateUtilTest.java | 4 +- .../mosip/resident/test/util/UtilityTest.java | 16 +++---- 48 files changed, 139 insertions(+), 139 deletions(-) rename resident/resident-service/src/main/java/io/mosip/resident/util/{Utilitiy.java => Utility.java} (97%) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/aspect/LoginCheck.java b/resident/resident-service/src/main/java/io/mosip/resident/aspect/LoginCheck.java index 614e8c53314..e23c7205762 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/aspect/LoginCheck.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/aspect/LoginCheck.java @@ -22,7 +22,7 @@ import io.mosip.resident.entity.ResidentUserEntity; import io.mosip.resident.repository.ResidentUserRepository; import io.mosip.resident.service.impl.IdentityServiceImpl; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; /** * Aspect class for login redirect API @@ -51,7 +51,7 @@ public class LoginCheck { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utilitiy utility; + private Utility utility; private static final Logger logger = LoggerConfiguration.logConfig(LoginCheck.class); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java b/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java index 28ec6ffc23c..8b2e2db9b58 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/config/Config.java @@ -30,7 +30,7 @@ import io.mosip.kernel.keygenerator.bouncycastle.KeyGenerator; import io.mosip.kernel.templatemanager.velocity.impl.TemplateManagerImpl; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; @Configuration @@ -52,7 +52,7 @@ public class Config { @Bean("varres") public VariableResolverFactory getVariableResolverFactory() { - String mvelExpression = Utilitiy.readResourceContent(mvelFile); + String mvelExpression = Utility.readResourceContent(mvelFile); VariableResolverFactory functionFactory = new MapVariableResolverFactory(); MVEL.eval(mvelExpression, functionFactory); return functionFactory; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java index 79e2a1b707c..edacf2a85e1 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java @@ -11,7 +11,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import io.swagger.v3.oas.annotations.tags.Tag; @@ -60,7 +60,7 @@ public class AcknowledgementController { private TemplateUtil templateUtil; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @GetMapping("/ack/download/pdf/event/{eventId}/language/{languageCode}") public ResponseEntity getAcknowledgement(@PathVariable("eventId") String eventId, diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java index afa59b09b62..0cf12973c03 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java @@ -7,7 +7,7 @@ import io.mosip.resident.service.DownLoadMasterDataService; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; @@ -52,7 +52,7 @@ public class DownLoadMasterDataController { private AuditUtil audit; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private Environment environment; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index 6a0827fa131..a81a1840585 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -16,7 +16,7 @@ import io.mosip.resident.service.DownloadCardService; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -65,7 +65,7 @@ public class DownloadCardController { DownloadCardService downloadCardService; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private Environment environment; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ProxyAuditController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ProxyAuditController.java index d4fd19c18aa..c57787b2d70 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ProxyAuditController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ProxyAuditController.java @@ -20,7 +20,7 @@ import io.mosip.resident.exception.ResidentServiceCheckedException; import io.mosip.resident.service.IdentityService; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -45,7 +45,7 @@ public class ProxyAuditController { private IdentityService identityService; @Autowired - private Utilitiy utility; + private Utility utility; /** * Auth audit log. diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index 183e4e819d1..b7d13fec53c 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -81,7 +81,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.JsonUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -108,7 +108,7 @@ public class ResidentController { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private Environment environment; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/NotificationService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/NotificationService.java index 6ef42312db9..2ed117e0165 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/NotificationService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/NotificationService.java @@ -52,7 +52,7 @@ import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.TemplateUtil; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; /** @@ -82,7 +82,7 @@ public class NotificationService { private ResidentServiceRestClient restClient; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private Utilities utilities; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java index a50ca6cadb0..29a61d41f70 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java @@ -13,7 +13,7 @@ import io.mosip.resident.repository.ResidentTransactionRepository; import io.mosip.resident.service.AcknowledgementService; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -60,7 +60,7 @@ public void idTemplateManagerPostConstruct() { } @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Override public byte[] getAcknowledgementPDF(String eventId, String languageCode, int timeZoneOffset) throws ResidentServiceCheckedException, IOException { diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AuthTransactionCallBackServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AuthTransactionCallBackServiceImpl.java index 1d37c03adfe..53fe9703dc1 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AuthTransactionCallBackServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AuthTransactionCallBackServiceImpl.java @@ -23,7 +23,7 @@ import io.mosip.resident.service.AuthTransactionCallBackService; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; @Component public class AuthTransactionCallBackServiceImpl implements AuthTransactionCallBackService { @@ -44,7 +44,7 @@ public class AuthTransactionCallBackServiceImpl implements AuthTransactionCallBa private IdentityServiceImpl identityService; @Autowired - private Utilitiy utility; + private Utility utility; @Override public void updateAuthTransactionCallBackService(EventModel eventModel) throws ResidentServiceCheckedException, ApisResourceAccessException, NoSuchAlgorithmException { diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java index da9590a6065..7d64e6ddc58 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java @@ -16,7 +16,7 @@ import io.mosip.resident.exception.ResidentServiceException; import io.mosip.resident.service.DownLoadMasterDataService; import io.mosip.resident.service.ProxyMasterdataService; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -69,7 +69,7 @@ public class DownLoadMasterDataServiceImpl implements DownLoadMasterDataService private ObjectMapper mapper; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; private static final Logger logger = LoggerConfiguration.logConfig(ProxyMasterdataServiceImpl.class); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java index 03e77cc9773..dd01314fff4 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java @@ -38,7 +38,7 @@ import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.MediaType; @@ -94,7 +94,7 @@ public class DownloadCardServiceImpl implements DownloadCardService { private ResidentServiceImpl residentService; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private IdentityServiceImpl identityService; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java index a3cd4f71fe1..43b18cd1a5d 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/IdentityServiceImpl.java @@ -64,7 +64,7 @@ import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; /** @@ -106,7 +106,7 @@ public class IdentityServiceImpl implements IdentityService { private ResidentServiceRestClient restClientWithPlainRestTemplate; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private TokenIDGenerator tokenIDGenerator; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/OrderCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/OrderCardServiceImpl.java index c86671b58ab..0f4d8420143 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/OrderCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/OrderCardServiceImpl.java @@ -28,7 +28,7 @@ import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.codec.binary.Base64; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -68,7 +68,7 @@ public class OrderCardServiceImpl implements OrderCardService { private AuditUtil auditUtil; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired NotificationService notificationService; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyOtpServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyOtpServiceImpl.java index af3fb00fef0..0ec5129c2ef 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyOtpServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyOtpServiceImpl.java @@ -25,7 +25,7 @@ import io.mosip.resident.service.ProxyOtpService; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -65,7 +65,7 @@ public class ProxyOtpServiceImpl implements ProxyOtpService { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentConfigServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentConfigServiceImpl.java index 1b1ad8b06b2..c8aa548cc93 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentConfigServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentConfigServiceImpl.java @@ -32,7 +32,7 @@ import io.mosip.resident.exception.ResidentServiceException; import io.mosip.resident.handler.service.ResidentConfigService; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; /** * The Class ResidentConfigServiceImpl. @@ -129,7 +129,7 @@ public String getUISchema(String schemaType) { Resource residentUiSchemaJsonFileRes = resourceLoader .getResource(String.format("%s-%s-schema.json", residentUiSchemaJsonFilePrefix, schemaType)); if (residentUiSchemaJsonFileRes.exists()) { - uiSchema = Utilitiy.readResourceContent(residentUiSchemaJsonFileRes); + uiSchema = Utility.readResourceContent(residentUiSchemaJsonFileRes); } else { throw new ResidentServiceException(ResidentErrorCode.API_RESOURCE_UNAVAILABLE); } @@ -173,7 +173,7 @@ private List doGetUiSchemaFilteredInputAttributes(String schemaType) thr @Override public String getIdentityMapping() throws ResidentServiceCheckedException { if(identityMapping==null) { - identityMapping=Utilitiy.readResourceContent(identityMappingJsonFile); + identityMapping=Utility.readResourceContent(identityMappingJsonFile); } return identityMapping; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentCredentialServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentCredentialServiceImpl.java index d75b10b93e1..4d142669208 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentCredentialServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentCredentialServiceImpl.java @@ -47,7 +47,7 @@ import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -111,7 +111,7 @@ public class ResidentCredentialServiceImpl implements ResidentCredentialService Environment env; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private IdentityServiceImpl identityServiceImpl; @@ -197,20 +197,20 @@ public ResidentCredentialResponseDto reqCredential(ResidentCredentialRequestDto residentCredentialResponseDto = JsonUtil.readValue( JsonUtil.writeValueAsString(responseDto.getResponse()), ResidentCredentialResponseDto.class); additionalAttributes.put("RID", residentCredentialResponseDto.getRequestId()); - if(!Utilitiy.isSecureSession()){ + if(!Utility.isSecureSession()){ sendNotification(dto.getIndividualId(), NotificationTemplateCode.RS_CRE_REQ_SUCCESS, additionalAttributes); } } catch (ResidentServiceCheckedException | ApisResourceAccessException e) { - if(!Utilitiy.isSecureSession()){ + if(!Utility.isSecureSession()){ sendNotification(dto.getIndividualId(), NotificationTemplateCode.RS_CRE_REQ_FAILURE, additionalAttributes); } audit.setAuditRequestDto(EventEnum.CREDENTIAL_REQ_EXCEPTION); throw new ResidentCredentialServiceException(ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorCode(), ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorMessage(), e); } catch (IOException e) { - if(!Utilitiy.isSecureSession()){ + if(!Utility.isSecureSession()){ sendNotification(dto.getIndividualId(), NotificationTemplateCode.RS_CRE_REQ_FAILURE, additionalAttributes); } audit.setAuditRequestDto(EventEnum.CREDENTIAL_REQ_EXCEPTION); @@ -299,7 +299,7 @@ public Tuple2 shareCredential(ResidentC throw new ResidentCredentialServiceException(ResidentErrorCode.IO_EXCEPTION, e, Map.of(ResidentConstants.EVENT_ID, eventId)); } finally { - if (Utilitiy.isSecureSession() && residentTransactionEntity != null) { + if (Utility.isSecureSession() && residentTransactionEntity != null) { //if the status code will come as null, it will set it as failed. if(residentTransactionEntity.getStatusCode()==null) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); @@ -435,7 +435,7 @@ public CredentialRequestStatusResponseDto getStatus(String requestId) { public CredentialReqestDto prepareCredentialRequest(ResidentCredentialRequestDto residentCreDto, String individualId) { CredentialReqestDto crDto = new CredentialReqestDto(); - if(Utilitiy.isSecureSession()){ + if(Utility.isSecureSession()){ crDto.setId(individualId); crDto.setCredentialType(credentialType); crDto.setEncrypt(isEncrypt); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java index 6de5e06187f..f2dbdf25b24 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java @@ -21,7 +21,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.MediaType; @@ -60,7 +60,7 @@ public class ResidentOtpServiceImpl implements ResidentOtpService { private ResidentServiceImpl residentServiceImpl; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private ObjectMapper objectMapper; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java index 5127fb25a63..ae67c0054a8 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java @@ -109,7 +109,7 @@ import io.mosip.resident.util.TemplateUtil; import io.mosip.resident.util.UINCardDownloadService; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.json.simple.JSONObject; @@ -221,7 +221,7 @@ public class ResidentServiceImpl implements ResidentService { private TemplateUtil templateUtil; @Autowired - public Utilitiy utility; + public Utility utility; @Autowired private Utilities utilities; @@ -835,7 +835,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj String eventId = ResidentConstants.NOT_AVAILABLE; ResidentTransactionEntity residentTransactionEntity = null; try { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentUpdateResponseDTOV2 = new ResidentUpdateResponseDTOV2(); responseDto = residentUpdateResponseDTOV2; residentTransactionEntity = createResidentTransEntity(dto); @@ -893,7 +893,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj || mappingJson.trim().isEmpty()) { audit.setAuditRequestDto( EventEnum.getEventEnumWithValue(EventEnum.JSON_PARSING_EXCEPTION, dto.getTransactionID())); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.JSON_PROCESSING_EXCEPTION, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -906,7 +906,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj demographicIdentity); JSONObject mappingDocument = JsonUtil.getJSONObject(mappingJsonObject, DOCUMENT); List documents; - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { documents = getResidentDocuments(dto, mappingDocument); } else { documents = dto.getDocuments(); @@ -931,7 +931,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj EventEnum.getEventEnumWithValue(EventEnum.OBTAINED_RID_UIN_UPDATE, dto.getTransactionID())); NotificationResponseDTO notificationResponseDTO; - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { updateResidentTransaction(residentTransactionEntity, response); notificationResponseDTO = sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.REQUEST_RECEIVED, eventId, additionalAttributes); @@ -948,7 +948,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_SUCCESS, dto.getTransactionID(), "Request for UIN update")); } catch (OtpValidationFailedException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -965,7 +965,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj e); } catch (ValidationFailedException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -978,7 +978,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, dto.getTransactionID(), "Request for UIN update")); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(e.getErrorCode(), e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -986,7 +986,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj } } catch (ApisResourceAccessException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -1001,7 +1001,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj dto.getTransactionID(), "Request for UIN update")); if (e.getCause() instanceof HttpClientErrorException) { HttpClientErrorException httpClientException = (HttpClientErrorException) e.getCause(); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorCode(), httpClientException.getResponseBodyAsString(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); @@ -1011,7 +1011,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj } } else if (e.getCause() instanceof HttpServerErrorException) { HttpServerErrorException httpServerException = (HttpServerErrorException) e.getCause(); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorCode(), httpServerException.getResponseBodyAsString(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); @@ -1020,7 +1020,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj httpServerException.getResponseBodyAsString()); } } else { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorCode(), ResidentErrorCode.API_RESOURCE_ACCESS_EXCEPTION.getErrorMessage() + e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); @@ -1030,7 +1030,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj } } } catch (IOException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -1043,7 +1043,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, dto.getTransactionID(), "Request for UIN update")); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.IO_EXCEPTION.getErrorCode(), ResidentErrorCode.IO_EXCEPTION.getErrorMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); @@ -1052,7 +1052,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj ResidentErrorCode.IO_EXCEPTION.getErrorMessage(), e); } } catch (ResidentServiceCheckedException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -1066,7 +1066,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, dto.getTransactionID(), "Request for UIN update")); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException( ResidentErrorCode.NO_DOCUMENT_FOUND_FOR_TRANSACTION_ID.getErrorCode(), ResidentErrorCode.NO_DOCUMENT_FOUND_FOR_TRANSACTION_ID.getErrorMessage() + dto.getTransactionID(), @@ -1078,7 +1078,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj } } catch (BaseCheckedException e) { - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionEntity.setRequestSummary("failed"); sendNotificationV2(dto.getIndividualId(), RequestType.UPDATE_MY_UIN, TemplateType.FAILURE, @@ -1091,7 +1091,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, dto.getTransactionID(), "Request for UIN update")); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { throw new ResidentServiceException(ResidentErrorCode.BASE_EXCEPTION.getErrorCode(), ResidentErrorCode.BASE_EXCEPTION.getErrorMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); @@ -1103,7 +1103,7 @@ public Tuple2 reqUinUpdate(ResidentUpdateRequestDto dto, JSONObj } finally { - if (Utilitiy.isSecureSession() && residentTransactionEntity != null) { + if (Utility.isSecureSession() && residentTransactionEntity != null) { // if the status code will come as null, it will set it as failed. if (residentTransactionEntity.getStatusCode() == null) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); @@ -1465,7 +1465,7 @@ else if (ResidentIndividialIDType.VID.toString().equals(individualIdType)) { JSONObject identityMappingJsonObject = JsonUtil.getJSONObject(mappingJsonObject, IDENTITY); String uinMapping = getDocumentName(identityMappingJsonObject, UIN); - if (Utilitiy.isSecureSession()) { + if (Utility.isSecureSession()) { demographicIdentity.put(uinMapping, uin); } String identityJsonUIN = JsonUtil.getJSONValue(demographicIdentity, uinMapping); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java index 2a93606409f..993d75eb7a7 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java @@ -53,7 +53,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.EventEnum; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -153,7 +153,7 @@ public class ResidentVidServiceImpl implements ResidentVidService { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private ResidentTransactionRepository residentTransactionRepository; @@ -204,7 +204,7 @@ public Tuple2, String> generateVidV2(BaseVidRequ String eventId = ResidentConstants.NOT_AVAILABLE; ResidentTransactionEntity residentTransactionEntity=null; try { - if(Utilitiy.isSecureSession()){ + if(Utility.isSecureSession()){ residentTransactionEntity = createResidentTransactionEntity(requestDto); if (residentTransactionEntity != null) { eventId = residentTransactionEntity.getEventId(); @@ -251,7 +251,7 @@ public Tuple2, String> generateVidV2(BaseVidRequ vidResponseDto.setMessage(notificationResponseDTO.getMessage()); responseDto.setResponse(vidResponseDto); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setRefId(utility.convertToMaskDataFormat(vidResponseDto.getVid())); residentTransactionEntity.setStatusCode(EventStatusSuccess.VID_GENERATED.name()); residentTransactionEntity.setStatusComment(EventStatusSuccess.VID_GENERATED.name()); @@ -274,7 +274,7 @@ public Tuple2, String> generateVidV2(BaseVidRequ } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to generate VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidCreationException(e.getErrorText(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -297,7 +297,7 @@ public Tuple2, String> generateVidV2(BaseVidRequ } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to generate VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidCreationException(e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -320,14 +320,14 @@ public Tuple2, String> generateVidV2(BaseVidRequ } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to generate VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidAlreadyPresentException(e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { throw e; } } finally { - if (Utilitiy.isSecureSession() && residentTransactionEntity != null) { + if (Utility.isSecureSession() && residentTransactionEntity != null) { //if the status code will come as null, it will set it as failed. if(residentTransactionEntity.getStatusCode()==null) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); @@ -453,7 +453,7 @@ public Tuple2, String> revokeVidV2(BaseVid } String eventId = ResidentConstants.NOT_AVAILABLE; ResidentTransactionEntity residentTransactionEntity = null; - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity = createResidentTransEntity(vid, indivudalId); if (residentTransactionEntity != null) { eventId = residentTransactionEntity.getEventId(); @@ -468,7 +468,7 @@ public Tuple2, String> revokeVidV2(BaseVid String idaTokenForIndividualId = identityServiceImpl.getResidentIdaToken(); String idaTokenForVid = identityServiceImpl.getIDATokenForIndividualId(vid); if(idaTokenForVid == null || !idaTokenForIndividualId.equalsIgnoreCase(idaTokenForVid)) { - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); residentTransactionRepository.save(residentTransactionEntity); throw new ResidentServiceCheckedException(ResidentErrorCode.VID_NOT_BELONG_TO_SESSION, @@ -525,7 +525,7 @@ public Tuple2, String> revokeVidV2(BaseVid } vidRevokeResponseDto.setMessage(notificationResponseDTO.getMessage()); responseDto.setResponse(vidRevokeResponseDto); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusSuccess.VID_REVOKED.name()); residentTransactionEntity.setStatusComment(EventStatusSuccess.VID_REVOKED.name()); } @@ -545,7 +545,7 @@ public Tuple2, String> revokeVidV2(BaseVid } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to revoke VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidRevocationException(e.getErrorText(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -567,7 +567,7 @@ public Tuple2, String> revokeVidV2(BaseVid } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to revoke VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidRevocationException(e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { @@ -589,14 +589,14 @@ public Tuple2, String> revokeVidV2(BaseVid } audit.setAuditRequestDto(EventEnum.getEventEnumWithValue(EventEnum.SEND_NOTIFICATION_FAILURE, requestDto.getTransactionID(), "Request to revoke VID")); - if(Utilitiy.isSecureSession()) { + if(Utility.isSecureSession()) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); throw new VidRevocationException(e.getMessage(), e, Map.of(ResidentConstants.EVENT_ID, eventId)); } else { throw e; } } finally { - if (Utilitiy.isSecureSession() && residentTransactionEntity != null) { + if (Utility.isSecureSession() && residentTransactionEntity != null) { //if the status code will come as null, it will set it as failed. if(residentTransactionEntity.getStatusCode()==null) { residentTransactionEntity.setStatusCode(EventStatusFailure.FAILED.name()); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/VerificationServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/VerificationServiceImpl.java index 81e7ec5bbd0..5cf4367408e 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/VerificationServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/VerificationServiceImpl.java @@ -18,7 +18,7 @@ import io.mosip.resident.repository.ResidentTransactionRepository; import io.mosip.resident.service.VerificationService; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; @Component public class VerificationServiceImpl implements VerificationService { @@ -30,7 +30,7 @@ public class VerificationServiceImpl implements VerificationService { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utilitiy utility; + private Utility utility; @Autowired private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java index ff30aa962bf..a8bf2413d4e 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java @@ -59,7 +59,7 @@ public class TemplateUtil { private ProxyPartnerManagementServiceImpl proxyPartnerManagementServiceImpl; @Autowired - private Utilitiy utilitiy; + private Utility utilitiy; @Autowired private ResidentServiceImpl residentService; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java similarity index 97% rename from resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java rename to resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java index d2980c7055d..1df6865cbe4 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utilitiy.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java @@ -86,9 +86,9 @@ */ @Component -public class Utilitiy { +public class Utility { - private static final Logger logger = LoggerConfiguration.logConfig(Utilitiy.class); + private static final Logger logger = LoggerConfiguration.logConfig(Utility.class); @Autowired private ResidentServiceRestClient residentServiceRestClient; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ResidentOtpServiceImplTest.java b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ResidentOtpServiceImplTest.java index d11ece501d3..86415e80d2c 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ResidentOtpServiceImplTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ResidentOtpServiceImplTest.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -64,7 +64,7 @@ public class ResidentOtpServiceImplTest { private ResidentServiceImpl residentServiceImpl; @Mock - private Utilitiy utility; + private Utility utility; @InjectMocks private ResidentOtpServiceImpl residentOtpServiceImpl; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/aspect/LoginCheckTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/aspect/LoginCheckTest.java index 279f5423613..e1c9575e79f 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/aspect/LoginCheckTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/aspect/LoginCheckTest.java @@ -24,7 +24,7 @@ import io.mosip.resident.entity.ResidentUserEntity; import io.mosip.resident.repository.ResidentUserRepository; import io.mosip.resident.service.impl.IdentityServiceImpl; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; /** * Aspect test class for login redirect API @@ -46,7 +46,7 @@ public class LoginCheckTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utilitiy utility; + private Utility utility; @Mock private HttpServletRequest request; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java index 0bc1e0ccbe7..1938dfbc7b5 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java @@ -9,7 +9,7 @@ import io.mosip.resident.service.impl.ResidentVidServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.junit.Before; import org.junit.Test; @@ -72,7 +72,7 @@ public class AcknowledgmentControllerTest { private IdAuthService idAuthService; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; private ResponseEntity responseEntity; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java index 609099417c4..e45d3c3866d 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java @@ -45,7 +45,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import reactor.util.function.Tuples; @@ -69,7 +69,7 @@ public class DownloadCardControllerTest { private Environment environment; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @MockBean private ObjectStoreHelper objectStore; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java index b9fe2264e98..593769d91db 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java @@ -12,7 +12,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.junit.Before; import org.junit.Test; @@ -87,7 +87,7 @@ public class DownloadMasterdataControllerTest { private AuditUtil auditUtil; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private Environment environment; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java index d3a18f6ca28..7f5058472a7 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java @@ -14,7 +14,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.junit.Assert; import org.junit.Before; @@ -62,7 +62,7 @@ public class GrievanceControllerTest { private Environment environment; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @MockBean private ObjectStoreHelper objectStore; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyAuditControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyAuditControllerTest.java index ce7c69da844..b263a8e64ee 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyAuditControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyAuditControllerTest.java @@ -41,7 +41,7 @@ import io.mosip.resident.service.ResidentVidService; import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; /** * Resident proxy audit controller test class. @@ -66,7 +66,7 @@ public class ProxyAuditControllerTest { private IdentityService identityService; @Mock - private Utilitiy utility; + private Utility utility; @MockBean @Qualifier("selfTokenRestTemplate") diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java index ff00499bcdd..d0710531543 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java @@ -18,7 +18,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import reactor.util.function.Tuples; @@ -98,7 +98,7 @@ public class ProxyOtpControllerTest { private AuditUtil auditUtil; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private Environment environment; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java index 3140ba5fd61..5fd9330232d 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java @@ -47,7 +47,7 @@ import io.mosip.resident.test.ResidentTestBootApplication; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; @RunWith(SpringRunner.class) @@ -87,7 +87,7 @@ public class ResidentOtpControllerTest { private UinCardRePrintService rePrintService; @MockBean - private Utilitiy utilitiy; + private Utility utilitiy; @MockBean private Utilities utilities; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java index ca08b7fa515..d196cd46ba2 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java @@ -15,7 +15,7 @@ import io.mosip.resident.service.impl.ProxyMasterdataServiceImpl; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -79,7 +79,7 @@ public class AcknowledgmentServiceTest { private ResidentServiceRestClient residentServiceRestClient; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; private byte[] result; private String eventId; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AuthTransactionCallbackServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AuthTransactionCallbackServiceTest.java index 682b96fad63..cee4e91a70d 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AuthTransactionCallbackServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AuthTransactionCallbackServiceTest.java @@ -14,7 +14,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; @@ -59,7 +59,7 @@ public class AuthTransactionCallbackServiceTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utilitiy utility; + private Utility utility; @Mock private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java index c43cf248fb7..feac1209265 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java @@ -29,7 +29,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import reactor.util.function.Tuple2; import org.junit.Before; @@ -88,7 +88,7 @@ public class DownloadCardServiceTest { private IdentityServiceImpl identityService; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java index a5becc84179..b3315a6299b 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java @@ -15,7 +15,7 @@ import io.mosip.resident.service.impl.DownLoadMasterDataServiceImpl; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -80,7 +80,7 @@ public class DownloadmasterDataServiceImplTest { private ResidentServiceRestClient residentServiceRestClient; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; private byte[] result; private String eventId; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/IdentityServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/IdentityServiceTest.java index a57fdf15667..4c02c51c677 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/IdentityServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/IdentityServiceTest.java @@ -26,7 +26,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -80,7 +80,7 @@ public class IdentityServiceTest { private AuditUtil auditUtil; @Mock - private Utilitiy utility; + private Utility utility; @Mock private CbeffUtil cbeffUtil; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/NotificationServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/NotificationServiceTest.java index a4c36e0b48d..8107f364bf3 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/NotificationServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/NotificationServiceTest.java @@ -18,7 +18,7 @@ import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.apache.commons.io.IOUtils; import org.junit.Before; @@ -63,7 +63,7 @@ public class NotificationServiceTest { private NotificationService notificationService; @Mock - private Utilitiy utility; + private Utility utility; @Mock private Utilities utilities; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/OrderCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/OrderCardServiceTest.java index 52381cf2c34..dca5df1ad30 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/OrderCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/OrderCardServiceTest.java @@ -18,7 +18,7 @@ import io.mosip.resident.service.impl.ProxyPartnerManagementServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -57,7 +57,7 @@ public class OrderCardServiceTest { private AuditUtil auditUtil; @Mock - private Utilitiy utility; + private Utility utility; @Mock private IdentityServiceImpl identityServiceImpl; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java index 79516e49ad2..376b6fc01bc 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java @@ -23,7 +23,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.junit.Before; import org.junit.Test; @@ -80,7 +80,7 @@ public class ProxyOtpServiceImpllTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock @Qualifier("selfTokenRestTemplate") diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java index 5c918df93cb..198e50d05f3 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java @@ -62,7 +62,7 @@ import io.mosip.resident.service.impl.ResidentCredentialServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import reactor.util.function.Tuple2; @RunWith(MockitoJUnitRunner.class) @@ -88,7 +88,7 @@ public class ResidentCredentialServiceTest { private ObjectMapper mapper; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private AuditUtil audit; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java index abf76b28580..8c1f593da1a 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java @@ -28,7 +28,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -99,7 +99,7 @@ public class ResidentServiceDownloadCardTest { private TemplateManager templateManager; @Mock - private Utilitiy utility; + private Utility utility; private byte[] result; private String eventId; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceRequestTypeAuthLockTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceRequestTypeAuthLockTest.java index a12679f01f2..c6b2d5c0ed4 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceRequestTypeAuthLockTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceRequestTypeAuthLockTest.java @@ -27,7 +27,7 @@ import io.mosip.resident.service.impl.ResidentServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.UINCardDownloadService; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import reactor.util.function.Tuple2; import org.json.simple.JSONObject; @@ -87,7 +87,7 @@ public class ResidentServiceRequestTypeAuthLockTest { IdentityServiceImpl identityServiceImpl; @Mock - private Utilitiy utility; + private Utility utility; @Mock ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceResUpdateTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceResUpdateTest.java index f5ebce99b60..e99245adefd 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceResUpdateTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceResUpdateTest.java @@ -72,7 +72,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; @RunWith(SpringRunner.class) public class ResidentServiceResUpdateTest { @@ -109,7 +109,7 @@ public class ResidentServiceResUpdateTest { @Mock NotificationService notificationService; @Mock - private Utilitiy utility; + private Utility utility; @Mock private Utilities utilities; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java index 3581a64efa8..50a59030392 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java @@ -11,7 +11,7 @@ import io.mosip.resident.service.impl.VerificationServiceImpl; import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.joda.time.DateTime; import org.junit.Before; @@ -51,7 +51,7 @@ public class ResidentVerificationServiceTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java index 1bb0964fec2..fba1971f862 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java @@ -62,7 +62,7 @@ import io.mosip.resident.util.AuditUtil; import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; @RunWith(MockitoJUnitRunner.class) @RefreshScope @@ -87,7 +87,7 @@ public class ResidentVidServiceTest { private ObjectMapper mapper; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private AuditUtil audit; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java index 56ff0699da3..b905f8d3478 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java @@ -16,7 +16,7 @@ import io.mosip.resident.service.impl.ProxyPartnerManagementServiceImpl; import io.mosip.resident.service.impl.ResidentServiceImpl; import io.mosip.resident.util.TemplateUtil; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import io.mosip.resident.validator.RequestValidator; import org.junit.Before; import org.junit.Test; @@ -55,7 +55,7 @@ public class TemplateUtilTest { private RequestValidator validator; @Mock - private Utilitiy utilitiy; + private Utility utilitiy; @Mock private ProxyPartnerManagementServiceImpl proxyPartnerManagementServiceImpl; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java index d157cd11aca..c029ba4243a 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/util/UtilityTest.java @@ -15,7 +15,7 @@ import io.mosip.resident.service.impl.IdentityServiceImpl; import io.mosip.resident.util.JsonUtil; import io.mosip.resident.util.ResidentServiceRestClient; -import io.mosip.resident.util.Utilitiy; +import io.mosip.resident.util.Utility; import org.apache.commons.io.IOUtils; import org.json.simple.JSONObject; import org.junit.Before; @@ -67,7 +67,7 @@ public class UtilityTest { private ResidentServiceRestClient residentServiceRestClient; @InjectMocks - private Utilitiy utility; + private Utility utility; private JSONObject identity; @@ -191,7 +191,7 @@ public void testGetMailingAttributes() throws Exception { File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = IOUtils.toString(is, "UTF-8"); - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); ResponseWrapper response = new ResponseWrapper<>(); @@ -215,7 +215,7 @@ public void testGetPreferredLanguage() throws Exception { File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = IOUtils.toString(is, "UTF-8"); - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); ResponseWrapper response = new ResponseWrapper<>(); @@ -237,7 +237,7 @@ public void testGetDefaultTemplateLanguages() throws Exception { File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = IOUtils.toString(is, "UTF-8"); - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); ResponseWrapper response = new ResponseWrapper<>(); @@ -259,7 +259,7 @@ public void testGetDataCapturedLanguages() throws Exception { File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = IOUtils.toString(is, "UTF-8"); - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); ResponseWrapper response = new ResponseWrapper<>(); @@ -302,7 +302,7 @@ public void testGetMailingAttributesJSONParsingException() throws Exception { File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = ""; - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); Map attributes = utilitySpy.getMailingAttributes("3527812406", new HashSet()); assertEquals("user@mail.com", attributes.get("email")); @@ -319,7 +319,7 @@ public void testGetMailingAttributesIOException() throws IOException, ResidentSe File idJson = new File(classLoader.getResource("IdentityMapping.json").getFile()); InputStream is = new FileInputStream(idJson); String mappingJson = IOUtils.toString(is, "UTF-8"); - Utilitiy utilitySpy = Mockito.spy(utility); + Utility utilitySpy = Mockito.spy(utility); Mockito.doReturn(mappingJson).when(utilitySpy).getMappingJson(); Mockito.doReturn(JsonUtil.getJSONObject(identity, "identity")).when(utilitySpy) .retrieveIdrepoJson(Mockito.anyString()); From c278423e4d888385cee34ff3e2b85293f5baf24a Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Wed, 18 Jan 2023 20:47:15 +0530 Subject: [PATCH 13/15] Refactored to fix utility class name --- .../controller/AcknowledgementController.java | 4 ++-- .../DownLoadMasterDataController.java | 8 +++---- .../controller/DownloadCardController.java | 4 ++-- .../controller/ResidentController.java | 4 ++-- .../impl/AcknowledgementServiceImpl.java | 4 ++-- .../impl/DownLoadMasterDataServiceImpl.java | 6 ++--- .../service/impl/DownloadCardServiceImpl.java | 24 +++++++++---------- .../service/impl/ResidentOtpServiceImpl.java | 8 +++---- .../io/mosip/resident/util/TemplateUtil.java | 18 +++++++------- .../java/io/mosip/resident/util/Utility.java | 8 +++---- .../AcknowledgmentControllerTest.java | 2 +- .../DownloadCardControllerTest.java | 4 ++-- .../DownloadMasterdataControllerTest.java | 4 ++-- .../controller/GrievanceControllerTest.java | 4 ++-- .../controller/ProxyOtpControllerTest.java | 2 +- .../controller/ResidentOtpControllerTest.java | 2 +- .../service/AcknowledgmentServiceTest.java | 4 ++-- .../test/service/DownloadCardServiceTest.java | 10 ++++---- .../DownloadmasterDataServiceImplTest.java | 4 ++-- .../service/ProxyOtpServiceImpllTest.java | 6 ++--- .../ResidentCredentialServiceTest.java | 6 ++--- .../ResidentVerificationServiceTest.java | 2 +- .../test/service/ResidentVidServiceTest.java | 4 ++-- .../resident/test/util/TemplateUtilTest.java | 2 +- 24 files changed, 72 insertions(+), 72 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java index edacf2a85e1..7e0021b9b74 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/AcknowledgementController.java @@ -60,7 +60,7 @@ public class AcknowledgementController { private TemplateUtil templateUtil; @Autowired - private Utility utilitiy; + private Utility utility; @GetMapping("/ack/download/pdf/event/{eventId}/language/{languageCode}") public ResponseEntity getAcknowledgement(@PathVariable("eventId") String eventId, @@ -93,7 +93,7 @@ public ResponseEntity getAcknowledgement(@PathVariable("eventId") String } return ResponseEntity.ok().contentType(MediaType.APPLICATION_PDF) .header("Content-Disposition", "attachment; filename=\"" + - utilitiy.getFileNameAsPerFeatureName(eventId, featureName, timeZoneOffset) + ".pdf\"") + utility.getFileNameAsPerFeatureName(eventId, featureName, timeZoneOffset) + ".pdf\"") .body(resource); } } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java index 0cf12973c03..6c19d57e4d9 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownLoadMasterDataController.java @@ -52,7 +52,7 @@ public class DownLoadMasterDataController { private AuditUtil audit; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private Environment environment; @@ -85,7 +85,7 @@ public ResponseEntity downloadRegistrationCentersByHierarchyLevel(@Reque logger.debug("downLoad file name::" + DOWNLOADABLE_REGCEN_FILENAME); logger.debug("AcknowledgementController::acknowledgement()::exit"); return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf")) - .header("Content-Disposition", "attachment; filename=\"" + utilitiy.getFileName(null, + .header("Content-Disposition", "attachment; filename=\"" + utility.getFileName(null, Objects.requireNonNull(this.environment.getProperty( ResidentConstants.DOWNLOAD_REGISTRATION_CENTRE_FILE_NAME_CONVENTION_PROPERTY)), timeZoneOffset) + ".pdf\"") .body(resource); @@ -108,7 +108,7 @@ public ResponseEntity downloadNearestRegistrationcenters(@RequestParam(n logger.debug("downLoad file name::" + DOWNLOADABLE_REGCEN_FILENAME); logger.debug("AcknowledgementController::acknowledgement()::exit"); return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf")) - .header("Content-Disposition", "attachment; filename=\"" + utilitiy.getFileName(null, + .header("Content-Disposition", "attachment; filename=\"" + utility.getFileName(null, Objects.requireNonNull(this.environment.getProperty( ResidentConstants.DOWNLOAD_NEAREST_REGISTRATION_CENTRE_FILE_NAME_CONVENTION_PROPERTY)), timeZoneOffset) + ".pdf\"") .body(resource); @@ -129,7 +129,7 @@ public ResponseEntity downloadSupportingDocsByLanguage(@RequestParam(nam logger.debug("downLoad file name::" + DOWNLOADABLE_SUPPORTING_FILENAME); logger.debug("AcknowledgementController::acknowledgement()::exit"); return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf")) - .header("Content-Disposition", "attachment; filename=\"" + utilitiy.getFileName(null, + .header("Content-Disposition", "attachment; filename=\"" + utility.getFileName(null, Objects.requireNonNull(this.environment.getProperty( ResidentConstants.DOWNLOAD_SUPPORTING_DOCUMENT_FILE_NAME_CONVENTION_PROPERTY)), timeZoneOffset) + ".pdf\"") .body(resource); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index a81a1840585..6276b1cd095 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -65,7 +65,7 @@ public class DownloadCardController { DownloadCardService downloadCardService; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private Environment environment; @@ -118,7 +118,7 @@ public ResponseEntity downloadPersonalizedCard(@Validated @RequestBody M } return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf")) .header("Content-Disposition", "attachment; filename=\"" - + utilitiy.getFileName(tupleResponse.getT2(), + + utility.getFileName(tupleResponse.getT2(), Objects.requireNonNull(this.environment.getProperty( ResidentConstants.DOWNLOAD_PERSONALIZED_CARD_NAMING_CONVENTION_PROPERTY)), timeZoneOffset) + ".pdf\"") diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index b7d13fec53c..478ba7f8dba 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -108,7 +108,7 @@ public class ResidentController { private IdentityServiceImpl identityServiceImpl; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private Environment environment; @@ -618,7 +618,7 @@ public ResponseEntity downLoadServiceHistory( audit.setAuditRequestDto(EventEnum.DOWNLOAD_SERVICE_HISTORY_SUCCESS); logger.debug("AcknowledgementController::acknowledgement()::exit"); return ResponseEntity.ok().contentType(MediaType.parseMediaType("application/pdf")) - .header("Content-Disposition", "attachment; filename=\"" + utilitiy.getFileName(null, + .header("Content-Disposition", "attachment; filename=\"" + utility.getFileName(null, Objects.requireNonNull(this.environment.getProperty( ResidentConstants.DOWNLOAD_SERVICE_HISTORY_FILE_NAME_CONVENTION_PROPERTY)), timeZoneOffset) + ".pdf\"") .body(resource); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java index 29a61d41f70..3336cab17af 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/AcknowledgementServiceImpl.java @@ -60,7 +60,7 @@ public void idTemplateManagerPostConstruct() { } @Autowired - private Utility utilitiy; + private Utility utility; @Override public byte[] getAcknowledgementPDF(String eventId, String languageCode, int timeZoneOffset) throws ResidentServiceCheckedException, IOException { @@ -84,7 +84,7 @@ public byte[] getAcknowledgementPDF(String eventId, String languageCode, int tim InputStream stream = new ByteArrayInputStream(fileText.getBytes(StandardCharsets.UTF_8)); InputStream templateValue = templateManager.merge(stream, convertMapValueFromStringToObject(templateVariables)); logger.debug("AcknowledgementServiceImpl::getAcknowledgementPDF()::exit"); - return utilitiy.signPdf(templateValue, null); + return utility.signPdf(templateValue, null); } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java index 7d64e6ddc58..6b7b1d11cbf 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownLoadMasterDataServiceImpl.java @@ -69,7 +69,7 @@ public class DownLoadMasterDataServiceImpl implements DownLoadMasterDataService private ObjectMapper mapper; @Autowired - private Utility utilitiy; + private Utility utility; private static final Logger logger = LoggerConfiguration.logConfig(ProxyMasterdataServiceImpl.class); @@ -119,7 +119,7 @@ public InputStream getRegistrationCentrePdf(String langCode, ResponseWrapper StringWriter writer = new StringWriter(); IOUtils.copy(downLoadRegCenterTemplateData, writer, "UTF-8"); - return new ByteArrayInputStream(utilitiy.signPdf(new ByteArrayInputStream(writer.toString().getBytes()), null)); + return new ByteArrayInputStream(utility.signPdf(new ByteArrayInputStream(writer.toString().getBytes()), null)); } /** @@ -152,7 +152,7 @@ public InputStream downloadSupportingDocsByLanguage(String langCode) throws Resi StringWriter writer = new StringWriter(); IOUtils.copy(supportingDocsTemplateData, writer, "UTF-8"); - return new ByteArrayInputStream(utilitiy.signPdf(new ByteArrayInputStream(writer.toString().getBytes()), null)); + return new ByteArrayInputStream(utility.signPdf(new ByteArrayInputStream(writer.toString().getBytes()), null)); } /** diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java index dd01314fff4..af105cd3dc2 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java @@ -94,7 +94,7 @@ public class DownloadCardServiceImpl implements DownloadCardService { private ResidentServiceImpl residentService; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private IdentityServiceImpl identityService; @@ -116,7 +116,7 @@ public class DownloadCardServiceImpl implements DownloadCardService { @Override public Tuple2 getDownloadCardPDF(MainRequestDTO downloadCardRequestDTOMainRequestDTO) { String rid = ""; - String eventId = utilitiy.createEventId(); + String eventId = utility.createEventId(); byte[] pdfBytes = new byte[0]; try { if (idAuthService.validateOtp(downloadCardRequestDTOMainRequestDTO.getRequest().getTransactionId(), @@ -197,14 +197,14 @@ private ResponseWrapper getCheckStatusResponse(HashMap downloadCardRequestDTOMainRequestDTO, String eventId, String status) throws ApisResourceAccessException, ResidentServiceCheckedException { - ResidentTransactionEntity residentTransactionEntity = utilitiy.createEntity(); + ResidentTransactionEntity residentTransactionEntity = utility.createEntity(); residentTransactionEntity.setEventId(eventId); residentTransactionEntity.setRequestTypeCode(RequestType.GET_MY_ID.name()); residentTransactionEntity.setRequestSummary(RequestType.GET_MY_ID.name()); residentTransactionEntity.setStatusCode(status); residentTransactionEntity.setAuthTypeCode(OTP); residentTransactionEntity.setStatusComment(String.valueOf(CARD_DOWNLOADED)); - residentTransactionEntity.setRefId(utilitiy.convertToMaskDataFormat( + residentTransactionEntity.setRefId(utility.convertToMaskDataFormat( downloadCardRequestDTOMainRequestDTO.getRequest().getIndividualId())); residentTransactionEntity.setTokenId(identityService.getIDAToken( downloadCardRequestDTOMainRequestDTO.getRequest().getIndividualId())); @@ -228,7 +228,7 @@ public Tuple2 downloadPersonalizedCard(MainRequestDTO attributeValues = getAttributeList(); if(Boolean.parseBoolean(this.environment.getProperty(ResidentConstants.IS_PASSWORD_FLAG_ENABLED))){ - password = utilitiy.getPassword(attributeValues); + password = utility.getPassword(attributeValues); } List attributes = downloadPersonalizedCardMainRequestDTO.getRequest().getAttributes(); if(attributes != null){ @@ -259,16 +259,16 @@ public Tuple2 downloadPersonalizedCard(MainRequestDTO getIndividualIdStatus(String aid) } private ResidentTransactionEntity insertDataForVidCard(String vid, String uin) throws ApisResourceAccessException, IOException { - ResidentTransactionEntity residentTransactionEntity = utilitiy.createEntity(); - residentTransactionEntity.setEventId(utilitiy.createEventId()); + ResidentTransactionEntity residentTransactionEntity = utility.createEntity(); + residentTransactionEntity.setEventId(utility.createEventId()); residentTransactionEntity.setAuthTypeCode(identityService.getResidentAuthenticationMode()); residentTransactionEntity.setRequestTypeCode(RequestType.VID_CARD_DOWNLOAD.name()); - residentTransactionEntity.setRefId(utilitiy.convertToMaskDataFormat(uin)); + residentTransactionEntity.setRefId(utility.convertToMaskDataFormat(uin)); residentTransactionEntity.setTokenId(identityService.getIDAToken(uin)); residentTransactionEntity.setStatusCode(CARD_DOWNLOADED.name()); residentTransactionEntity.setStatusComment(CARD_DOWNLOADED.name()); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java index f2dbdf25b24..34da742af0f 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentOtpServiceImpl.java @@ -60,7 +60,7 @@ public class ResidentOtpServiceImpl implements ResidentOtpService { private ResidentServiceImpl residentServiceImpl; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private ObjectMapper objectMapper; @@ -100,7 +100,7 @@ public OtpResponseDTO generateOtp(OtpRequestDTO otpRequestDTO) throws NoSuchAlgo @Override public void insertData(OtpRequestDTO otpRequestDTO) throws ResidentServiceCheckedException, NoSuchAlgorithmException, ApisResourceAccessException { ResidentTransactionEntity residentTransactionEntity = new ResidentTransactionEntity(); - residentTransactionEntity.setEventId(utilitiy.createEventId()); + residentTransactionEntity.setEventId(utility.createEventId()); residentTransactionEntity.setRequestDtimes(LocalDateTime.now()); residentTransactionEntity.setResponseDtime(LocalDateTime.now()); residentTransactionEntity.setRequestTrnId(otpRequestDTO.getTransactionID()); @@ -114,9 +114,9 @@ public void insertData(OtpRequestDTO otpRequestDTO) throws ResidentServiceChecke residentTransactionEntity.setLangCode("eng"); residentTransactionEntity.setRefIdType("UIN"); if( otpRequestDTO.getOtpChannel()!=null && otpRequestDTO.getOtpChannel().size()==1){ - residentTransactionEntity.setRefId(utilitiy.getIdForResidentTransaction(otpRequestDTO.getIndividualId(), otpRequestDTO.getOtpChannel())); + residentTransactionEntity.setRefId(utility.getIdForResidentTransaction(otpRequestDTO.getIndividualId(), otpRequestDTO.getOtpChannel())); } else{ - residentTransactionEntity.setRefId(utilitiy.getRefIdHash(otpRequestDTO.getIndividualId())); + residentTransactionEntity.setRefId(utility.getRefIdHash(otpRequestDTO.getIndividualId())); } residentTransactionEntity.setTokenId(identityServiceImpl.getIDAToken(otpRequestDTO.getIndividualId())); residentTransactionEntity.setCrBy("mosip"); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java index a8bf2413d4e..67c0ec863e6 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/TemplateUtil.java @@ -59,7 +59,7 @@ public class TemplateUtil { private ProxyPartnerManagementServiceImpl proxyPartnerManagementServiceImpl; @Autowired - private Utility utilitiy; + private Utility utility; @Autowired private ResidentServiceImpl residentService; @@ -95,9 +95,9 @@ public Map getCommonTemplateVariables(String eventId, String lan templateVariables.put(TemplateVariablesConstants.SUMMARY, replaceNullWithEmptyString( residentTransactionEntity.getRequestSummary())); templateVariables.put(TemplateVariablesConstants.TIMESTAMP, - utilitiy.formatWithOffsetForUI(timeZoneOffset, residentTransactionEntity.getCrDtimes())); - templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_REQUEST_LINK, utilitiy.createTrackServiceRequestLink(eventId)); - templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_LINK, utilitiy.createTrackServiceRequestLink(eventId)); + utility.formatWithOffsetForUI(timeZoneOffset, residentTransactionEntity.getCrDtimes())); + templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_REQUEST_LINK, utility.createTrackServiceRequestLink(eventId)); + templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_LINK, utility.createTrackServiceRequestLink(eventId)); templateVariables.put(TemplateVariablesConstants.PURPOSE, residentTransactionEntity.getPurpose()); templateVariables.put(TemplateVariablesConstants.ATTRIBUTE_LIST, replaceNullWithEmptyString( residentTransactionEntity.getAttributeList())); @@ -355,7 +355,7 @@ public Map getNotificationCommonTemplateVariables(NotificationTe templateVariables.put(TemplateVariablesConstants.TIME, getTime()); templateVariables.put(TemplateVariablesConstants.STATUS, dto.getTemplateType().getType()); if(TemplateType.FAILURE.getType().equals(dto.getTemplateType().getType())) { - templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_REQUEST_LINK, utilitiy.createTrackServiceRequestLink(dto.getEventId())); + templateVariables.put(TemplateVariablesConstants.TRACK_SERVICE_REQUEST_LINK, utility.createTrackServiceRequestLink(dto.getEventId())); } return templateVariables; } @@ -400,7 +400,7 @@ public Map getNotificationTemplateVariablesForAuthTypeLockUnlock public Map getNotificationTemplateVariablesForUpdateMyUin(NotificationTemplateVariableDTO dto) { Map templateVariables = getNotificationCommonTemplateVariables(dto); if(TemplateType.SUCCESS.getType().equals(dto.getTemplateType().getType())) { - templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utilitiy.createDownloadLink(dto.getEventId())); + templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utility.createDownloadLink(dto.getEventId())); } return templateVariables; } @@ -418,7 +418,7 @@ public Map getNotificationTemplateVariablesForGetMyId(Notificati public Map getNotificationTemplateVariablesForDownloadPersonalizedCard(NotificationTemplateVariableDTO dto) { Map templateVariables = getNotificationCommonTemplateVariables(dto); if(TemplateType.SUCCESS.getType().equals(dto.getTemplateType().getType())) { - templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utilitiy.createDownloadLink(dto.getEventId())); + templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utility.createDownloadLink(dto.getEventId())); } return templateVariables; } @@ -426,7 +426,7 @@ public Map getNotificationTemplateVariablesForDownloadPersonaliz public Map getNotificationTemplateVariablesForOrderPhysicalCard(NotificationTemplateVariableDTO dto) { Map templateVariables = getNotificationCommonTemplateVariables(dto); if(TemplateType.SUCCESS.getType().equals(dto.getTemplateType().getType())) { - templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utilitiy.createDownloadLink(dto.getEventId())); + templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utility.createDownloadLink(dto.getEventId())); } return templateVariables; } @@ -439,7 +439,7 @@ public Map getNotificationTemplateVariablesForShareCredentialWit public Map getNotificationTemplateVariablesForVidCardDownload(NotificationTemplateVariableDTO dto) { Map templateVariables = getNotificationCommonTemplateVariables(dto); if(TemplateType.SUCCESS.getType().equals(dto.getTemplateType().getType())) { - templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utilitiy.createDownloadLink(dto.getEventId())); + templateVariables.put(TemplateVariablesConstants.DOWNLOAD_LINK, utility.createDownloadLink(dto.getEventId())); } return templateVariables; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java index 1df6865cbe4..3f5641961df 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java @@ -153,7 +153,7 @@ private void loadRegProcessorIdentityJson() { @SuppressWarnings("unchecked") public JSONObject retrieveIdrepoJson(String id) throws ResidentServiceCheckedException { logger.debug(LoggerFileConstant.APPLICATIONID.toString(), LoggerFileConstant.UIN.name(), id, - "Utilitiy::retrieveIdrepoJson()::entry"); + "Utility::retrieveIdrepoJson()::entry"); List pathsegments = new ArrayList<>(); pathsegments.add(id); ResponseWrapper response = null; @@ -200,7 +200,7 @@ public JSONObject retrieveErrorCode(ResponseWrapper response, String jsonResponse = JsonUtil.writeValueAsString(response.getResponse()); JSONObject json = JsonUtil.readValue(jsonResponse, JSONObject.class); logger.debug(LoggerFileConstant.APPLICATIONID.toString(), LoggerFileConstant.UIN.name(), id, - "Utilitiy::retrieveIdrepoJson()::exit"); + "Utility::retrieveIdrepoJson()::exit"); return JsonUtil.getJSONObject(json, "identity"); } catch (IOException e) { throw new ResidentServiceCheckedException(ResidentErrorCode.RESIDENT_SYS_EXCEPTION.getErrorCode(), @@ -212,7 +212,7 @@ public JSONObject retrieveErrorCode(ResponseWrapper response, public Map getMailingAttributes(String id, Set templateLangauges) throws ResidentServiceCheckedException { logger.debug(LoggerFileConstant.APPLICATIONID.toString(), LoggerFileConstant.UIN.name(), id, - "Utilitiy::getMailingAttributes()::entry"); + "Utility::getMailingAttributes()::entry"); if(id == null || id.isEmpty()) { throw new ResidentServiceException(ResidentErrorCode.UNABLE_TO_PROCESS.getErrorCode(), ResidentErrorCode.UNABLE_TO_PROCESS.getErrorMessage() + ": individual_id is not available." ); @@ -269,7 +269,7 @@ public Map getMailingAttributes(String id, Set templateL ResidentErrorCode.RESIDENT_SYS_EXCEPTION.getErrorMessage(), e); } logger.debug(LoggerFileConstant.APPLICATIONID.toString(), LoggerFileConstant.UIN.name(), id, - "Utilitiy::getMailingAttributes()::exit"); + "Utility::getMailingAttributes()::exit"); return attributes; } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java index 1938dfbc7b5..82515cce195 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/AcknowledgmentControllerTest.java @@ -72,7 +72,7 @@ public class AcknowledgmentControllerTest { private IdAuthService idAuthService; @Mock - private Utility utilitiy; + private Utility utility; private ResponseEntity responseEntity; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java index e45d3c3866d..3458ba66bfa 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadCardControllerTest.java @@ -69,7 +69,7 @@ public class DownloadCardControllerTest { private Environment environment; @Mock - private Utility utilitiy; + private Utility utility; @MockBean private ObjectStoreHelper objectStore; @@ -116,7 +116,7 @@ public void setup() throws Exception { downloadCardRequestDTOMainRequestDTO.setId("mosip.resident.download.uin.card"); reqJson = gson.toJson(downloadCardRequestDTOMainRequestDTO); pdfbytes = "uin".getBytes(); - Mockito.when(utilitiy.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("file"); + Mockito.when(utility.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("file"); Mockito.when(environment.getProperty(Mockito.anyString())).thenReturn("property"); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java index 593769d91db..5bdc6e016cd 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/DownloadMasterdataControllerTest.java @@ -87,7 +87,7 @@ public class DownloadMasterdataControllerTest { private AuditUtil auditUtil; @Mock - private Utility utilitiy; + private Utility utility; @Mock private Environment environment; @@ -111,7 +111,7 @@ public void setup() throws Exception { downloadCardRequestDTOMainRequestDTO.setId("mosip.resident.download.uin.card"); reqJson = gson.toJson(downloadCardRequestDTOMainRequestDTO); pdfbytes = "uin".getBytes(); - Mockito.when(utilitiy.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("fileName"); + Mockito.when(utility.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("fileName"); Mockito.when(environment.getProperty(Mockito.anyString())).thenReturn("property"); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java index 7f5058472a7..20be350734f 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/GrievanceControllerTest.java @@ -62,7 +62,7 @@ public class GrievanceControllerTest { private Environment environment; @Mock - private Utility utilitiy; + private Utility utility; @MockBean private ObjectStoreHelper objectStore; @@ -109,7 +109,7 @@ public void setup() throws Exception { grievanceRequestDTOMainRequestDTO.setId("mosip.resident.grievance.ticket.request"); reqJson = gson.toJson(grievanceRequestDTOMainRequestDTO); pdfbytes = "uin".getBytes(); - Mockito.when(utilitiy.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("file"); + Mockito.when(utility.getFileName(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt())).thenReturn("file"); Mockito.when(environment.getProperty(Mockito.anyString())).thenReturn("property"); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java index d0710531543..1260870dadf 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ProxyOtpControllerTest.java @@ -98,7 +98,7 @@ public class ProxyOtpControllerTest { private AuditUtil auditUtil; @Mock - private Utility utilitiy; + private Utility utility; @Mock private Environment environment; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java index 5fd9330232d..6afa319877f 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentOtpControllerTest.java @@ -87,7 +87,7 @@ public class ResidentOtpControllerTest { private UinCardRePrintService rePrintService; @MockBean - private Utility utilitiy; + private Utility utility; @MockBean private Utilities utilities; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java index d196cd46ba2..f007b538b90 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/AcknowledgmentServiceTest.java @@ -79,7 +79,7 @@ public class AcknowledgmentServiceTest { private ResidentServiceRestClient residentServiceRestClient; @Mock - private Utility utilitiy; + private Utility utility; private byte[] result; private String eventId; @@ -125,7 +125,7 @@ public void setup() throws Exception { signatureResponseDto.setData("data"); ResponseWrapper responseWrapper = new ResponseWrapper<>(); responseWrapper.setResponse(signatureResponseDto); - Mockito.when(utilitiy.signPdf(Mockito.any(), Mockito.any())).thenReturn("data".getBytes()); + Mockito.when(utility.signPdf(Mockito.any(), Mockito.any())).thenReturn("data".getBytes()); } @Test diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java index feac1209265..800746440b5 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadCardServiceTest.java @@ -88,7 +88,7 @@ public class DownloadCardServiceTest { private IdentityServiceImpl identityService; @Mock - private Utility utilitiy; + private Utility utility; @Mock private ResidentTransactionRepository residentTransactionRepository; @@ -118,14 +118,14 @@ public void setup() throws Exception { downloadCardRequestDTOMainRequestDTO.setRequest(downloadCardRequestDTO); result = "result"; pdfbytes = result.getBytes(); - Mockito.when(utilitiy.signPdf(Mockito.any(), Mockito.any())).thenReturn(pdfbytes); + Mockito.when(utility.signPdf(Mockito.any(), Mockito.any())).thenReturn(pdfbytes); Mockito.when(idAuthService.validateOtp(Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(true); Mockito.when(utilities.getRidByIndividualId(Mockito.anyString())).thenReturn("1234567890"); Mockito.when(residentService.getUINCard(Mockito.anyString())).thenReturn(pdfbytes); Mockito.when(identityService.getIndividualIdType(Mockito.anyString())).thenReturn("UIN"); Mockito.when(identityService.getIndividualIdForAid(Mockito.anyString())).thenReturn("7841261580"); - Mockito.when(utilitiy.createEntity()).thenReturn(new ResidentTransactionEntity()); - Mockito.when(utilitiy.createEventId()).thenReturn("12345"); + Mockito.when(utility.createEntity()).thenReturn(new ResidentTransactionEntity()); + Mockito.when(utility.createEventId()).thenReturn("12345"); ResidentTransactionEntity residentTransactionEntity = new ResidentTransactionEntity(); residentTransactionEntity.setEventId("12345"); @@ -248,7 +248,7 @@ public void testDownloadPersonalizedCardPassword(){ @Test(expected = ResidentServiceException.class) public void testDownloadPersonalizedCardPasswordFailed(){ Mockito.when(environment.getProperty(ResidentConstants.IS_PASSWORD_FLAG_ENABLED)).thenReturn(String.valueOf(true)); - Mockito.when(utilitiy.getPassword(Mockito.anyList())).thenThrow( + Mockito.when(utility.getPassword(Mockito.anyList())).thenThrow( new ResidentServiceException(ResidentErrorCode.DOWNLOAD_PERSONALIZED_CARD)); Tuple2 actualResult = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO); assertEquals(pdfbytes, actualResult.getT1()); diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java index b3315a6299b..036adcd0447 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/DownloadmasterDataServiceImplTest.java @@ -80,7 +80,7 @@ public class DownloadmasterDataServiceImplTest { private ResidentServiceRestClient residentServiceRestClient; @Mock - private Utility utilitiy; + private Utility utility; private byte[] result; private String eventId; @@ -126,7 +126,7 @@ public void setup() throws Exception { signatureResponseDto.setData("data"); ResponseWrapper responseWrapper = new ResponseWrapper<>(); responseWrapper.setResponse(signatureResponseDto); - Mockito.when(utilitiy.signPdf(Mockito.any(), Mockito.any())).thenReturn("data".getBytes()); + Mockito.when(utility.signPdf(Mockito.any(), Mockito.any())).thenReturn("data".getBytes()); Mockito.when(environment.getProperty(Mockito.anyString())).thenReturn("supporting-docs-list"); langCode="eng"; hierarchyLevel=4; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java index 376b6fc01bc..810f91c0842 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ProxyOtpServiceImpllTest.java @@ -80,7 +80,7 @@ public class ProxyOtpServiceImpllTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utility utilitiy; + private Utility utility; @Mock @Qualifier("selfTokenRestTemplate") @@ -150,8 +150,8 @@ public void setup() throws ApisResourceAccessException, ResidentServiceCheckedEx MainResponseDTO response = new MainResponseDTO<>(); response.setResponse(authNResponse); responseEntity = new ResponseEntity<>(HttpStatus.OK); - Mockito.when(utilitiy.createEntity()).thenReturn(new ResidentTransactionEntity()); - Mockito.when(utilitiy.createEventId()).thenReturn("12345"); + Mockito.when(utility.createEntity()).thenReturn(new ResidentTransactionEntity()); + Mockito.when(utility.createEventId()).thenReturn("12345"); } @Test diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java index 198e50d05f3..29aa3e31a0e 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentCredentialServiceTest.java @@ -88,7 +88,7 @@ public class ResidentCredentialServiceTest { private ObjectMapper mapper; @Mock - private Utility utilitiy; + private Utility utility; @Mock private AuditUtil audit; @@ -129,9 +129,9 @@ public void setup() throws IOException, ResidentServiceCheckedException, ApisRes residentCredentialRequestDto.setConsent("Accepted"); ResidentTransactionEntity residentTransactionEntity = new ResidentTransactionEntity(); residentTransactionEntity.setEventId("e65c86f5-8929-4547-a156-9b349c29ab8b"); - when(utilitiy.createEntity()).thenReturn(residentTransactionEntity); + when(utility.createEntity()).thenReturn(residentTransactionEntity); when(identityServiceImpl.getResidentIndvidualId()).thenReturn("1234567890"); - when(utilitiy.createEventId()).thenReturn("1111111111111111"); + when(utility.createEventId()).thenReturn("1111111111111111"); } @Test diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java index 50a59030392..378269eec05 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVerificationServiceTest.java @@ -51,7 +51,7 @@ public class ResidentVerificationServiceTest { private IdentityServiceImpl identityServiceImpl; @Mock - private Utility utilitiy; + private Utility utility; @Mock private ResidentTransactionRepository residentTransactionRepository; diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java index fba1971f862..05fab9aaf48 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentVidServiceTest.java @@ -87,7 +87,7 @@ public class ResidentVidServiceTest { private ObjectMapper mapper; @Mock - private Utility utilitiy; + private Utility utility; @Mock private AuditUtil audit; @@ -145,7 +145,7 @@ public void setup() throws IOException, ResidentServiceCheckedException, ApisRes ResidentTransactionEntity residentTransactionEntity = new ResidentTransactionEntity(); residentTransactionEntity.setEventId(UUID.randomUUID().toString()); - Mockito.lenient().when(utilitiy.createEntity()).thenReturn(residentTransactionEntity); + Mockito.lenient().when(utility.createEntity()).thenReturn(residentTransactionEntity); Mockito.lenient().when(identityServiceImpl.getResidentIdaToken()).thenReturn("idaToken"); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java index b905f8d3478..f075c40075a 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/util/TemplateUtilTest.java @@ -55,7 +55,7 @@ public class TemplateUtilTest { private RequestValidator validator; @Mock - private Utility utilitiy; + private Utility utility; @Mock private ProxyPartnerManagementServiceImpl proxyPartnerManagementServiceImpl; From c416c3c49cd72221a99d80c244d3e8fa9447c969 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Thu, 19 Jan 2023 18:09:08 +0530 Subject: [PATCH 14/15] Fixed last login time offset; filename timestamp; vid generated on time; --- .../controller/ResidentController.java | 4 +- .../io/mosip/resident/dto/UserInfoDto.java | 1 - .../resident/service/ResidentService.java | 2 +- .../service/impl/ResidentServiceImpl.java | 33 +++--- .../service/impl/ResidentVidServiceImpl.java | 21 ++-- .../java/io/mosip/resident/util/Utility.java | 111 +++++++++--------- .../controller/ResidentControllerTest.java | 4 +- .../ResidentServiceDownloadCardTest.java | 6 +- 8 files changed, 95 insertions(+), 87 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java index 478ba7f8dba..ae37a6cee99 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/ResidentController.java @@ -633,11 +633,11 @@ public ResponseEntity downLoadServiceHistory( @ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(hidden = true))) }) - public ResponseWrapper userinfo() + public ResponseWrapper userinfo(@RequestHeader(name = "time-zone-offset", required = false, defaultValue = "0") int timeZoneOffset) throws ResidentServiceCheckedException, ApisResourceAccessException { logger.debug("ResidentController::getuserinfo()::entry"); String Id = identityServiceImpl.getResidentIdaToken(); - ResponseWrapper userInfoDto = residentService.getUserinfo(Id); + ResponseWrapper userInfoDto = residentService.getUserinfo(Id, timeZoneOffset); logger.debug("ResidentController::getuserinfo()::exit"); return userInfoDto; } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/dto/UserInfoDto.java b/resident/resident-service/src/main/java/io/mosip/resident/dto/UserInfoDto.java index aa8bf60cf6c..2e886ffd051 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/dto/UserInfoDto.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/dto/UserInfoDto.java @@ -1,7 +1,6 @@ package io.mosip.resident.dto; import java.time.LocalDateTime; -import java.util.List; import java.util.Map; import lombok.Data; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java index b93ec765144..abfdbaf5c7d 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java @@ -88,7 +88,7 @@ byte[] downLoadServiceHistory(ResponseWrapper String languageCode, LocalDateTime eventReqDateTime, LocalDate fromDateTime, LocalDate toDateTime, String serviceType, String statusFilter) throws ResidentServiceCheckedException, IOException; - public ResponseWrapper getUserinfo(String Id) throws ApisResourceAccessException; + public ResponseWrapper getUserinfo(String Id, int timeZoneOffset) throws ApisResourceAccessException; public String getFileName(String eventId, int timeZoneOffset); } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java index ae67c0054a8..0c0822321b3 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java @@ -1684,7 +1684,7 @@ public PageDto getServiceHistoryResponse(String sortT LocalDate toDateTime, String serviceType, String langCode, int timeZoneOffset) throws ResidentServiceCheckedException { String nativeQueryString = getDynamicNativeQueryString(sortType, idaToken, pageStart, pageFetch, statusFilter, - searchText, fromDateTime, toDateTime, serviceType); + searchText, fromDateTime, toDateTime, serviceType, timeZoneOffset); Query nativeQuery = entityManager.createNativeQuery(nativeQueryString, ResidentTransactionEntity.class); List residentTransactionEntityList = (List) nativeQuery .getResultList(); @@ -1700,24 +1700,24 @@ public PageDto getServiceHistoryResponse(String sortT public String getDynamicNativeQueryString(String sortType, String idaToken, Integer pageStart, Integer pageFetch, String statusFilter, String searchText, LocalDate fromDateTime, LocalDate toDateTime, - String serviceType) { + String serviceType, int timeZoneOffset) { String query = "SELECT * FROM resident_transaction where token_id = '" + idaToken+"'"; String dynamicQuery = ""; if (fromDateTime != null && toDateTime != null && serviceType != null && !serviceType.equalsIgnoreCase("ALL") && statusFilter != null && searchText != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime) + getServiceQuery(serviceType) + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getServiceQuery(serviceType) + getStatusFilterQuery(statusFilter) + getSearchQuery(searchText); } else if (fromDateTime != null && toDateTime != null && serviceType != null && !serviceType.equalsIgnoreCase("ALL") && statusFilter != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime) + getServiceQuery(serviceType ) + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getServiceQuery(serviceType ) + getStatusFilterQuery(statusFilter ); } else if (fromDateTime != null && toDateTime != null && serviceType != null && !serviceType.equalsIgnoreCase("ALL") && searchText != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ) + getServiceQuery(serviceType ) + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getServiceQuery(serviceType ) + getSearchQuery(searchText ); } else if (fromDateTime != null && toDateTime != null && statusFilter != null && searchText != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ) + getStatusFilterQuery(statusFilter ) + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getStatusFilterQuery(statusFilter ) + getSearchQuery(searchText ); } else if (serviceType != null && !serviceType.equalsIgnoreCase("ALL") && statusFilter != null && searchText != null) { @@ -1730,14 +1730,14 @@ public String getDynamicNativeQueryString(String sortType, String idaToken, Inte } else if (statusFilter != null && searchText != null) { dynamicQuery = getStatusFilterQuery(statusFilter ) + getSearchQuery(searchText ); } else if (fromDateTime != null && toDateTime != null && searchText != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ) + getSearchQuery(searchText ); + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getSearchQuery(searchText ); } else if (fromDateTime != null && toDateTime != null && statusFilter != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ) + getStatusFilterQuery(statusFilter ); + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getStatusFilterQuery(statusFilter ); } else if (fromDateTime != null && toDateTime != null && serviceType != null && !serviceType.equalsIgnoreCase("ALL")) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ) + getServiceQuery(serviceType ); + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset) + getServiceQuery(serviceType ); } else if (fromDateTime != null && toDateTime != null) { - dynamicQuery = getDateQuery(fromDateTime, toDateTime ); + dynamicQuery = getDateQuery(fromDateTime, toDateTime, timeZoneOffset); } else if (serviceType != null && !serviceType.equalsIgnoreCase("ALL")) { dynamicQuery = getServiceQuery(serviceType ); } else if (statusFilter != null) { @@ -1768,9 +1768,10 @@ private String getServiceQuery(String serviceType) { return " and request_type_code in (" + serviceTypeListString + ")"; } - private String getDateQuery(LocalDate fromDate, LocalDate toDate) { - LocalDateTime fromDateTime = fromDate.atStartOfDay(); - LocalDateTime toDateTime = toDate.plusDays(1).atStartOfDay(); + private String getDateQuery(LocalDate fromDate, LocalDate toDate, int timeZoneOffset) { + //Converting local time to UTC before using in db query + LocalDateTime fromDateTime = fromDate.atStartOfDay().plusMinutes(timeZoneOffset); + LocalDateTime toDateTime = toDate.plusDays(1).atStartOfDay().plusMinutes(timeZoneOffset); return " and cr_dtimes between '" + fromDateTime + "' and '" + toDateTime+ "'"; } @@ -2171,7 +2172,7 @@ public byte[] downLoadServiceHistory(ResponseWrapper getUserinfo(String Id) throws ApisResourceAccessException { + public ResponseWrapper getUserinfo(String Id, int timeZoneOffset) throws ApisResourceAccessException { String name = identityServiceImpl.getAvailableclaimValue(env.getProperty(ResidentConstants.NAME_FROM_PROFILE)); String photo = identityServiceImpl.getAvailableclaimValue(env.getProperty(IMAGE)); String email = identityServiceImpl.getAvailableclaimValue(env.getProperty(ResidentConstants.EMAIL_FROM_PROFILE)); @@ -2207,7 +2208,7 @@ public ResponseWrapper getUserinfo(String Id) throws ApisResourceAc user.setIp(response.get().getIpAddress()); user.setMachineType(response.get().getMachineType()); user.setHost(response.get().getHost()); - user.setLastLogin(response.get().getLastloginDtime()); + user.setLastLogin(utility.applyTimeZoneOffsetOnDateTime(timeZoneOffset, response.get().getLastloginDtime())); user.setPhoto(data); responseWrapper.setResponse(user); return responseWrapper; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java index 993d75eb7a7..514790912fd 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentVidServiceImpl.java @@ -81,6 +81,8 @@ @Component public class ResidentVidServiceImpl implements ResidentVidService { + private static final String GENRATED_ON_TIMESTAMP = "genratedOnTimestamp"; + private static final String EXPIRY_TIMESTAMP = "expiryTimestamp"; private static final String TRANSACTIONS_LEFT_COUNT = "transactionsLeftCount"; @@ -735,7 +737,8 @@ public ResponseWrapper>> retrieveVidsfromUin(String uin, int LinkedHashMap lhm = new LinkedHashMap(map); getMaskedVid(lhm); getRefIdHash(lhm); - normalizeExpiryTime(lhm, timeZoneOffset); + normalizeTime(EXPIRY_TIMESTAMP, lhm, timeZoneOffset); + normalizeTime(GENRATED_ON_TIMESTAMP, lhm, timeZoneOffset); return lhm; }) .collect(Collectors.toList()); @@ -748,16 +751,16 @@ public ResponseWrapper>> retrieveVidsfromUin(String uin, int } - private void normalizeExpiryTime(LinkedHashMap lhm, int timeZoneOffset) { - Object expiryTimeObj = lhm.get(EXPIRY_TIMESTAMP); - if(expiryTimeObj instanceof String) { - String expiryTime = String.valueOf(expiryTimeObj); - LocalDateTime expiryLocalDateTime = mapper.convertValue(expiryTime, LocalDateTime.class); + private void normalizeTime(String attributeName, LinkedHashMap lhm, int timeZoneOffset) { + Object timeObject = lhm.get(attributeName); + if(timeObject instanceof String) { + String timeStr = String.valueOf(timeObject); + LocalDateTime localDateTime = mapper.convertValue(timeStr, LocalDateTime.class); //For the big expiry time, assume no expiry time, so set to null - if(expiryLocalDateTime.getYear() >= 9999) { - lhm.put(EXPIRY_TIMESTAMP, null); + if(localDateTime.getYear() >= 9999) { + lhm.put(attributeName, null); } else { - lhm.put(EXPIRY_TIMESTAMP, utility.formatWithOffsetForUI(timeZoneOffset, expiryLocalDateTime)) ; + lhm.put(attributeName, utility.formatWithOffsetForUI(timeZoneOffset, localDateTime)) ; } } } diff --git a/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java index 3f5641961df..3adab9068f4 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/util/Utility.java @@ -1,7 +1,58 @@ package io.mosip.resident.util; +import static io.mosip.resident.constant.MappingJsonConstants.EMAIL; +import static io.mosip.resident.constant.MappingJsonConstants.PHONE; +import static io.mosip.resident.constant.RegistrationConstants.DATETIME_PATTERN; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.assertj.core.util.Lists; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.mvel2.MVEL; +import org.mvel2.integration.VariableResolverFactory; +import org.mvel2.integration.impl.MapVariableResolverFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.core.io.Resource; +import org.springframework.http.MediaType; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.RestTemplate; + import com.fasterxml.jackson.databind.ObjectMapper; import com.nimbusds.jose.util.IOUtils; + import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.http.RequestWrapper; import io.mosip.kernel.core.http.ResponseWrapper; @@ -30,55 +81,6 @@ import io.mosip.resident.exception.ResidentServiceException; import io.mosip.resident.repository.ResidentTransactionRepository; import io.mosip.resident.service.impl.IdentityServiceImpl; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.assertj.core.util.Lists; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.mvel2.MVEL; -import org.mvel2.integration.VariableResolverFactory; -import org.mvel2.integration.impl.MapVariableResolverFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.core.io.Resource; -import org.springframework.http.MediaType; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContext; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.HttpServerErrorException; -import org.springframework.web.client.RestTemplate; - -import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletRequest; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; - -import static io.mosip.resident.constant.MappingJsonConstants.EMAIL; -import static io.mosip.resident.constant.MappingJsonConstants.PHONE; -import static io.mosip.resident.constant.RegistrationConstants.DATETIME_PATTERN; /** * @author Girish Yarru @@ -522,16 +524,19 @@ public String getRefIdHash(String individualId) throws NoSuchAlgorithmException } private String formatDateTimeForPattern(LocalDateTime localDateTime, String dateTimePattern) { - return localDateTime.format( - DateTimeFormatter.ofPattern(dateTimePattern)); + return localDateTime == null ? null : localDateTime.format(DateTimeFormatter.ofPattern(dateTimePattern)); } public String formatWithOffsetForUI(int timeZoneOffset, LocalDateTime localDateTime) { - return formatDateTimeForPattern(localDateTime.minusMinutes(timeZoneOffset), Objects.requireNonNull(env.getProperty(ResidentConstants.UI_DATE_TIME_PATTERN))); + return formatDateTimeForPattern(applyTimeZoneOffsetOnDateTime(timeZoneOffset, localDateTime), Objects.requireNonNull(env.getProperty(ResidentConstants.UI_DATE_TIME_PATTERN))); + } + + public LocalDateTime applyTimeZoneOffsetOnDateTime(int timeZoneOffset, LocalDateTime localDateTime) { + return localDateTime == null ? null : localDateTime.minusMinutes(timeZoneOffset); //Converting UTC to local time zone } public String formatWithOffsetForFileName(int timeZoneOffset, LocalDateTime localDateTime) { - return formatDateTimeForPattern(localDateTime.minusMinutes(timeZoneOffset), Objects.requireNonNull(env.getProperty(ResidentConstants.FILENAME_DATETIME_PATTERN))); + return formatDateTimeForPattern(applyTimeZoneOffsetOnDateTime(timeZoneOffset, localDateTime), Objects.requireNonNull(env.getProperty(ResidentConstants.FILENAME_DATETIME_PATTERN))); } public String getClientIp(HttpServletRequest req) { diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java index c00b265488a..129dbac0bb9 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/controller/ResidentControllerTest.java @@ -534,8 +534,8 @@ public void testGetUserInfo() throws Exception { user.setFullName("name"); ResponseWrapper response = new ResponseWrapper<>(); response.setResponse(user); - residentController.userinfo(); - Mockito.when(residentService.getUserinfo(Mockito.any())).thenReturn(response); + residentController.userinfo(0); + Mockito.when(residentService.getUserinfo(Mockito.any(), Mockito.anyInt())).thenReturn(response); this.mockMvc.perform(get("/profile")) .andExpect(status().isOk()); } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java index 8c1f593da1a..a433e2c60d7 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/test/service/ResidentServiceDownloadCardTest.java @@ -195,7 +195,7 @@ public void testGetUserInfo() throws ApisResourceAccessException{ residentUserEntity.setIpAddress("http"); Optional response = Optional.of(residentUserEntity); Mockito.when(residentUserRepository.findById(Mockito.anyString())).thenReturn(response); - ResponseWrapper responseWrapper = residentServiceImpl.getUserinfo("123"); + ResponseWrapper responseWrapper = residentServiceImpl.getUserinfo("123", 0); assertEquals(responseWrapper.getResponse().getFullName(), responseWrapper.getResponse().getFullName()); } @@ -204,7 +204,7 @@ public void testGetUserInfoFailed() throws ApisResourceAccessException { Mockito.when(identityServiceImpl.getClaimFromIdToken(Mockito.anyString())).thenReturn("claim"); Optional response = Optional.empty(); Mockito.when(residentUserRepository.findById(Mockito.anyString())).thenReturn(response); - ResponseWrapper responseWrapper = residentServiceImpl.getUserinfo("123"); + ResponseWrapper responseWrapper = residentServiceImpl.getUserinfo("123", 0); assertEquals(responseWrapper.getResponse().getFullName(), responseWrapper.getResponse().getFullName()); } @@ -224,7 +224,7 @@ public void testDownloadServiceHistory() throws ResidentServiceCheckedException, .thenReturn(responseWrapper1); Mockito.when(templateManager.merge(any(), any())).thenReturn(new ByteArrayInputStream("pdf".getBytes())); Mockito.when(utility.signPdf(any(), any())).thenReturn("pdf".getBytes(StandardCharsets.UTF_8)); - byte[] pdfDocument = residentServiceImpl.downLoadServiceHistory(responseWrapper, "eng", + byte[] pdfDocument = residentServiceImpl.downLoadServiceHistory(responseWrapper, "eng", LocalDateTime.now(), LocalDate.now(), LocalDate.now(), String.valueOf(RequestType.DOWNLOAD_PERSONALIZED_CARD), "SUCCESS"); assertNotNull(pdfDocument); From a2c5ab466b68bf56a3a4adb79d7003eee9d98d00 Mon Sep 17 00:00:00 2001 From: Loganathan Sekar Date: Thu, 19 Jan 2023 18:52:31 +0530 Subject: [PATCH 15/15] Fix timezone for view history download request time --- .../io/mosip/resident/controller/DownloadCardController.java | 2 +- .../java/io/mosip/resident/service/DownloadCardService.java | 2 +- .../main/java/io/mosip/resident/service/ResidentService.java | 2 +- .../io/mosip/resident/service/impl/ResidentServiceImpl.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java index 6276b1cd095..e3005489246 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/controller/DownloadCardController.java @@ -111,7 +111,7 @@ public ResponseEntity downloadPersonalizedCard(@Validated @RequestBody M Map.of(ResidentConstants.HTTP_STATUS_CODE, HttpStatus.BAD_REQUEST, ResidentConstants.REQ_RES_ID, environment.getProperty(ResidentConstants.MOSIP_RESIDENT_DOWNLOAD_PERSONALIZED_CARD_ID))); } - Tuple2 tupleResponse = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO); + Tuple2 tupleResponse = downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO, timeZoneOffset); InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(tupleResponse.getT1())); if(tupleResponse.getT1().length==0){ return new ResponseEntity<>(HttpStatus.BAD_REQUEST); diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java index d8c3358a585..0908485195a 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/DownloadCardService.java @@ -20,7 +20,7 @@ public interface DownloadCardService { Tuple2 getDownloadCardPDF(MainRequestDTO downloadCardRequestDTOMainRequestDTO); - Tuple2 downloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO); + Tuple2 downloadPersonalizedCard(MainRequestDTO downloadPersonalizedCardMainRequestDTO, int timeZoneOffset); Tuple2, String> getVidCardEventId(String vid, int timeZoneOffset) throws BaseCheckedException; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java index abfdbaf5c7d..5565842ee30 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/ResidentService.java @@ -86,7 +86,7 @@ ResponseWrapper getEventStatus(String id, String eventId byte[] downLoadServiceHistory(ResponseWrapper> responseWrapper, String languageCode, LocalDateTime eventReqDateTime, LocalDate fromDateTime, LocalDate toDateTime, - String serviceType, String statusFilter) throws ResidentServiceCheckedException, IOException; + String serviceType, String statusFilter, int timeZoneOffset) throws ResidentServiceCheckedException, IOException; public ResponseWrapper getUserinfo(String Id, int timeZoneOffset) throws ApisResourceAccessException; diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java index 0c0822321b3..b68992df827 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ResidentServiceImpl.java @@ -2130,7 +2130,7 @@ public ResponseWrapper> getUnreadnotifylist(S */ public byte[] downLoadServiceHistory(ResponseWrapper> responseWrapper, String languageCode, LocalDateTime eventReqDateTime, LocalDate fromDate, LocalDate toDate, - String serviceType, String statusFilter) throws ResidentServiceCheckedException, IOException { + String serviceType, String statusFilter, int timeZoneOffset) throws ResidentServiceCheckedException, IOException { logger.debug("ResidentServiceImpl::getResidentServicePDF()::entry"); String requestProperty = this.env.getProperty(ResidentConstants.SERVICE_HISTORY_PROPERTY_TEMPLATE_TYPE_CODE); @@ -2172,7 +2172,7 @@ public byte[] downLoadServiceHistory(ResponseWrapper