Skip to content

Commit 7981de9

Browse files
Merge pull request #1819 from Khuddusshariff0022/develop-MOSIP-28440 (#1838)
[Mosip-28440] changes to compare the biometric records only with the … Signed-off-by: khuddus shariff <khuddusshariff0022@gmail.com> Co-authored-by: Vishwa <visu.vs1@gmail.com>
1 parent 92a0974 commit 7981de9

File tree

4 files changed

+148
-140
lines changed

4 files changed

+148
-140
lines changed

registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/dao/PacketInfoDao.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.List;
66
import java.util.Map;
77

8+
import io.mosip.registration.processor.status.entity.RegistrationStatusEntity;
89
import org.springframework.beans.factory.annotation.Autowired;
910
import org.springframework.stereotype.Component;
1011

@@ -592,12 +593,10 @@ public List<String> getProcessedOrProcessingRegIds(List<String> matchedRegIds, L
592593
* the matched reg ids
593594
* @param statusCode1
594595
* the status code
595-
* @param statusCode2
596-
* the status code
597596
* @return the processed or processing reg ids
598597
*/
599-
public List<String> getWithoutStatusCodes(List<String> matchedRegIds, String statusCode1, String statusCode2) {
600-
return registrationRepositary.getWithoutStatusCodes(matchedRegIds, "REJECTED", "PROCESSED");
598+
public List<RegistrationStatusEntity> getWithoutStatusCode(List<String> matchedRegIds, String statusCode) {
599+
return registrationRepositary.getWithoutStatusCode(matchedRegIds, statusCode);
601600
}
602601

603602
/**

registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtil.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import io.mosip.registration.processor.core.code.AbisStatusCode;
1414
import io.mosip.registration.processor.core.constant.ProviderStageName;
1515
import io.mosip.registration.processor.core.exception.PacketManagerException;
16+
import io.mosip.registration.processor.status.code.RegistrationStatusCode;
17+
import io.mosip.registration.processor.status.entity.RegistrationStatusEntity;
1618
import org.springframework.beans.factory.annotation.Autowired;
1719
import org.springframework.stereotype.Component;
1820
import org.springframework.util.CollectionUtils;
@@ -99,15 +101,26 @@ public Set<String> getUniqueRegIds(String registrationId, String registrationTyp
99101
if (!CollectionUtils.isEmpty(machedRefIds)) {
100102
List<String> matchedRegIds = packetInfoDao.getAbisRefRegIdsByMatchedRefIds(machedRefIds);
101103
if (!CollectionUtils.isEmpty(matchedRegIds)) {
102-
List<String> processingRegIds = packetInfoDao.getWithoutStatusCodes(matchedRegIds,
103-
RegistrationTransactionStatusCode.REJECTED.toString(), RegistrationTransactionStatusCode.PROCESSED.toString());
104-
List<String> statusList=new ArrayList<>();
105-
statusList.add(RegistrationTransactionStatusCode.PROCESSED.toString());
106-
statusList.add(RegistrationTransactionStatusCode.PROCESSING.toString());
107-
List<String> processedRegIds = packetInfoDao.getProcessedOrProcessingRegIds(matchedRegIds,
108-
statusList);
109-
uniqueRIDs = getUniqueRegIds(processedRegIds, registrationId, registrationType, stageName);
104+
List<RegistrationStatusEntity> matchedRegistrationStatusEntities = packetInfoDao
105+
.getWithoutStatusCode(matchedRegIds,
106+
RegistrationStatusCode.REJECTED.toString());
107+
List<RegistrationStatusEntity> processingRegistrationStatusEntities = matchedRegistrationStatusEntities
108+
.stream()
109+
.filter(e -> RegistrationStatusCode.PROCESSING.toString().equals(e.getStatusCode()))
110+
.collect(Collectors.toList());
111+
List<String> processingRegIds = processingRegistrationStatusEntities.stream()
112+
.map(RegistrationStatusEntity::getRegId)
113+
.collect(Collectors.toList());
114+
List<String> matchedProcessedRegIds = matchedRegistrationStatusEntities.stream()
115+
.map(RegistrationStatusEntity::getRegId).collect(Collectors.toList());
110116
uniqueRIDs.addAll(processingRegIds);
117+
Set<String> processedRegIds = getUniqueRegIds(matchedProcessedRegIds, registrationId,
118+
registrationType,
119+
stageName);
120+
for(String rid:processedRegIds) {
121+
if(!uniqueRIDs.contains(rid))
122+
uniqueRIDs.add(rid);
123+
}
111124
}
112125
}
113126
}

registration-processor/registration-processor-info-storage-service/src/test/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtilTest.java

Lines changed: 122 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao;
1616
import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto;
1717
import io.mosip.registration.processor.packet.storage.mapper.PacketInfoMapper;
18+
import io.mosip.registration.processor.status.code.RegistrationStatusCode;
19+
import io.mosip.registration.processor.status.entity.RegistrationStatusEntity;
1820
import org.assertj.core.util.Lists;
1921
import org.junit.Before;
2022
import org.junit.Test;
@@ -45,129 +47,125 @@
4547
@PowerMockIgnore({ "javax.management.*", "javax.net.ssl.*","com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*" })
4648
public class ABISHandlerUtilTest {
4749

48-
private static final String registrationId = "10002100820001420210108085956";
49-
private static final String registrationType = "NEW";
50-
private static final String latestTransactionId = "123-456-789";
51-
List<String> matchedRids = new ArrayList<>();
52-
53-
54-
@InjectMocks
55-
private ABISHandlerUtil abisHandlerUtil;
56-
57-
@Mock
58-
private Utilities utilities;
59-
60-
@Mock
61-
private PacketInfoManager<Identity, ApplicantInfoDto> packetInfoManager;
62-
63-
@Mock
64-
private PacketInfoDao packetInfoDao;
65-
66-
@Mock
67-
private IdRepoService idRepoService;
68-
69-
List<String> lst=new ArrayList<>();
70-
71-
@Before
72-
public void setup() throws Exception {
73-
MockitoAnnotations.initMocks(this);
74-
when(utilities.getLatestTransactionId(any(),any(),anyInt(), any())).thenReturn(latestTransactionId);
75-
76-
List<String> regBioRefIds = new ArrayList<>();
77-
regBioRefIds.add("cf1c941a-142c-44f1-9543-4606b4a7884e");
78-
79-
when(packetInfoDao.getAbisRefIdByWorkflowInstanceId(any())).thenReturn(regBioRefIds);
80-
when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn(new String());
81-
82-
List<String> inprogressMatchedIds = new ArrayList<>();
83-
inprogressMatchedIds.add("10002100820001420210108085100");
84-
inprogressMatchedIds.add("10002100820001420210108085101");
85-
inprogressMatchedIds.add("10002100820001420210108085102");
86-
87-
List<String> processedMatchedIds = new ArrayList<>();
88-
processedMatchedIds.add("10002100820001420210108085103");
89-
processedMatchedIds.add("10002100820001420210108085104");
90-
91-
matchedRids.addAll(inprogressMatchedIds);
92-
matchedRids.addAll(processedMatchedIds);
93-
94-
List<AbisResponseDto> abisResponseDtoList = new ArrayList<>();
95-
matchedRids.forEach(matchedRid -> {
96-
AbisResponseDto abisResponseDto = new AbisResponseDto();
97-
abisResponseDto.setId(matchedRid);
98-
abisResponseDtoList.add(abisResponseDto);
99-
});
100-
101-
102-
lst.add(RegistrationTransactionStatusCode.PROCESSED.toString());lst.add(RegistrationTransactionStatusCode.PROCESSING.toString());
103-
104-
105-
when(packetInfoManager.getAbisResponseRecords(regBioRefIds.get(0),
106-
latestTransactionId, AbisConstant.IDENTIFY)).thenReturn(abisResponseDtoList);
107-
108-
List<AbisResponseDetDto> abisResponseDetDtoList = new ArrayList<>();
109-
110-
matchedRids.forEach(matchedRid -> {
111-
AbisResponseDetDto abisResponseDto = new AbisResponseDetDto();
112-
abisResponseDto.setMatchedBioRefId(matchedRid);
113-
abisResponseDetDtoList.add(abisResponseDto);
114-
});
115-
for (AbisResponseDetDto dto : abisResponseDetDtoList) {
116-
AbisResponseDetDto responseDetDto = new AbisResponseDetDto();
117-
responseDetDto.setMatchedBioRefId(dto.getMatchedBioRefId());
118-
when(packetInfoManager.getAbisResponseDetails(dto.getMatchedBioRefId())).thenReturn(Lists.newArrayList(responseDetDto));
119-
}
120-
121-
when(packetInfoDao.getAbisRefRegIdsByMatchedRefIds(matchedRids)).thenReturn(matchedRids);
122-
123-
when(packetInfoDao.getWithoutStatusCodes(matchedRids, RegistrationTransactionStatusCode.REJECTED.toString(),
124-
RegistrationTransactionStatusCode.PROCESSED.toString())).thenReturn(inprogressMatchedIds);
125-
when(packetInfoDao.getProcessedOrProcessingRegIds(matchedRids,
126-
lst)).thenReturn(processedMatchedIds);
127-
128-
when(idRepoService.getUinByRid(processedMatchedIds.get(0), new String())).thenReturn("123456789");
129-
when(idRepoService.getUinByRid(processedMatchedIds.get(1), new String())).thenReturn("987654321");
130-
131-
}
132-
133-
@Test
134-
public void testProcesssedWithUniqueUin() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
135-
136-
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType, 1, "", ProviderStageName.BIO_DEDUPE);
137-
138-
assertEquals(matchedRids.size(), uniqueRids.size());
139-
}
140-
141-
@Test
142-
public void testProcesssedWithSameUin() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
143-
144-
when(idRepoService.getUinByRid(anyString(), anyString())).thenReturn("987654321");
145-
146-
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType,1, "", ProviderStageName.BIO_DEDUPE);
147-
// expected to pick only 1 rid from processedMatchedIds list. Total should be 3(inprogress) + 1(processed)
148-
assertEquals(4, uniqueRids.size());
149-
}
150-
151-
@Test
152-
public void testDonotReturnRejected() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
153-
154-
when(packetInfoDao.getWithoutStatusCodes(matchedRids, RegistrationTransactionStatusCode.REJECTED.toString(),
155-
RegistrationTransactionStatusCode.PROCESSED.toString())).thenReturn(Lists.newArrayList());
156-
157-
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType,1, "", ProviderStageName.BIO_DEDUPE);
158-
// expected to pick only rocessedMatchedIds list i.e 2 records.
159-
assertEquals(2, uniqueRids.size());
160-
}
161-
162-
@Test
163-
public void testReturnAllInprogress() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
164-
165-
when(packetInfoDao.getProcessedOrProcessingRegIds(matchedRids,
166-
lst)).thenReturn(Lists.newArrayList());
167-
168-
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType,1, "", ProviderStageName.BIO_DEDUPE);
169-
// expected not to pick rocessedMatchedIds list i.e 3 records.
170-
assertEquals(3, uniqueRids.size());
171-
}
50+
private static final String registrationId = "10002100820001420210108085956";
51+
private static final String registrationType = "NEW";
52+
private static final String latestTransactionId = "123-456-789";
53+
List<String> matchedRids = new ArrayList<>();
54+
55+
56+
@InjectMocks
57+
private ABISHandlerUtil abisHandlerUtil;
58+
59+
@Mock
60+
private Utilities utilities;
61+
62+
@Mock
63+
private PacketInfoManager<Identity, ApplicantInfoDto> packetInfoManager;
64+
65+
@Mock
66+
private PacketInfoDao packetInfoDao;
67+
68+
@Mock
69+
private IdRepoService idRepoService;
70+
71+
List<String> lst=new ArrayList<>();
72+
73+
@Before
74+
public void setup() throws Exception {
75+
MockitoAnnotations.initMocks(this);
76+
when(utilities.getLatestTransactionId(any(),any(),anyInt(), any())).thenReturn(latestTransactionId);
77+
78+
List<String> regBioRefIds = new ArrayList<>();
79+
regBioRefIds.add("cf1c941a-142c-44f1-9543-4606b4a7884e");
80+
81+
when(packetInfoDao.getAbisRefIdByWorkflowInstanceId(any())).thenReturn(regBioRefIds);
82+
when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn(new String());
83+
84+
List<RegistrationStatusEntity> registrationStatusEntityList = new ArrayList<>();
85+
86+
RegistrationStatusEntity registrationEntity1 = new RegistrationStatusEntity();
87+
registrationEntity1.setRegId("10002100820001420210108085103");
88+
registrationEntity1.setStatusCode(RegistrationStatusCode.PROCESSED.toString());
89+
registrationStatusEntityList.add(registrationEntity1);
90+
RegistrationStatusEntity registrationEntity2 = new RegistrationStatusEntity();
91+
registrationEntity2.setRegId("10002100820001420210108085100");
92+
registrationEntity2.setStatusCode(RegistrationStatusCode.PROCESSING.toString());
93+
registrationStatusEntityList.add(registrationEntity2);
94+
RegistrationStatusEntity registrationEntity3 = new RegistrationStatusEntity();
95+
registrationEntity3.setRegId("10002100820001420210108085102");
96+
registrationEntity3.setStatusCode(RegistrationStatusCode.PROCESSED.toString());
97+
registrationStatusEntityList.add(registrationEntity3);
98+
matchedRids.add("10002100820001420210108085100");
99+
matchedRids.add("10002100820001420210108085103");
100+
matchedRids.add("10002100820001420210108085101");// REJECTED
101+
matchedRids.add("10002100820001420210108085102");
102+
103+
List<AbisResponseDto> abisResponseDtoList = new ArrayList<>();
104+
matchedRids.forEach(matchedRid -> {
105+
AbisResponseDto abisResponseDto = new AbisResponseDto();
106+
abisResponseDto.setId(matchedRid);
107+
abisResponseDtoList.add(abisResponseDto);
108+
});
109+
110+
lst.add(RegistrationTransactionStatusCode.PROCESSED.toString());lst.add(RegistrationTransactionStatusCode.PROCESSING.toString());
111+
112+
when(packetInfoManager.getAbisResponseRecords(regBioRefIds.get(0),
113+
latestTransactionId, AbisConstant.IDENTIFY)).thenReturn(abisResponseDtoList);
114+
115+
List<AbisResponseDetDto> abisResponseDetDtoList = new ArrayList<>();
116+
matchedRids.forEach(matchedRid -> {
117+
AbisResponseDetDto abisResponseDto = new AbisResponseDetDto();
118+
abisResponseDto.setMatchedBioRefId(matchedRid);
119+
abisResponseDetDtoList.add(abisResponseDto);
120+
});
121+
for (AbisResponseDetDto dto : abisResponseDetDtoList) {
122+
AbisResponseDetDto responseDetDto = new AbisResponseDetDto();
123+
responseDetDto.setMatchedBioRefId(dto.getMatchedBioRefId());
124+
when(packetInfoManager.getAbisResponseDetails(dto.getMatchedBioRefId())).thenReturn(Lists.newArrayList(responseDetDto));
125+
}
126+
when(packetInfoDao.getAbisRefRegIdsByMatchedRefIds(matchedRids)).thenReturn(matchedRids);
127+
when(packetInfoDao.getWithoutStatusCode(matchedRids, RegistrationStatusCode.REJECTED.toString()))
128+
.thenReturn(registrationStatusEntityList);
129+
when(idRepoService.getUinByRid("10002100820001420210108085103", new String())).thenReturn("123456789");
130+
when(idRepoService.getUinByRid("10002100820001420210108085102", new String())).thenReturn("987654321");
131+
}
132+
133+
@Test
134+
public void testProcesssedWithUniqueUin() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
135+
136+
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType, 1, "", ProviderStageName.BIO_DEDUPE);
137+
// expected to pick 2 rids from processedMatchedIds list because different uin.
138+
// Total should be 1(inprogress) + 2(processed)
139+
assertEquals(3, uniqueRids.size());
140+
}
141+
142+
@Test
143+
public void testProcesssedWithSameUin() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
144+
145+
when(idRepoService.getUinByRid(anyString(), anyString())).thenReturn("987654321");
146+
147+
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType,1, "", ProviderStageName.BIO_DEDUPE);
148+
// expected to pick only 1 rid from processedMatchedIds list because same uin. Total should be 1(inprogress) + 1(processed)
149+
assertEquals(2, uniqueRids.size());
150+
}
151+
152+
@Test
153+
public void testDonotReturnRejected() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
154+
155+
// List<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType, ProviderStageName.BIO_DEDUPE);
156+
Set<String> uniqueRids= abisHandlerUtil.getUniqueRegIds(registrationId,registrationType,1,"",ProviderStageName.BIO_DEDUPE);
157+
// expected to pick only processingandprocessed list i.e 3 records.
158+
assertEquals(3, uniqueRids.size());
159+
}
160+
161+
@Test
162+
public void testReturnAllInprogress() throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException, io.mosip.kernel.core.exception.IOException {
163+
164+
when(idRepoService.getUinByRid(anyString(), anyString())).thenReturn(null);
165+
166+
Set<String> uniqueRids = abisHandlerUtil.getUniqueRegIds(registrationId, registrationType,1, "", ProviderStageName.BIO_DEDUPE);
167+
// expected not to pick processedMatchedIds list i.e 1 records..
168+
assertEquals(1, uniqueRids.size());
169+
}
172170

173171
}

registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/repositary/RegistrationRepositary.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ public interface RegistrationRepositary<T extends BaseRegistrationEntity, E> ext
3131
public List<String> getProcessedOrProcessingRegIds(@Param("regIds") List<String> regIds,
3232
@Param("statusCode") List<String> statusCode);
3333

34-
@Query("SELECT registration.regId FROM RegistrationStatusEntity registration WHERE registration.regId in :regIds AND registration.statusCode !=:statusCode1 AND registration.statusCode !=:statusCode2")
35-
public List<String> getWithoutStatusCodes(@Param("regIds") List<String> regIds,
36-
@Param("statusCode1") String statusCode1, @Param("statusCode2") String statusCode2);
37-
34+
@Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.id in :regIds and registration.statusCode !=:statusCode")
35+
public List<RegistrationStatusEntity> getWithoutStatusCode(@Param("regIds") List<String> regIds, @Param("statusCode") String statusCode);
3836
@Query("SELECT registration FROM RegistrationStatusEntity registration WHERE registration.regId = :regId AND registration.isDeleted =false AND registration.isActive=true")
3937
public List<RegistrationStatusEntity> findByRegId(@Param("regId") String regId);
4038

0 commit comments

Comments
 (0)