Skip to content

Commit

Permalink
MOSIP-34244 Fixed get pending draft api (#1386)
Browse files Browse the repository at this point in the history
* MOSIP-34244 Fixed get pending draft api

Signed-off-by: kameshsr <[email protected]>

* MOSIP-34244 Added unit test case

Signed-off-by: kameshsr <[email protected]>

* MOSIP-34244 Added unit test case

Signed-off-by: kameshsr <[email protected]>

---------

Signed-off-by: kameshsr <[email protected]>
  • Loading branch information
kameshsr authored Jan 13, 2025
1 parent 3c8c363 commit 59dbc14
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,9 @@ private String getDescription(ResidentTransactionEntity residentTransactionEntit

private ResidentTransactionEntity getEventIdFromRid(String rid, String individualId, List<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DraftResponseDto> 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<String, String>) any(), any())).thenReturn(responseWrapper);
when(objectMapper.convertValue((Object) any(), (Class<Object>) 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(1, service.getPendingDrafts("eng").getResponse().getDrafts().size());
}

}

0 comments on commit 59dbc14

Please sign in to comment.