diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemoDedupe.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemoDedupe.java index 03348faab55..cc4d80000a8 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemoDedupe.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemoDedupe.java @@ -1,107 +1,115 @@ -package io.mosip.registration.processor.stages.demodedupe; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; -import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; -import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; -import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; -import io.mosip.registration.processor.stages.app.constants.DemoDedupeConstants; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class DemoDedupe. - * - * @author M1048358 Alok Ranjan - * @author M1048860 Kiran Raj - */ -@Component -public class DemoDedupe { - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(DemoDedupe.class); - - /** The env. */ - @Autowired - private Environment env; - - @Autowired - private RegistrationStatusService registrationStatusService; - - /** The packet info dao. */ - @Autowired - private PacketInfoDao packetInfoDao; - - /** The packet info manager. */ - @Autowired - private PacketInfoManager packetInfoManager; - - /** - * Perform dedupe. - * - * @param refId - * the ref id - * @return the list - */ - public List performDedupe(String refId) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, - "DemoDedupe::performDedupe()::entry"); - - List applicantDemoDto = packetInfoDao.findDemoById(refId); - List matchedIdsWithUin; - List demographicInfoDtos; - Set infoDtos = new HashSet<>(); - for (DemographicInfoDto demoDto : applicantDemoDto) { - infoDtos.addAll(packetInfoDao.getAllDemographicInfoDtos(demoDto.getName(), demoDto.getGenderCode(), - demoDto.getDob(), demoDto.getLangCode())); - } - matchedIdsWithUin = getAllDemographicInfoDtosWithUin(infoDtos); - demographicInfoDtos = filterByRefIdAvailability(matchedIdsWithUin); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, - "DemoDedupe::performDedupe()::exit"); - return demographicInfoDtos; - } - - private List getAllDemographicInfoDtosWithUin( - Set duplicateDemographicDtos) { - List demographicInfoDtosWithUin = new ArrayList<>(); - for (DemographicInfoDto demographicDto : duplicateDemographicDtos) { - if (registrationStatusService.checkUinAvailabilityForRid(demographicDto.getRegId())) { - demographicInfoDtosWithUin.add(demographicDto); - } - - } - return demographicInfoDtosWithUin; - } - - private List filterByRefIdAvailability(List duplicateDemographicDtos) { - List demographicInfoDtosWithRefId = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(duplicateDemographicDtos)) { - List regIds = duplicateDemographicDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); - List finalRegBioRefDtos = packetInfoManager.getBioRefIdsByRegIds(regIds); - if (CollectionUtils.isNotEmpty(finalRegBioRefDtos)) { - List finalRegIds = finalRegBioRefDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); - demographicInfoDtosWithRefId.addAll(duplicateDemographicDtos.stream().filter( - dto -> finalRegIds.contains(dto.getRegId())).collect(Collectors.toList())); - } - } - return demographicInfoDtosWithRefId; - } - - -} +package io.mosip.registration.processor.stages.demodedupe; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; +import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; +import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; +import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; +import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +/** + * The Class DemoDedupe. + * + * @author M1048358 Alok Ranjan + * @author M1048860 Kiran Raj + */ +@Component +public class DemoDedupe { + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(DemoDedupe.class); + + /** The env. */ + @Autowired + private Environment env; + + @Autowired + private RegistrationStatusService registrationStatusService; + + /** The packet info dao. */ + @Autowired + private PacketInfoDao packetInfoDao; + + /** The packet info manager. */ + @Autowired + private PacketInfoManager packetInfoManager; + + @Value("${mosip.regproc.demo.dedupe.skip-refid-check-for-infant-dedupe:false}") + private boolean skipRefIdCheckForInfantDeduplication; + + /** + * Perform dedupe. + * + * @param refId + * the ref id + * @return the list + */ + public List performDedupe(String refId, boolean isInfant) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, + "DemoDedupe::performDedupe()::entry"); + + List applicantDemoDto = packetInfoDao.findDemoById(refId); + List matchedIdsWithUin; + List demographicInfoDtos; + Set infoDtos = new HashSet<>(); + for (DemographicInfoDto demoDto : applicantDemoDto) { + infoDtos.addAll(packetInfoDao.getAllDemographicInfoDtos(demoDto.getName(), demoDto.getGenderCode(), + demoDto.getDob(), demoDto.getLangCode())); + } + matchedIdsWithUin = getAllDemographicInfoDtosWithUin(infoDtos); + if (isInfant && skipRefIdCheckForInfantDeduplication) { + demographicInfoDtos = new ArrayList<>(); + demographicInfoDtos.addAll(matchedIdsWithUin); + } else { + demographicInfoDtos = filterByRefIdAvailability(matchedIdsWithUin); + } + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), refId, + "DemoDedupe::performDedupe()::exit"); + return demographicInfoDtos; + } + + private List getAllDemographicInfoDtosWithUin( + Set duplicateDemographicDtos) { + List demographicInfoDtosWithUin = new ArrayList<>(); + for (DemographicInfoDto demographicDto : duplicateDemographicDtos) { + if (registrationStatusService.checkUinAvailabilityForRid(demographicDto.getRegId())) { + demographicInfoDtosWithUin.add(demographicDto); + } + + } + return demographicInfoDtosWithUin; + } + + private List filterByRefIdAvailability(List duplicateDemographicDtos) { + List demographicInfoDtosWithRefId = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(duplicateDemographicDtos)) { + List regIds = duplicateDemographicDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); + List finalRegBioRefDtos = packetInfoManager.getBioRefIdsByRegIds(regIds); + if (CollectionUtils.isNotEmpty(finalRegBioRefDtos)) { + List finalRegIds = finalRegBioRefDtos.stream().map(dto -> dto.getRegId()).collect(Collectors.toList()); + demographicInfoDtosWithRefId.addAll(duplicateDemographicDtos.stream().filter( + dto -> finalRegIds.contains(dto.getRegId())).collect(Collectors.toList())); + } + } + return demographicInfoDtosWithRefId; + } + + +} diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java index ea0513a1ce0..57ab3c81479 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java @@ -433,7 +433,8 @@ private List performDemoDedupe(InternalRegistrationStatusDto JsonProcessingException, DataShareException, IOException { String registrationId = registrationStatusDto.getRegistrationId(); // Potential Duplicate Ids after performing demo dedupe - List duplicateDtos = demoDedupe.performDedupe(registrationStatusDto.getRegistrationId()); + List duplicateDtos = demoDedupe.performDedupe(registrationStatusDto.getRegistrationId(), + isInfant); List matchedRidsWithoutRejected = new ArrayList<>(); List matchedRegIds; if (!duplicateDtos.isEmpty()) { diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemoDedupeTest.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemoDedupeTest.java index 3bce4ef6051..f790ec9cf35 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemoDedupeTest.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemoDedupeTest.java @@ -1,195 +1,225 @@ -package io.mosip.registrationprocessor.stages.demodedupe; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; - -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; -import org.apache.commons.io.IOUtils; -import org.assertj.core.util.Lists; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.core.env.Environment; - -import io.mosip.kernel.core.util.HMACUtils2; -import io.mosip.registration.processor.core.auth.dto.AuthResponseDTO; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; -import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; -import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; -import io.mosip.registration.processor.stages.demodedupe.DemoDedupe; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class DemoDedupeTest. - */ -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*","javax.management.*", "javax.net.ssl.*" }) -@PrepareForTest({ IOUtils.class, HMACUtils2.class }) -public class DemoDedupeTest { - - /** The packet info manager. */ - @Mock - private PacketInfoManager packetInfoManager; - - /** The packet info dao. */ - @Mock - private PacketInfoDao packetInfoDao; - - /** The input stream. */ - @Mock - private InputStream inputStream; - - - - /** The registration status service. */ - @Mock - private RegistrationStatusService registrationStatusService; - - /** The auth response DTO. */ - @Mock - AuthResponseDTO authResponseDTO = new AuthResponseDTO(); - - /** The rest client service. */ - @Mock - RegistrationProcessorRestClientService restClientService; - - /** The env. */ - @Mock - Environment env; - - /** The demo dedupe. */ - @InjectMocks - private DemoDedupe demoDedupe; - - /** - * Sets the up. - * - * @throws Exception - * the exception - */ - @Before - public void setUp() throws Exception { - - List fingers = new ArrayList<>(); - fingers.add("LEFTTHUMB"); - fingers.add("LEFTINDEX"); - fingers.add("LEFTMIDDLE"); - fingers.add("LEFTLITTLE"); - fingers.add("LEFTRING"); - fingers.add("RIGHTTHUMB"); - fingers.add("RIGHTINDEX"); - fingers.add("RIGHTMIDDLE"); - fingers.add("RIGHTLITTLE"); - fingers.add("RIGHTRING"); - - List iris = new ArrayList<>(); - iris.add("LEFTEYE"); - iris.add("RIGHTEYE"); - Mockito.when(env.getProperty("fingerType")).thenReturn("LeftThumb"); - // Mockito.when(packetInfoManager.getApplicantFingerPrintImageNameById(anyString())).thenReturn(fingers); - // Mockito.when(packetInfoManager.getApplicantIrisImageNameById(anyString())).thenReturn(iris); - - - Mockito.when(registrationStatusService.checkUinAvailabilityForRid(any())).thenReturn(true); - - byte[] data = "1234567890".getBytes(); - PowerMockito.mockStatic(IOUtils.class); - PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(data); - - // authResponseDTO.setStatus("y"); - Mockito.when(restClientService.postApi(any(), any(), any(), any(), any())) - .thenReturn(authResponseDTO); - } - - /** - * Test dedupe duplicate found. - */ - @Test - public void testDedupeDuplicateFound() { - String regId = "1234567890"; - - DemographicInfoDto dto1 = new DemographicInfoDto(); - dto1.setRegId("1234"); - DemographicInfoDto dto2 = new DemographicInfoDto(); - dto2.setRegId("5678"); - List Dtos = new ArrayList<>(); - Dtos.add(dto1); - Dtos.add(dto2); - - RegBioRefDto regBioRefDto1 = new RegBioRefDto(); - regBioRefDto1.setRegId("1234"); - RegBioRefDto regBioRefDto2 = new RegBioRefDto(); - regBioRefDto2.setRegId("5678"); - List regBioRefDtos = new ArrayList<>(); - regBioRefDtos.add(regBioRefDto1); - regBioRefDtos.add(regBioRefDto2); - - Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); - - Mockito.when(packetInfoDao.getAllDemographicInfoDtos(any(), any(), any(), any())).thenReturn(Dtos); - Mockito.when(packetInfoManager.getBioRefIdsByRegIds(anyList())).thenReturn(regBioRefDtos); - - List duplicates = demoDedupe.performDedupe(regId); - assertEquals("Test for Dedupe Duplicate found", false, duplicates.isEmpty()); - } - - /** - * Test demodedupe empty. - */ - @Test - public void testDemodedupeEmpty() { - - String regId = "1234567890"; - List Dtos = new ArrayList<>(); - - Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); - - List duplicates = demoDedupe.performDedupe(regId); - assertEquals("Test for Demo Dedupe Empty", true, duplicates.isEmpty()); - } - - @Test - public void testFilterByRefIds() { - String regId = "1234567890"; - - // 2 ids have uin - DemographicInfoDto dto1 = new DemographicInfoDto(); - dto1.setRegId("1234"); - DemographicInfoDto dto2 = new DemographicInfoDto(); - dto2.setRegId("5678"); - List Dtos = Lists.newArrayList(dto1, dto2); - - // only one id has ref id - RegBioRefDto regBioRefDto1 = new RegBioRefDto(); - regBioRefDto1.setRegId("1234"); - List regBioRefDtos = Lists.newArrayList(regBioRefDto1); - - Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); - - Mockito.when(packetInfoDao.getAllDemographicInfoDtos(any(), any(), any(), any())).thenReturn(Dtos); - Mockito.when(packetInfoManager.getBioRefIdsByRegIds(anyList())).thenReturn(regBioRefDtos); - - List duplicates = demoDedupe.performDedupe(regId); - // expected to return only one id - assertEquals("Test for Dedupe Duplicate found", 1, duplicates.size()); - } - -} +package io.mosip.registrationprocessor.stages.demodedupe; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.assertj.core.util.Lists; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.env.Environment; +import org.springframework.test.util.ReflectionTestUtils; + +import io.mosip.kernel.core.util.HMACUtils2; +import io.mosip.registration.processor.core.auth.dto.AuthResponseDTO; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.packet.dto.abis.RegBioRefDto; +import io.mosip.registration.processor.core.packet.dto.demographicinfo.DemographicInfoDto; +import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; +import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; +import io.mosip.registration.processor.stages.demodedupe.DemoDedupe; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +/** + * The Class DemoDedupeTest. + */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({ "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*","javax.management.*", "javax.net.ssl.*" }) +@PrepareForTest({ IOUtils.class, HMACUtils2.class }) +public class DemoDedupeTest { + + /** The packet info manager. */ + @Mock + private PacketInfoManager packetInfoManager; + + /** The packet info dao. */ + @Mock + private PacketInfoDao packetInfoDao; + + /** The input stream. */ + @Mock + private InputStream inputStream; + + + + /** The registration status service. */ + @Mock + private RegistrationStatusService registrationStatusService; + + /** The auth response DTO. */ + @Mock + AuthResponseDTO authResponseDTO = new AuthResponseDTO(); + + /** The rest client service. */ + @Mock + RegistrationProcessorRestClientService restClientService; + + /** The env. */ + @Mock + Environment env; + + /** The demo dedupe. */ + @InjectMocks + private DemoDedupe demoDedupe; + + /** + * Sets the up. + * + * @throws Exception + * the exception + */ + @Before + public void setUp() throws Exception { + + List fingers = new ArrayList<>(); + fingers.add("LEFTTHUMB"); + fingers.add("LEFTINDEX"); + fingers.add("LEFTMIDDLE"); + fingers.add("LEFTLITTLE"); + fingers.add("LEFTRING"); + fingers.add("RIGHTTHUMB"); + fingers.add("RIGHTINDEX"); + fingers.add("RIGHTMIDDLE"); + fingers.add("RIGHTLITTLE"); + fingers.add("RIGHTRING"); + + List iris = new ArrayList<>(); + iris.add("LEFTEYE"); + iris.add("RIGHTEYE"); + Mockito.when(env.getProperty("fingerType")).thenReturn("LeftThumb"); + // Mockito.when(packetInfoManager.getApplicantFingerPrintImageNameById(anyString())).thenReturn(fingers); + // Mockito.when(packetInfoManager.getApplicantIrisImageNameById(anyString())).thenReturn(iris); + + ReflectionTestUtils.setField(demoDedupe, "skipRefIdCheckForInfantDeduplication", false); + Mockito.when(registrationStatusService.checkUinAvailabilityForRid(any())).thenReturn(true); + + byte[] data = "1234567890".getBytes(); + PowerMockito.mockStatic(IOUtils.class); + PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(data); + + // authResponseDTO.setStatus("y"); + Mockito.when(restClientService.postApi(any(), any(), any(), any(), any())) + .thenReturn(authResponseDTO); + } + + /** + * Test dedupe duplicate found. + */ + @Test + public void testDedupeDuplicateFound() { + String regId = "1234567890"; + + DemographicInfoDto dto1 = new DemographicInfoDto(); + dto1.setRegId("1234"); + DemographicInfoDto dto2 = new DemographicInfoDto(); + dto2.setRegId("5678"); + List Dtos = new ArrayList<>(); + Dtos.add(dto1); + Dtos.add(dto2); + + RegBioRefDto regBioRefDto1 = new RegBioRefDto(); + regBioRefDto1.setRegId("1234"); + RegBioRefDto regBioRefDto2 = new RegBioRefDto(); + regBioRefDto2.setRegId("5678"); + List regBioRefDtos = new ArrayList<>(); + regBioRefDtos.add(regBioRefDto1); + regBioRefDtos.add(regBioRefDto2); + + Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); + + Mockito.when(packetInfoDao.getAllDemographicInfoDtos(any(), any(), any(), any())).thenReturn(Dtos); + Mockito.when(packetInfoManager.getBioRefIdsByRegIds(anyList())).thenReturn(regBioRefDtos); + + List duplicates = demoDedupe.performDedupe(regId, false); + assertEquals("Test for Dedupe Duplicate found", false, duplicates.isEmpty()); + } + + /** + * Test demodedupe empty. + */ + @Test + public void testDemodedupeEmpty() { + + String regId = "1234567890"; + List Dtos = new ArrayList<>(); + + Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); + + List duplicates = demoDedupe.performDedupe(regId, false); + assertEquals("Test for Demo Dedupe Empty", true, duplicates.isEmpty()); + } + + @Test + public void testFilterByRefIds() { + String regId = "1234567890"; + + // 2 ids have uin + DemographicInfoDto dto1 = new DemographicInfoDto(); + dto1.setRegId("1234"); + DemographicInfoDto dto2 = new DemographicInfoDto(); + dto2.setRegId("5678"); + List Dtos = Lists.newArrayList(dto1, dto2); + + // only one id has ref id + RegBioRefDto regBioRefDto1 = new RegBioRefDto(); + regBioRefDto1.setRegId("1234"); + List regBioRefDtos = Lists.newArrayList(regBioRefDto1); + + Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); + + Mockito.when(packetInfoDao.getAllDemographicInfoDtos(any(), any(), any(), any())).thenReturn(Dtos); + Mockito.when(packetInfoManager.getBioRefIdsByRegIds(anyList())).thenReturn(regBioRefDtos); + + List duplicates = demoDedupe.performDedupe(regId, false); + // expected to return only one id + assertEquals("Test for Dedupe Duplicate found", 1, duplicates.size()); + } + + @Test + public void testWithoutFilterByRefIds() { + String regId = "1234567890"; + ReflectionTestUtils.setField(demoDedupe, "skipRefIdCheckForInfantDeduplication", true); + // 2 ids have uin + DemographicInfoDto dto1 = new DemographicInfoDto(); + dto1.setRegId("1234"); + DemographicInfoDto dto2 = new DemographicInfoDto(); + dto2.setRegId("5678"); + List Dtos = Lists.newArrayList(dto1, dto2); + + // only one id has ref id + RegBioRefDto regBioRefDto1 = new RegBioRefDto(); + regBioRefDto1.setRegId("1234"); + List regBioRefDtos = Lists.newArrayList(regBioRefDto1); + + Mockito.when(packetInfoDao.findDemoById(regId)).thenReturn(Dtos); + + Mockito.when(packetInfoDao.getAllDemographicInfoDtos(any(), any(), any(), any())).thenReturn(Dtos); + Mockito.when(packetInfoManager.getBioRefIdsByRegIds(anyList())).thenReturn(regBioRefDtos); + + List duplicatesInfant = demoDedupe.performDedupe(regId, true); + // expected to return only two id + assertEquals("Test for Dedupe Duplicate found", 2, duplicatesInfant.size()); + + List duplicatesAdult = demoDedupe.performDedupe(regId, false); + // expected to return only one id + assertEquals("Test for Dedupe Duplicate found", 1, duplicatesAdult.size()); + } + +} diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java index 7d542280aa9..9bd97641703 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doNothing; @@ -358,7 +359,7 @@ public void testDemoDedupeNewPacketSuccess() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(emptyDuplicateDtoSet); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -398,7 +399,7 @@ public void testDemoDedupeUpdatePacketSuccess() throws Exception { .thenReturn(packetMetaInfo); PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatus); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(emptyDuplicateDtoSet); Mockito.when(packetInfoManager.getIdentityKeysAndFetchValuesFromJSON(any(),any(),any())).thenReturn(individualDemoDedupe); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); @@ -435,7 +436,7 @@ public void testDemoDedupeUpdatePacketException() throws Exception { .thenReturn(packetMetaInfo); PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatus); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(emptyDuplicateDtoSet); Mockito.when(packetInfoManager.getIdentityKeysAndFetchValuesFromJSON(any(),any(),any())).thenReturn(individualDemoDedupe); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertFalse(messageDto.getIsValid()); @@ -484,7 +485,7 @@ public void testDemoDedupeResUpdatePacketSuccess() throws Exception { .thenReturn(packetMetaInfo); PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatus); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(emptyDuplicateDtoSet); IndividualDemographicDedupe demographicData = individualDemoDedupe; demographicData.setName(null); demographicData.setDateOfBirth(null); @@ -517,7 +518,7 @@ public void testDemoDedupeSuccessNotDuplicateAfterAuth() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.findById(any())).thenReturn(entity); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); @@ -557,7 +558,7 @@ public void testDemoDedupePotentialMatchWithEmpty() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.findById(any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); @@ -601,7 +602,7 @@ public void testDemoDedupePotentialMatchSuccess() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.findById(any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); @@ -647,7 +648,7 @@ public void testDemoDedupeEmptyMatch() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.findById(any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); @@ -688,7 +689,7 @@ public void testDemoDedupePotentialMatchAbisResponseNotProcessed() throws Except PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.findById(any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); @@ -727,7 +728,7 @@ public void testDemoDedupePotentialMatchAbisResponseNotProcessed() throws Except public void testDemoDedupeFailure() throws ApisResourceAccessException, IOException, JsonProcessingException, PacketManagerException, PacketManagerException { InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(RegistrationType.NEW.toString()); Mockito.when(registrationStatusService.getRegistrationStatus(anyString())).thenReturn(registrationStatusDto); registrationStatusDto.setRetryCount(3); @@ -770,7 +771,7 @@ public void testResourceException() throws ApisResourceAccessException, IOExcept Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(emptyDuplicateDtoSet); when(utility.getDefaultSource(any(), any())).thenReturn(source); ApisResourceAccessException exp = new ApisResourceAccessException("errorMessage"); Mockito.doThrow(exp).when(utility).getApplicantAge(anyString(),anyString(), any()); @@ -790,7 +791,7 @@ public void testResourceException() throws ApisResourceAccessException, IOExcept @Test public void testFSAdapterExceptionException() throws ApisResourceAccessException, IOException, JsonProcessingException, PacketManagerException { - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); FSAdapterException exp = new FSAdapterException("errorMessage", "test"); Mockito.doThrow(exp).when(abisHandlerUtil).getPacketStatus(any()); @@ -811,7 +812,7 @@ public void testFSAdapterExceptionException() @Test public void testIllegalArgumentException() throws ApisResourceAccessException, IOException, JsonProcessingException, PacketManagerException { - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); IllegalArgumentException exp = new IllegalArgumentException("errorMessage"); Mockito.doThrow(exp).when(abisHandlerUtil).getPacketStatus(any()); registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); @@ -876,7 +877,7 @@ public void testDemoDedupeNewPacketSuccessWithDuplicates() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); List matchedRidsWithoutRejected = new ArrayList<>(); matchedRidsWithoutRejected.add("2018701130000410092018110731"); @@ -911,7 +912,7 @@ public void testDemoDedupeNewPacketSuccessWithDuplicatesWithException() throws E PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); List matchedRidsWithoutRejected = new ArrayList<>(); matchedRidsWithoutRejected.add("2018701130000410092018110731"); Mockito.when(abisHandlerUtil.removeRejectedIds(anyList())) @@ -945,7 +946,7 @@ public void testDemoDedupeNewChildPacketSuccess() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(emptyDuplicateDtoSet); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -973,7 +974,7 @@ public void testDemoDedupeDisabledSuccess() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(emptyDuplicateDtoSet); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -1000,7 +1001,7 @@ public void testDemoDedupeSuccess() throws Exception { PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(emptyDuplicateDtoSet); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -1077,7 +1078,7 @@ public void testDemoDedupeNewPacketWithDuplicatesWithNoBiometrics() throws Excep PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList()); @@ -1112,7 +1113,7 @@ public void testDemoDedupeNewPacketWithDuplicatesWithNoBiometricsWithDemodedupeS PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList()); @@ -1146,7 +1147,7 @@ public void testDemoDedupeNewPacketWithDuplicatesWithNoBiometricsWithDemodedupeR PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(),anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList()); @@ -1175,7 +1176,7 @@ public void testDemoDedupeNewInfantPacketWithDuplicatesWithNoBiometrics() throws PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList()); @@ -1207,7 +1208,7 @@ public void testDemoDedupeNewInfantPacketWithDuplicatesWithNoBiometricsWithDemod PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList()); @@ -1237,7 +1238,7 @@ public void testDemoDedupeNewInfantPacketWithDuplicatesWithNoBiometricsWithDemod PowerMockito.when(IOUtils.class, "toByteArray", inputStream).thenReturn(b); Mockito.when(registrationStatusService.getRegistrationStatus(any())).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1).thenReturn(registrationStatusDto2); Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(duplicateDtos); + Mockito.when(demoDedupe.performDedupe(anyString(), anyBoolean())).thenReturn(duplicateDtos); Mockito.when(packetManagerService.getBiometrics(any(), any(), any(), any(), any())).thenReturn(null); BiometricRecordValidationException e = new BiometricRecordValidationException("Biometirc validation failed"); Mockito.doThrow(e).when(abisHandlerUtil).validateBiometricRecord(any(), anyList());