From e1c08cf19417876d6e0b42db440570ce53fa4a08 Mon Sep 17 00:00:00 2001 From: khuddus shariff Date: Fri, 26 Jul 2024 20:41:34 +0530 Subject: [PATCH] [MOSIO-34112] Adding test cases (#1899) * [MOSIO-34112] Adding test cases Signed-off-by: khuddus shariff --------- Signed-off-by: khuddus shariff --- .../constants/BioDedupeConstants.java | 6 +- .../biodedupe/stage/BioDedupeProcessor.java | 15 +- .../stage/BioDedupeProcessorTest.java | 312 +++++++++++++++++- .../core/status/util/StatusUtil.java | 4 +- 4 files changed, 322 insertions(+), 15 deletions(-) diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/constants/BioDedupeConstants.java b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/constants/BioDedupeConstants.java index 6d1c65c5eee..0a9faaeaf33 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/constants/BioDedupeConstants.java +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/constants/BioDedupeConstants.java @@ -43,7 +43,7 @@ public class BioDedupeConstants { /** The Constant INTERNAL_ERROR. */ private static final String INTERNAL_ERROR = "Internal error occurred in bio-dedupe stage while processing for registrationId "; - public static final String ABIS_RESPONSE_MATCHING = "ABIS response Details matching, destination stage is UIN"; + public static final String BIOMETRIC_MATCH_FOUND_WITH_SELF = "Biometric match found successfully, destination stage is UIN"; - public static final String NO_MATCH_FOUND_FOR_UPDATE = "No match found, rejecting the Update packet for "; -} + public static final String BIOMETRIC_MATCH_FOUND_WITH_OTHER = "Biometric match found with other user, rejecting packet for "; +} \ No newline at end of file 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 0b4598e23a3..6c130c2de08 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 @@ -185,9 +185,7 @@ public MessageDTO process(MessageDTO object, String stageName) { newPacketPreAbisIdentification(registrationStatusDto, object); } else if (packetStatus.equalsIgnoreCase(AbisConstant.POST_ABIS_IDENTIFICATION)) { postAbisIdentification(registrationStatusDto, object, registrationType); - } - } else if (registrationType.equalsIgnoreCase(SyncTypeDto.UPDATE.toString()) || registrationType.equalsIgnoreCase(SyncTypeDto.RES_UPDATE.toString())) { String packetStatus = abisHandlerUtil.getPacketStatus(registrationStatusDto); @@ -444,9 +442,8 @@ private void postAbisIdentification(InternalRegistrationStatusDto registrationSt updatePostAbisIdentification(registrationStatusDto, object, registrationType, moduleName, matchedRegIds); }else { - sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, matchedRegIds); - - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, matchedRegIds); + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), registrationStatusDto.getRegistrationId(), BioDedupeConstants.ABIS_RESPONSE_NOT_NULL); } } @@ -489,7 +486,7 @@ private void updatePostAbisIdentification(InternalRegistrationStatusDto registra registrationStatusDto.setSubStatusCode(StatusUtil.BIO_DEDUPE_SUCCESS.getCode()); regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), registrationStatusDto.getRegistrationId(), - BioDedupeConstants.ABIS_RESPONSE_MATCHING); + BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_SELF); } else { if (biometricsUpdateSingleMatchAutoReject) { registrationStatusDto.setLatestTransactionStatusCode( @@ -497,13 +494,13 @@ private void updatePostAbisIdentification(InternalRegistrationStatusDto registra object.setIsValid(Boolean.FALSE); registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.name()); registrationStatusDto - .setStatusComment(StatusUtil.UPDATE_PACKET_BIOMETRICS_NO_MATCH_FOUND.getMessage()); + .setStatusComment(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getMessage()); registrationStatusDto - .setSubStatusCode(StatusUtil.UPDATE_PACKET_BIOMETRICS_NO_MATCH_FOUND.getCode()); + .setSubStatusCode(StatusUtil. UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER.getCode()); regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), registrationStatusDto.getRegistrationId(), - BioDedupeConstants.NO_MATCH_FOUND_FOR_UPDATE + BioDedupeConstants.BIOMETRIC_MATCH_FOUND_WITH_OTHER + registrationStatusDto.getRegistrationId()); } else { sendToManualAdjudicationStage(registrationStatusDto, object, registrationType, moduleName, 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 7efb2be83fd..0ec8c184c8b 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 @@ -25,12 +25,15 @@ import io.mosip.registration.processor.core.constant.ProviderStageName; import io.mosip.registration.processor.core.exception.PacketManagerException; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; import org.apache.commons.io.IOUtils; import org.json.simple.JSONObject; +import org.junit.Assert; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -38,6 +41,7 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.dao.DataAccessException; import org.springframework.test.util.ReflectionTestUtils; @@ -77,6 +81,8 @@ import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; import io.mosip.registration.processor.status.service.RegistrationStatusService; +import javax.validation.constraints.AssertTrue; + /** * The Class BioDedupeStageTest. */ @@ -450,11 +456,13 @@ public void testBioDeDupUpdatePacketHandlerProcessingSuccess() throws ApisResour * @throws RegistrationProcessorCheckedException */ @Test - @Ignore + @Ignore +// this test cases is being handeled in oneMatchFoundWithDifferentUinWithSingleMatchAutoRejectAsFalse() test Method. public void testBioDeDupUpdatePacketHandlerProcessingFailure() throws ApisResourceAccessException, IOException, PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { registrationStatusDto.setRegistrationId("reg1234"); 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); @@ -728,4 +736,306 @@ public void testBioDeDupUpdatePacketHandlerProcessingFailWithAutoRejectEnable() assertFalse(messageDto.getIsValid()); assertFalse(messageDto.getInternalError()); } +// One match of RID/AID found at bio dedupe stage. +// UIN of the duplicate match is same as the update packet UIN + @Test + public void oneMatchFoundWithSameUin() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + 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("9403107396"); + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); + Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.PROCESSING.name()); + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + +// 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.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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + 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); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); + assertFalse(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.REJECTED.name()); + } + +// 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 + @Test + public void oneMatchFoundWithDifferentUinWithSingleMatchAutoRejectAsFalse() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + 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", 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 UIN of duplicate matches are same as update packet UIN + @Test + public void MoreThenOneMatchFoundWithSameUin() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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("9403107396") + .thenReturn("9403107396") + .thenReturn("9403107396");; + + ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", true); + 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(RegistrationStatusCode.PROCESSING.name(),argumentCaptor.getValue().getStatusCode()); + } + +// 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 + @Test + public void moreThenOneMatchFoundWithAllSameUinExceptUpdateUin() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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") + .thenReturn("9403107397") + .thenReturn("9403107397"); + + ReflectionTestUtils.setField(bioDedupeProcessor, "biometricsUpdateSingleMatchAutoReject", true); + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(InternalRegistrationStatusDto.class); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + Mockito.verify(registrationStatusService).updateRegistrationStatus(argumentCaptor.capture(),anyString(),anyString()); + assertFalse(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.REJECTED.name()); + } + +// 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("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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("9403107394") + .thenReturn("9403107395") + .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 + @Test + public void moreThenOneMatchFoundWithDifferentUin() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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") + .thenReturn("9403107398") + .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()); + assertTrue(messageDto.getIsValid()); + 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 + + @Test + public void oneMatchFoundWithStillInProgress () throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + Mockito.when(utility.getUIn(anyString(), anyString(), any())) + .thenReturn(null); + + 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()); + Assert.assertEquals(argumentCaptor.getValue().getStatusCode(), RegistrationStatusCode.FAILED.name()); + 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 + @Test + public void moreThenOneMatchFoundWithOneIsStillInProgress () throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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") + .thenReturn(null) + .thenReturn("9403107398"); + 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 RID is in progress state & mapping is not done in repo + @Test + public void moreThenOneMatchFoundWithAllRidAreStillInProgress () throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("27847657360002520190320095011"); + 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("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + matchedRidList.add("27847657360002520190320095013"); + matchedRidList.add("27847657360002520190320095014"); + 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(null); + + 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()); + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/status/util/StatusUtil.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/status/util/StatusUtil.java index 53b752f1e3b..00dbcc6cdb8 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/status/util/StatusUtil.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/status/util/StatusUtil.java @@ -200,8 +200,8 @@ public enum StatusUtil { LOST_PACKET_MULTIPLE_MATCH_FOUND(StatusConstants.BIO_DEDUPE_MODULE_FAILED + "003", "Multiple Match was Found for the Biometrics Received"), - UPDATE_PACKET_BIOMETRICS_NO_MATCH_FOUND(StatusConstants.BIO_DEDUPE_MODULE_FAILED + "004", - "No Match was Found for the Biometrics Received"), + UPDATE_PACKET_BIOMETRICS_MATCHED_WITH_OTHER(StatusConstants.BIO_DEDUPE_MODULE_FAILED + "004", + "Biometric match found with another user"), // Biometric authentication stage BIOMETRIC_AUTHENTICATION_FAILED(StatusConstants.BIO_METRIC_AUTHENTICATION_MODULE_FAILED + "001",