diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java index 4e05f2c78a6..597b940c08b 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java @@ -1,23 +1,5 @@ package io.mosip.registration.processor.biodedupe.stage; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.dao.DataAccessException; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.StringUtils; import io.mosip.kernel.core.util.exception.JsonProcessingException; @@ -26,19 +8,11 @@ import io.mosip.registration.processor.biodedupe.stage.exception.CbeffNotFoundException; import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.code.DedupeSourceName; import io.mosip.registration.processor.core.code.EventId; import io.mosip.registration.processor.core.code.EventName; import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.ModuleName; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; -import io.mosip.registration.processor.core.constant.AbisConstant; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.constant.RegistrationType; +import io.mosip.registration.processor.core.code.*; +import io.mosip.registration.processor.core.constant.*; import io.mosip.registration.processor.core.exception.ApisResourceAccessException; import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException; import io.mosip.registration.processor.core.exception.PacketManagerException; @@ -67,6 +41,17 @@ import io.mosip.registration.processor.status.dto.RegistrationStatusDto; import io.mosip.registration.processor.status.dto.SyncTypeDto; import io.mosip.registration.processor.status.service.RegistrationStatusService; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.dao.DataAccessException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.IOException; +import java.util.*; /** * The Class BioDedupeProcessor. @@ -419,6 +404,10 @@ private void postAbisIdentification(InternalRegistrationStatusDto registrationSt io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { String moduleId = ""; String moduleName = ModuleName.BIO_DEDUPE.toString(); + /* This method returns combination of below RIDs : + - RIDs which are in PROCESSING state (Except current packet RID) + - RIDs (For which UIN is generated and it reached to RID repo) associated with UINs other than current packet UIN i.e it removes the RIDs which are associated with current packet UIN. + */ Set matchedRegIds = abisHandlerUtil.getUniqueRegIds(registrationStatusDto.getRegistrationId(), registrationType, registrationStatusDto.getIteration(), registrationStatusDto.getWorkflowInstanceId(), ProviderStageName.BIO_DEDUPE); ArrayList matchedRegIdsList = new ArrayList(matchedRegIds); @@ -456,7 +445,6 @@ private void updatePostAbisIdentification(InternalRegistrationStatusDto registra boolean sendToManualAdjudication = false; for(String matchedRegistrationId:matchedRegIds) { String uin = idRepoService.getUinByRid(matchedRegistrationId, utilities.getGetRegProcessorDemographicIdentity()); - // TODO need to check this condition is necessary if (StringUtils.isEmpty(uin)) { InternalRegistrationStatusDto matchedRegistrationStatusDto = registrationStatusService .getRegistrationStatus(matchedRegistrationId, null, null, null); @@ -477,42 +465,25 @@ private void updatePostAbisIdentification(InternalRegistrationStatusDto registra sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, matchedRegIds); } else { - Optional optionalMatchedUin = uniqueUins.stream().findFirst(); - String matchedUIN = optionalMatchedUin.get(); - String updateUin = utilities.getUIn(registrationStatusDto.getRegistrationId(), registrationType, - ProviderStageName.BIO_AUTH); - if (StringUtils.equals(matchedUIN, updateUin)) { - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.SUCCESS.toString()); - object.setIsValid(Boolean.TRUE); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); - registrationStatusDto.setStatusComment(StatusUtil.BIO_DEDUPE_SUCCESS.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.BIO_DEDUPE_SUCCESS.getCode()); - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), registrationStatusDto.getRegistrationId(), - BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_SELF); - } else { - if (biometricsUpdateSingleMatchAutoReject) { - registrationStatusDto.setLatestTransactionStatusCode( - RegistrationTransactionStatusCode.FAILED.toString()); - object.setIsValid(Boolean.FALSE); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.name()); - registrationStatusDto - .setStatusComment(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getMessage()); - registrationStatusDto - .setSubStatusCode(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getCode()); - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), - registrationStatusDto.getRegistrationId(), - BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_OTHER - + registrationStatusDto.getRegistrationId()); - } else { - sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, - matchedRegIds); - } - - } - } + if (biometricsUpdateSingleMatchAutoReject) { + registrationStatusDto.setLatestTransactionStatusCode( + RegistrationTransactionStatusCode.FAILED.toString()); + object.setIsValid(Boolean.FALSE); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.name()); + registrationStatusDto + .setStatusComment(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getMessage()); + registrationStatusDto + .setSubStatusCode(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getCode()); + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), + registrationStatusDto.getRegistrationId(), + BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_OTHER + + registrationStatusDto.getRegistrationId()); + } else { + sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, + matchedRegIds); + } + } } private void sendToManualAdjudicationStage(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object, diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java index ce97e9646df..896356b376a 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java @@ -695,61 +695,20 @@ public void testApisResourceAccessException() throws Exception { assertTrue(messageDto.getInternalError()); } - @Test - public void testBioDeDupUpdatePacketHandlerProcessingSuccessWithAutoRejectEnable() - throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, - io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("UPDATE"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(), any(), any(), any())) - .thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - when(idRepoService.getUinByRid(any(), any())).thenReturn("9403107397"); - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("9403107397"); - ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", true); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } + /* use case 1 -> No match of RID/AID found in bio dedupe: + This use case is handled in noMatchedRidFound(). - @Test - public void testBioDeDupUpdatePacketHandlerProcessingFailWithAutoRejectEnable() - throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, - io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("UPDATE"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(), any(), any(), any())) - .thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + use case 2 -> One match of RID/AID found at bio dedupe stage. UIN of the duplicate match is same as the update packet UIN + This use case is handled in noMatchedRidFound() because abisHandlerUtil.getUniqueRegIds() will + return the empty matched rid list because it rid's associated with current packet. - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - when(idRepoService.getUinByRid(any(), any())).thenReturn("9403107397"); - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("9403107396"); - ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", true); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertFalse(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - -// 1)No match of RID/AID found in bio dedupe: -// This usecase is handeled in oneMatchFoundWithSameUin(). because empty matched rid list handeled in it. - -// 2)One match of RID/AID found at bio dedupe stage. UIN of the duplicate match is same as the update packet UIN -// This usecase is handeled in oneMatchFoundWithSameUin() because abisHandlerUtil.getUniqueRegIds() will return the empty matched rid list if update uin is same as Matched rid. - -// 4) More than one match of RID/AID found at bio dedupe stage, all UIN of duplicate matches are same as update packet UIN: -// This usecase is handeled in oneMatchFoundWithSameUin() because abisHandlerUtil.getUniqueRegIds() will return the empty matched rid list if update uin is same as Matched rid. - -// More than one match of RID/AID found at bio dedupe stage, all duplicate matches have the same UIN but, they does not matches with update packet UIN -// This usecase is handeled in oneMatchFoundWithDifferentUinWithMatchAutoRejecAsTrue(). Because abisHandlerUtil.getUniqueRegIds() will return the latest match for a particular uin. + use case 4 -> More than one match of RID/AID found at bio dedupe stage, all UIN of duplicate matches are same as update packet UIN: + This use case is handled in noMatchedRidFound() because abisHandlerUtil.getUniqueRegIds() will + return the empty matched rid list because it rid's associated with current packet. + */ @Test - public void oneMatchFoundWithSameUin() throws ApisResourceAccessException, IOException, + public void noMatchedRidFound() throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { registrationStatusDto.setRegistrationId("27847657360002520190320095011"); registrationStatusDto.setRegistrationType("UPDATE"); @@ -757,7 +716,6 @@ public void oneMatchFoundWithSameUin() throws ApisResourceAccessException, IOExc Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); Set matchedRidList = new HashSet<>(); -// matchedRidList is empty Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); @@ -766,21 +724,26 @@ public void oneMatchFoundWithSameUin() throws ApisResourceAccessException, IOExc assertTrue(messageDto.getIsValid()); assertFalse(messageDto.getInternalError()); } + /* + (when registration.processor.biometrics-update.single-match.auto-reject.enabled = true) + use case 3 -> One match of RID/AID found at bio dedupe, but UIN of the duplicate match is different from update packet UIN when AutoReject is True + + use case 5 -> More than one match of RID/AID found at bio dedupe stage, all duplicate matches have the same UIN but, they does not match with update packet UIN + This use case is handled in oneMatchFoundWithDifferentUinWithMatchAutoRejecAsTrue() + because abisHandlerUtil.getUniqueRegIds() will return the latest match for a particular uin. + */ -// 3) One match of RID/AID found at bio dedupe, -// but UIN of the duplicate match is different from update packet UIN when AutoReject is True @Test public void oneMatchFoundWithDifferentUinWithMatchAutoRejecAsTrue() throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + registrationStatusDto.setRegistrationId("27847657360002520190320095012"); registrationStatusDto.setRegistrationType("UPDATE"); registrationStatusDto.setStatusCode("PROCESSING"); Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095011"); Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); -// Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("9403107396"); Mockito.when(idRepoService.getUinByRid(anyString(),any())).thenReturn("9403107397"); ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", true); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); @@ -790,19 +753,24 @@ public void oneMatchFoundWithDifferentUinWithMatchAutoRejecAsTrue() throws ApisR assertFalse(messageDto.getInternalError()); Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.REJECTED.name()); } + /* + (when registration.processor.biometrics-update.single-match.auto-reject.enabled = false) + use case 3 -> One match of RID/AID found at bio dedupe, but UIN of the duplicate match is different from update packet UIN when AutoReject is True -// One match of RID/AID found at bio dedupe, -// but UIN of the duplicate match is different from update packet UIN with auto rejection is false + use case 5 -> More than one match of RID/AID found at bio dedupe stage, all duplicate matches have the same UIN but, they does not match with update packet UIN. + This use case is handled in oneMatchFoundWithDifferentUinWithMatchAutoRejecAsTrue(). + Because abisHandlerUtil.getUniqueRegIds() will return the latest match for a particular uin. + */ @Test public void oneMatchFoundWithDifferentUinWithSingleMatchAutoRejectAsFalse() throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + registrationStatusDto.setRegistrationId("27847657360002520190320095012"); registrationStatusDto.setRegistrationType("UPDATE"); registrationStatusDto.setStatusCode("PROCESSING"); Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095011"); Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); Mockito.when(idRepoService.getUinByRid(anyString(),any())).thenReturn("9403107397"); ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", false); @@ -814,37 +782,17 @@ public void oneMatchFoundWithDifferentUinWithSingleMatchAutoRejectAsFalse() thro Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.FAILED.name()); } + /* + use case 6 -> More than one match of RID/AID found at bio dedupe stage, all duplicate matches possess different UINs. + Among that one UIN matches with update packet UIN + This is not a valid use case. because abisHandlerUtil.getUniqueRegIds() will not return rid's associated with current packet. + */ -// More than one match of RID/AID found at bio dedupe stage, -// all duplicate matches possess different UINs. Among that one UIN matches with update packet UIN - @Test - public void moreThenOneMatchFoundWithDifferentUinOnlyOneMatches() throws ApisResourceAccessException, IOException, - PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("27847657360002520190320095014"); - registrationStatusDto.setRegistrationType("UPDATE"); - registrationStatusDto.setStatusCode("PROCESSING"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())) - .thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095013"); - matchedRidList.add("27847657360002520190320095012"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - Mockito.when(idRepoService.getUinByRid(anyString(),any())) - .thenReturn("9403107394") - .thenReturn("9403107396"); - - ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", false); - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.FAILED.name()); - } -// More than one match of RID/AID found at bio dedupe stage, -// all duplicate matches possess different UINs. Among that no UIN matches with update packet UIN + /* + use case 7 -> More than one match of RID/AID found at bio dedupe stage, all duplicate matches possess different UINs. + Among that no UIN matches with update packet UIN. + abisHandlerUtil.getUniqueRegIds() returns the latest rids associated with uin's other than current packet uin. + */ @Test public void moreThenOneMatchFoundWithDifferentUin() throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { @@ -862,9 +810,6 @@ public void moreThenOneMatchFoundWithDifferentUin() throws ApisResourceAccessExc Mockito.when(idRepoService.getUinByRid(anyString(),any())) .thenReturn("9403107397") .thenReturn("9403107399"); - - ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", false); - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); @@ -872,24 +817,29 @@ public void moreThenOneMatchFoundWithDifferentUin() throws ApisResourceAccessExc assertFalse(messageDto.getInternalError()); Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.FAILED.name()); } - -// One match of RID/AID found at bio dedupe stage, -// found AID/RID is in progress status and RID & UIN mapping is not done - + /* + use case 8 -> One match of RID/AID found at bio dedupe stage, found AID/RID is in progress status and RID & UIN mapping is not done + abisHandlerUtil.getUniqueRegIds() returns RID which are in PROCESSING state (Except Update packet RID) + */ @Test public void oneMatchFoundWithStillInProgress () throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { registrationStatusDto.setRegistrationId("27847657360002520190320095012"); registrationStatusDto.setRegistrationType("UPDATE"); registrationStatusDto.setStatusCode("PROCESSING"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + //This is existing rid which is in PROCESSING status. + InternalRegistrationStatusDto existingRegistrationStatusDto=new InternalRegistrationStatusDto(); + existingRegistrationStatusDto.setRegistrationId("27847657360002520190320095011"); + existingRegistrationStatusDto.setStatusCode("PROCESSING"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())) + .thenReturn(registrationStatusDto). + thenReturn(existingRegistrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())) .thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095011"); //this rid is in processing state Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", false); + Mockito.when(idRepoService.getUinByRid(anyString(),any())).thenReturn(null); ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); @@ -897,23 +847,31 @@ public void oneMatchFoundWithStillInProgress () throws ApisResourceAccessExcepti assertTrue(messageDto.getIsValid()); assertFalse(messageDto.getInternalError()); } -// More than one match of RID/AID found at bio dedupe stage, -// Among them one of the RID is in progress state & mapping is not done in repo + + /* + use case 9 -> More than one match of RID/AID found at bio dedupe stage, Among them one of the RID is in progress state & mapping is not done in repo. + abisHandlerUtil.getUniqueRegIds() returns RIDs (For which UIN is generated and it reached to RID repo) other than update packet UIN + and rid's in PROCESSING state (Except Update packet RID) + */ @Test public void moreThenOneMatchFoundWithOneIsStillInProgress () throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { registrationStatusDto.setRegistrationId("27847657360002520190320095014"); registrationStatusDto.setRegistrationType("UPDATE"); registrationStatusDto.setStatusCode("PROCESSING"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + //This is existing rid which is in PROCESSING status. + InternalRegistrationStatusDto existingRegistrationStatusDto=new InternalRegistrationStatusDto(); + existingRegistrationStatusDto.setRegistrationId("27847657360002520190320095013"); + existingRegistrationStatusDto.setStatusCode("PROCESSING"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())) + .thenReturn(registrationStatusDto). + thenReturn(existingRegistrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())) .thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095013"); matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - Mockito.when(idRepoService.getUinByRid(anyString(),any())) .thenReturn("9403107397") .thenReturn(null); @@ -925,18 +883,31 @@ public void moreThenOneMatchFoundWithOneIsStillInProgress () throws ApisResource Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.FAILED.name()); } -// More than one match of RID/AID found at bio dedupe stage, -// All RID is in progress state & mapping is not done in repo + /* + use case 10 -> More than one match of RID/AID found at bio dedupe stage, All RID is in progress state & mapping is not done in repo. + abisHandlerUtil.getUniqueRegIds() returns RIDs (For which UIN is generated and it reached to RID repo) other than update packet UIN + and rid's in PROCESSING state (Except Update packet RID) + */ @Test public void moreThenOneMatchFoundWithAllRidAreStillInProgress () throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { registrationStatusDto.setRegistrationId("27847657360002520190320095014"); registrationStatusDto.setRegistrationType("UPDATE"); registrationStatusDto.setStatusCode("PROCESSING"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + //This is existing rid which is in PROCESSING status. + InternalRegistrationStatusDto existingRegistrationStatusDto1=new InternalRegistrationStatusDto(); + existingRegistrationStatusDto1.setRegistrationId("27847657360002520190320095013"); + existingRegistrationStatusDto1.setStatusCode("PROCESSING"); + //This is existing rid which is in PROCESSING status. + InternalRegistrationStatusDto existingRegistrationStatusDto2=new InternalRegistrationStatusDto(); + existingRegistrationStatusDto1.setRegistrationId("27847657360002520190320095012"); + existingRegistrationStatusDto1.setStatusCode("PROCESSING"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())) + .thenReturn(registrationStatusDto) + .thenReturn(existingRegistrationStatusDto1) + .thenReturn(existingRegistrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())) .thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); matchedRidList.add("27847657360002520190320095013"); matchedRidList.add("27847657360002520190320095012");