Skip to content

Commit

Permalink
MOSIP-38031: Added filter for sbiId and ftmId (#1075)
Browse files Browse the repository at this point in the history
Signed-off-by: Swetha K <[email protected]>
Co-authored-by: Swetha K <[email protected]>
  • Loading branch information
SwethaKrish4 and Swetha K authored Jan 8, 2025
1 parent 1221c58 commit e7936e2
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface FtmDetailsSummaryRepository extends BaseRepository<FtmDetailSum
"FROM FTPChipDetail f " +
"WHERE (:partnerId IS NULL OR lower(f.ftpProviderId) LIKE %:partnerId%) " +
"AND (:orgName IS NULL OR lower(f.partnerOrganizationName) LIKE %:orgName%) " +
"AND (:ftmId IS NULL OR lower(f.ftpChipDetailId) LIKE %:ftmId%) " +
"AND (:make IS NULL OR lower(f.make) LIKE %:make%) " +
"AND (:model IS NULL OR lower(f.model) LIKE %:model%) " +
"AND (:status IS NULL OR " +
Expand All @@ -37,6 +38,7 @@ public interface FtmDetailsSummaryRepository extends BaseRepository<FtmDetailSum
Page<FtmDetailSummaryEntity> getSummaryOfPartnersFtmDetails(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("ftmId") String ftmId,
@Param("make") String make,
@Param("model") String model,
@Param("status") String status,
Expand All @@ -47,6 +49,7 @@ Page<FtmDetailSummaryEntity> getSummaryOfPartnersFtmDetails(
Page<FtmDetailSummaryEntity> getSummaryOfPartnersFtmDetailsByStatusAsc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("ftmId") String ftmId,
@Param("make") String make,
@Param("model") String model,
@Param("status") String status,
Expand All @@ -57,6 +60,7 @@ Page<FtmDetailSummaryEntity> getSummaryOfPartnersFtmDetailsByStatusAsc(
Page<FtmDetailSummaryEntity> getSummaryOfPartnersFtmDetailsByStatusDesc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("ftmId") String ftmId,
@Param("make") String make,
@Param("model") String model,
@Param("status") String status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public interface SbiSummaryRepository extends BaseRepository<SbiSummaryEntity, S
"LEFT JOIN DeviceDetail d ON d.id = dd.id.deviceDetailId " +
"WHERE (:partnerId IS NULL OR lower(s.providerId) LIKE %:partnerId%) " +
"AND (:orgName IS NULL OR lower(s.partnerOrgName) LIKE %:orgName%) " +
"AND (:sbiId IS NULL OR lower(s.id) LIKE %:sbiId%) " +
"AND (:sbiVersion IS NULL OR lower(s.swVersion) LIKE %:sbiVersion%) " +
"AND (:status IS NULL OR " +
"(:status = 'deactivated' AND s.approvalStatus = 'approved' AND s.isActive = false) " +
Expand All @@ -47,6 +48,7 @@ public interface SbiSummaryRepository extends BaseRepository<SbiSummaryEntity, S
Page<SbiSummaryEntity> getSummaryOfSbiDetails(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -57,6 +59,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetails(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByStatusAsc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -67,6 +70,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetailsByStatusAsc(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByStatusDesc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -77,6 +81,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetailsByStatusDesc(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByExpiryStatusAsc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -87,6 +92,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetailsByExpiryStatusAsc(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByExpiryStatusDesc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -97,6 +103,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetailsByExpiryStatusDesc(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByDevicesCountAsc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand All @@ -107,6 +114,7 @@ Page<SbiSummaryEntity> getSummaryOfSbiDetailsByDevicesCountAsc(
Page<SbiSummaryEntity> getSummaryOfSbiDetailsByDevicesCountDesc(
@Param("partnerId") String partnerId,
@Param("orgName") String orgName,
@Param("sbiId") String sbiId,
@Param("sbiVersion") String sbiVersion,
@Param("status") String status,
@Param("sbiExpiryStatus") String sbiExpiryStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,19 +714,19 @@ private Page<FtmDetailSummaryEntity> getFtmChipDetails(String sortFieldName, Str
if (sortFieldName.equals("status") && sortType.equalsIgnoreCase(PartnerConstants.ASC)) {
return ftmDetailsSummaryRepository.
getSummaryOfPartnersFtmDetailsByStatusAsc(filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
filterDto.getFtmId(), filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
} else if (sortFieldName.equals("status") && sortType.equalsIgnoreCase(PartnerConstants.DESC)) {
return ftmDetailsSummaryRepository.
getSummaryOfPartnersFtmDetailsByStatusDesc(filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
filterDto.getFtmId(), filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
}
//Sorting for other fields
Sort sort = partnerHelper.getSortingRequest(getSortColumn(partnerHelper.ftmAliasToColumnMap, sortFieldName), sortType);
pageable = PageRequest.of(pageNo, pageSize, sort);
}
//Default
return ftmDetailsSummaryRepository.getSummaryOfPartnersFtmDetails(filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
filterDto.getFtmId(), filterDto.getMake(), filterDto.getModel(), filterDto.getStatus(), pageable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1156,37 +1156,37 @@ private Page<SbiSummaryEntity> getSbiDetails(String sortFieldName, String sortTy
switch (sortKey) {
case "status_asc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByStatusAsc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

case "status_desc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByStatusDesc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

case "sbiExpiryStatus_asc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusAsc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

case "sbiExpiryStatus_desc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusDesc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

case "countOfAssociatedDevices_asc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountAsc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

case "countOfAssociatedDevices_desc":
return sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountDesc(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);

Expand All @@ -1198,7 +1198,7 @@ private Page<SbiSummaryEntity> getSbiDetails(String sortFieldName, String sortTy
}
}
return sbiSummaryRepository.getSummaryOfSbiDetails(
filterDto.getPartnerId(), filterDto.getOrgName(),
filterDto.getPartnerId(), filterDto.getOrgName(), filterDto.getSbiId(),
filterDto.getSbiVersion(), filterDto.getStatus(),
filterDto.getSbiExpiryStatus(), pageable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ ResponseWrapperV2<PageResponseV2Dto<FtmDetailSummaryDto>> getPartnersFtmChipDeta
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize,
@RequestParam(value = "partnerId", required = false) String partnerId,
@RequestParam(value = "orgName", required = false) String orgName,
@RequestParam(value = "ftmId", required = false) String ftmId,
@RequestParam(value = "make", required = false) String make,
@RequestParam(value = "model", required = false) String model,
@Parameter(
Expand All @@ -311,6 +312,9 @@ ResponseWrapperV2<PageResponseV2Dto<FtmDetailSummaryDto>> getPartnersFtmChipDeta
if (orgName != null) {
filterDto.setOrgName(orgName.toLowerCase());
}
if (ftmId != null) {
filterDto.setFtmId(ftmId.toLowerCase());
}
if (make != null) {
filterDto.setMake(make.toLowerCase());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ ResponseWrapperV2<PageResponseV2Dto<SbiSummaryDto>> getAllSbiDetails(
@RequestParam(value = "pageSize", defaultValue = "8") int pageSize,
@RequestParam(value = "partnerId", required = false) String partnerId,
@RequestParam(value = "orgName", required = false) String orgName,
@RequestParam(value = "sbiId", required = false) String sbiId,
@RequestParam(value = "sbiVersion", required = false) String sbiVersion,
@Parameter(
description = "Status of SBI",
Expand All @@ -313,6 +314,9 @@ ResponseWrapperV2<PageResponseV2Dto<SbiSummaryDto>> getAllSbiDetails(
if (orgName != null) {
filterDto.setOrgName(orgName.toLowerCase());
}
if (sbiId != null) {
filterDto.setSbiId(sbiId.toLowerCase());
}
if (sbiVersion != null) {
filterDto.setSbiVersion(sbiVersion.toLowerCase());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class FtmChipFilterDto {
private String partnerId;
private String orgName;
private String ftmId;
private String make;
private String model;
private String status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class SbiFilterDto {

private String partnerId;
private String orgName;
private String sbiId;
private String sbiVersion;
private String status;
private String sbiExpiryStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public void getPartnersFtmDetailsTest() throws Exception {
.param("pageSize", String.valueOf(pageSize))
.param("partnerId", "123")
.param("orgName", "ABC")
.param("ftmId", "ftm123")
.param("make", "test")
.param("model", "test")
.param("status", "approved"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ public void getAllSbiDetailsTest() throws Exception {
.param("pageSize", String.valueOf(pageSize))
.param("partnerId", "123")
.param("orgName", "ABC")
.param("sbiId", "sbi123")
.param("sbiVersion", "test")
.param("status", "approved")
.param("sbiExpiryStatus", "expired"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ public void getPartnersFtmChipDetailsTest() throws Exception {
filterDto.setOrgName("ABC");
ResponseWrapperV2<PageResponseV2Dto<FtmDetailSummaryDto>> responseWrapper = new ResponseWrapperV2<>();
Page<FtmDetailSummaryEntity> page = null;
when(ftmDetailsSummaryRepository.getSummaryOfPartnersFtmDetails(anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
when(ftmDetailsSummaryRepository.getSummaryOfPartnersFtmDetails(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
fTPChipDetailServiceImpl.getPartnersFtmChipDetails(sortFieldName, sortType, pageNo, pageSize, filterDto);
}

Expand All @@ -1708,7 +1708,7 @@ public void getPartnersFtmChipDetailsTestException() throws Exception {
int pageSize = 8;
ResponseWrapperV2<PageResponseV2Dto<FtmDetailSummaryDto>> responseWrapper = new ResponseWrapperV2<>();
Page<FtmDetailSummaryEntity> page = null;
when(ftmDetailsSummaryRepository.getSummaryOfPartnersFtmDetails(anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
when(ftmDetailsSummaryRepository.getSummaryOfPartnersFtmDetails(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
fTPChipDetailServiceImpl.getPartnersFtmChipDetails(sortFieldName, sortType, pageNo, pageSize, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ public void getAllSbiDetailsTest() throws Exception {
field.set(partnerHelper, mockMap);

when(partnerHelper.getSortingRequest(anyString(), anyString())).thenReturn(Sort.by(Sort.Order.asc("crDtimes")));
when(sbiSummaryRepository.getSummaryOfSbiDetails(any(), any(), any(), any(), anyString(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetails(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
ResponseWrapperV2<PageResponseV2Dto<SbiSummaryDto>> response = secureBiometricInterfaceService.getAllSbiDetails(sortFieldName, sortType, pageNo, pageSize, filterDto);

Assert.assertNotNull(response);
Expand All @@ -1175,7 +1175,7 @@ public void getAllSbiDetailsExceptionTest() throws Exception {
int pageSize = 8;
ResponseWrapperV2<PageResponseV2Dto<SbiSummaryDto>> responseWrapper = new ResponseWrapperV2<>();
Page<SbiSummaryEntity> page = null;
when(sbiSummaryRepository.getSummaryOfSbiDetails(anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetails(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any())).thenReturn(page);
secureBiometricInterfaceService.getAllSbiDetails(sortFieldName, sortType, pageNo, pageSize, null);
}

Expand Down Expand Up @@ -1331,13 +1331,13 @@ public void getAllDevicesForSbi_Exception() {
@Test
public void testGetSbiDetails() throws NoSuchFieldException, IllegalAccessException {
Page<SbiSummaryEntity> page = null;
when(sbiSummaryRepository.getSummaryOfSbiDetailsByStatusAsc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByStatusDesc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusAsc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusDesc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountAsc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountDesc(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetails(any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByStatusAsc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByStatusDesc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusAsc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByExpiryStatusDesc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountAsc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetailsByDevicesCountDesc(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);
when(sbiSummaryRepository.getSummaryOfSbiDetails(any(), any(), any(), any(), any(), any(), any())).thenReturn(page);

// Create and set the mock map
Map<String, String> mockMap = new HashMap<>();
Expand Down Expand Up @@ -1394,31 +1394,31 @@ public void testGetSbiDetails() throws NoSuchFieldException, IllegalAccessExcept
switch (sortKey) {
case "status_asc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByStatusAsc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByStatusAsc(any(), any(), any(), any(), any(), any(), any());
break;
case "status_desc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByStatusDesc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByStatusDesc(any(), any(), any(), any(), any(), any(), any());
break;
case "sbiExpiryStatus_asc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByExpiryStatusAsc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByExpiryStatusAsc(any(), any(), any(), any(), any(), any(), any());
break;
case "sbiExpiryStatus_desc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByExpiryStatusDesc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByExpiryStatusDesc(any(), any(), any(), any(), any(), any(), any());
break;
case "countOfAssociatedDevices_asc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByDevicesCountAsc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByDevicesCountAsc(any(), any(), any(), any(), any(), any(), any());
break;
case "countOfAssociatedDevices_desc":
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetailsByDevicesCountDesc(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetailsByDevicesCountDesc(any(), any(), any(), any(), any(), any(), any());
break;
default:
verify(sbiSummaryRepository, times(1))
.getSummaryOfSbiDetails(any(), any(), any(), any(), any(), any());
.getSummaryOfSbiDetails(any(), any(), any(), any(), any(), any(), any());
break;
}

Expand Down

0 comments on commit e7936e2

Please sign in to comment.