From 4f6c984cae062af5bb31873acdfe8fc1a595a068 Mon Sep 17 00:00:00 2001 From: kameshsr Date: Mon, 13 Jan 2025 15:27:05 +0530 Subject: [PATCH 1/3] MOSIP-34244 Fixed get pending draft api Signed-off-by: kameshsr --- .../mosip/resident/service/impl/ProxyIdRepoServiceImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyIdRepoServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyIdRepoServiceImpl.java index c8da526db75..46c99afb291 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyIdRepoServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/ProxyIdRepoServiceImpl.java @@ -272,11 +272,9 @@ private String getDescription(ResidentTransactionEntity residentTransactionEntit private ResidentTransactionEntity getEventIdFromRid(String rid, String individualId, List attributes) throws ResidentServiceCheckedException, ApisResourceAccessException { ResidentTransactionEntity residentTransactionEntityAlreadyPresent = residentTransactionRepository.findTopByAidOrderByCrDtimesDesc(rid); - String eventId = residentTransactionEntityAlreadyPresent.getEventId(); - if(eventId == null){ + if(residentTransactionEntityAlreadyPresent == null){ ResidentTransactionEntity residentTransactionEntity = utility.createEntity(RequestType.UPDATE_MY_UIN); - eventId = utility.createEventId(); - residentTransactionEntity.setEventId(eventId); + residentTransactionEntity.setEventId(utility.createEventId()); residentTransactionEntity.setRefId(utility.convertToMaskData(individualId)); residentTransactionEntity.setIndividualId(individualId); residentTransactionEntity.setTokenId(identityServiceImpl.getResidentIdaToken()); From 6756e4338b2985db09ed5e92656f8a87408c6c61 Mon Sep 17 00:00:00 2001 From: kameshsr Date: Mon, 13 Jan 2025 15:35:49 +0530 Subject: [PATCH 2/3] MOSIP-34244 Added unit test case Signed-off-by: kameshsr --- .../service/impl/ProxyIdRepoServiceTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java index 01f20ecd0b4..cd893eda7d8 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java @@ -240,4 +240,39 @@ public void testGetPendingDraftsSuccessWithPendingDraft() throws ResidentService assertEquals("123", service.getPendingDrafts("eng").getResponse().getDrafts().get(0).getEid()); } + @Test + public void testGetPendingDraftsSuccessWithPendingDraftEmptyValue() throws ResidentServiceCheckedException, ApisResourceAccessException { + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + DraftResponseDto draftResponseDto = new DraftResponseDto(); + DraftUinResponseDto draftUinResponseDto = new DraftUinResponseDto(); + draftUinResponseDto.setAttributes(List.of("PHONE")); + draftUinResponseDto.setRid("123"); + draftUinResponseDto.setCreatedDTimes(LocalDateTime.now().toString()); + draftResponseDto.setDrafts(List.of(draftUinResponseDto)); + responseWrapper.setResponse(draftResponseDto); + ResidentTransactionEntity residentTransactionEntity = new ResidentTransactionEntity(); + residentTransactionEntity.setStatusCode(EventStatusInProgress.NEW.name()); + residentTransactionEntity.setRequestTypeCode(RequestType.UPDATE_MY_UIN.name()); + residentTransactionEntity.setEventId("123"); + + ResidentTransactionEntity residentTransactionEntity1 = new ResidentTransactionEntity(); + residentTransactionEntity1.setStatusCode(EventStatusInProgress.NEW.name()); + residentTransactionEntity1.setRequestTypeCode(RequestType.UPDATE_MY_UIN.name()); + residentTransactionEntity1.setEventId("1234"); + + when(identityServiceImpl.getResidentIndvidualIdFromSession()).thenReturn("123"); + when(identityServiceImpl.getUinForIndividualId(Mockito.anyString())).thenReturn("123"); + when(environment.getProperty(Mockito.anyString())).thenReturn("id"); + when(residentServiceRestClient.getApi(any(), (Map) any(), any())).thenReturn(responseWrapper); + when(objectMapper.convertValue((Object) any(), (Class) any())).thenReturn(draftResponseDto); + when(residentTransactionRepository.findTopByAidOrderByCrDtimesDesc(Mockito.anyString())).thenReturn(null); + when(residentTransactionRepository.findByTokenIdAndRequestTypeCodeAndStatusCode(Mockito.anyString() + , Mockito.anyString(), Mockito.anyString())).thenReturn(List.of(residentTransactionEntity, residentTransactionEntity1)); + when(utility.createEntity(any())).thenReturn(residentTransactionEntity); + when(identityServiceImpl.getResidentIdaToken()).thenReturn("123"); + when(residentService.getEventStatusCode(Mockito.anyString(), Mockito.anyString())).thenReturn(Tuples.of(EventStatusInProgress.NEW.name(), + "eng")); + assertEquals("123", service.getPendingDrafts("eng").getResponse().getDrafts().get(0).getEid()); + } + } From a8f7bc31264928f8433468f75d397142da0d4726 Mon Sep 17 00:00:00 2001 From: kameshsr Date: Mon, 13 Jan 2025 15:43:16 +0530 Subject: [PATCH 3/3] MOSIP-34244 Added unit test case Signed-off-by: kameshsr --- .../io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java index cd893eda7d8..ff5c28ea60a 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/ProxyIdRepoServiceTest.java @@ -272,7 +272,7 @@ public void testGetPendingDraftsSuccessWithPendingDraftEmptyValue() throws Resid when(identityServiceImpl.getResidentIdaToken()).thenReturn("123"); when(residentService.getEventStatusCode(Mockito.anyString(), Mockito.anyString())).thenReturn(Tuples.of(EventStatusInProgress.NEW.name(), "eng")); - assertEquals("123", service.getPendingDrafts("eng").getResponse().getDrafts().get(0).getEid()); + assertEquals(1, service.getPendingDrafts("eng").getResponse().getDrafts().size()); } }