Skip to content

Commit

Permalink
MOSIP-37899: Updated request dto for approve or reject device (#1049)
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 Dec 20, 2024
1 parent 1fac6d6 commit 0bf58d7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.mosip.pms.common.dto.PageResponseV2Dto;
import io.mosip.pms.common.response.dto.ResponseWrapperV2;
import io.mosip.pms.partner.dto.DeviceDetailDto;
import io.mosip.pms.partner.dto.DeviceDto;
import io.mosip.pms.device.response.dto.SbiDetailsResponseDto;
import io.mosip.pms.device.response.dto.SbiSummaryDto;
import io.mosip.pms.device.dto.SbiFilterDto;
Expand All @@ -17,6 +17,7 @@
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceCreateDto;
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceStatusUpdateDto;
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceUpdateDto;
import io.mosip.pms.device.request.dto.DeviceDetailDto;
import io.mosip.pms.device.response.dto.FilterResponseCodeDto;
import io.mosip.pms.device.response.dto.IdDto;
import io.mosip.pms.device.response.dto.MappedDeviceDetailsReponse;
Expand Down Expand Up @@ -45,9 +46,9 @@ public interface SecureBiometricInterfaceService {

public ResponseWrapperV2<List<SbiDetailsDto>> getSbiDetails();

public ResponseWrapperV2<IdDto> addDeviceToSbi(io.mosip.pms.device.request.dto.DeviceDetailDto deviceDetailDto, String sbiId);
public ResponseWrapperV2<IdDto> addDeviceToSbi(DeviceDetailDto deviceDetailDto, String sbiId);

public ResponseWrapperV2<List<DeviceDetailDto>> getAllDevicesForSbi(String sbiId);
public ResponseWrapperV2<List<DeviceDto>> getAllDevicesForSbi(String sbiId);

public ResponseWrapperV2<SbiDetailsResponseDto> deactivateSbi(String id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
import io.mosip.pms.device.dto.SbiFilterDto;
import io.mosip.pms.device.util.DeviceUtil;
import io.mosip.pms.partner.constant.ErrorCode;
import io.mosip.pms.partner.dto.DeviceDetailDto;
import io.mosip.pms.partner.dto.DeviceDto;
import io.mosip.pms.device.dto.SbiDetailsDto;
import io.mosip.pms.partner.exception.PartnerServiceException;
import io.mosip.pms.device.response.dto.SbiDetailsResponseDto;
import io.mosip.pms.partner.util.MultiPartnerUtil;
import io.mosip.pms.partner.util.PartnerHelper;
import io.mosip.pms.partner.util.PartnerUtil;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
Expand Down Expand Up @@ -76,6 +75,7 @@
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceCreateDto;
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceStatusUpdateDto;
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceUpdateDto;
import io.mosip.pms.device.request.dto.DeviceDetailDto;
import io.mosip.pms.device.response.dto.ColumnCodeValue;
import io.mosip.pms.device.response.dto.FilterResponseCodeDto;
import io.mosip.pms.device.response.dto.IdDto;
Expand Down Expand Up @@ -753,7 +753,7 @@ public FilterResponseCodeDto filterValues(FilterValueDto filterValueDto) {
}

@Override
public ResponseWrapperV2<IdDto> addDeviceToSbi(io.mosip.pms.device.request.dto.DeviceDetailDto deviceDetailDto, String sbiId) {
public ResponseWrapperV2<IdDto> addDeviceToSbi(DeviceDetailDto deviceDetailDto, String sbiId) {
ResponseWrapperV2<IdDto> responseWrapper = new ResponseWrapperV2<>();
String deviceId = null;
try {
Expand Down Expand Up @@ -817,7 +817,7 @@ public ResponseWrapperV2<IdDto> addDeviceToSbi(io.mosip.pms.device.request.dto.D
return responseWrapper;
}

private IdDto createDeviceDetails(io.mosip.pms.device.request.dto.DeviceDetailDto deviceDetailDto) {
private IdDto createDeviceDetails(DeviceDetailDto deviceDetailDto) {
DeviceDetail entity = new DeviceDetail();
DeviceDetail deviceDetail = null;
IdDto dto = new IdDto();
Expand Down Expand Up @@ -850,7 +850,7 @@ private IdDto createDeviceDetails(io.mosip.pms.device.request.dto.DeviceDetailDt
return dto;
}

public DeviceDetail getCreateMapping(DeviceDetail deviceDetail, io.mosip.pms.device.request.dto.DeviceDetailDto deviceDetailDto) {
public DeviceDetail getCreateMapping(DeviceDetail deviceDetail, DeviceDetailDto deviceDetailDto) {
deviceDetail.setId(deviceDetailDto.getId() == null ? DeviceUtil.generateId(): deviceDetailDto.getId());
deviceDetail.setIsActive(false);
deviceDetail.setIsDeleted(false);
Expand Down Expand Up @@ -914,8 +914,8 @@ private void deleteDeviceDetail(String deviceDetailId) {
}

@Override
public ResponseWrapperV2<List<DeviceDetailDto>> getAllDevicesForSbi(String sbiId) {
ResponseWrapperV2<List<DeviceDetailDto>> responseWrapper = new ResponseWrapperV2<>();
public ResponseWrapperV2<List<DeviceDto>> getAllDevicesForSbi(String sbiId) {
ResponseWrapperV2<List<DeviceDto>> responseWrapper = new ResponseWrapperV2<>();
try {
String userId = getUserId();
List<Partner> partnerList = partnerRepository.findByUserId(userId);
Expand Down Expand Up @@ -953,27 +953,27 @@ public ResponseWrapperV2<List<DeviceDetailDto>> getAllDevicesForSbi(String sbiId
// fetch devices list
List<DeviceDetailSBI> deviceDetailSBIList = deviceDetailSbiRepository.findByDeviceProviderIdAndSbiId(sbi.getProviderId(), sbiId);
if (!deviceDetailSBIList.isEmpty()) {
List<DeviceDetailDto> deviceDetailDtoList = new ArrayList<>();
List<DeviceDto> deviceDtoList = new ArrayList<>();
for (DeviceDetailSBI deviceDetailSBI : deviceDetailSBIList) {
Optional<DeviceDetail> optionalDeviceDetail = deviceDetailRepository.
findByIdAndDeviceProviderId(deviceDetailSBI.getId().getDeviceDetailId(), deviceDetailSBI.getProviderId());
if (optionalDeviceDetail.isPresent()) {
DeviceDetail deviceDetail = optionalDeviceDetail.get();
DeviceDetailDto deviceDetailDto = new DeviceDetailDto();
deviceDetailDto.setDeviceId(deviceDetail.getId());
deviceDetailDto.setDeviceTypeCode(deviceDetail.getDeviceTypeCode());
deviceDetailDto.setDeviceSubTypeCode(deviceDetail.getDeviceSubTypeCode());
deviceDetailDto.setDeviceProviderId(deviceDetail.getDeviceProviderId());
deviceDetailDto.setMake(deviceDetail.getMake());
deviceDetailDto.setModel(deviceDetail.getModel());
deviceDetailDto.setStatus(deviceDetail.getApprovalStatus());
deviceDetailDto.setActive(deviceDetail.getIsActive());
deviceDetailDto.setCreatedDateTime(deviceDetail.getCrDtimes());

deviceDetailDtoList.add(deviceDetailDto);
DeviceDto deviceDto = new DeviceDto();
deviceDto.setDeviceId(deviceDetail.getId());
deviceDto.setDeviceTypeCode(deviceDetail.getDeviceTypeCode());
deviceDto.setDeviceSubTypeCode(deviceDetail.getDeviceSubTypeCode());
deviceDto.setDeviceProviderId(deviceDetail.getDeviceProviderId());
deviceDto.setMake(deviceDetail.getMake());
deviceDto.setModel(deviceDetail.getModel());
deviceDto.setStatus(deviceDetail.getApprovalStatus());
deviceDto.setActive(deviceDetail.getIsActive());
deviceDto.setCreatedDateTime(deviceDetail.getCrDtimes());

deviceDtoList.add(deviceDto);
}
}
responseWrapper.setResponse(deviceDetailDtoList);
responseWrapper.setResponse(deviceDtoList);
}
} catch (PartnerServiceException ex) {
LOGGER.info("sessionId", "idType", "id", "In getAllDevicesForSbi method of SecureBiometricInterfaceServiceImpl - " + ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.mosip.pms.common.request.dto.RequestWrapperV2;
import io.mosip.pms.common.response.dto.ResponseWrapperV2;
import io.mosip.pms.device.dto.SbiFilterDto;
import io.mosip.pms.partner.dto.DeviceDetailDto;
import io.mosip.pms.partner.dto.DeviceDto;
import io.mosip.pms.device.response.dto.SbiDetailsResponseDto;
import io.mosip.pms.device.dto.SbiDetailsDto;
import io.mosip.pms.partner.util.PartnerHelper;
Expand Down Expand Up @@ -44,6 +44,7 @@
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceStatusUpdateDto;
import io.mosip.pms.device.request.dto.SecureBiometricInterfaceUpdateDto;
import io.mosip.pms.device.request.dto.UpdateDeviceDetailStatusDto;
import io.mosip.pms.device.request.dto.DeviceDetailDto;
import io.mosip.pms.device.response.dto.FilterResponseCodeDto;
import io.mosip.pms.device.response.dto.IdDto;
import io.mosip.pms.device.response.dto.MappedDeviceDetailsReponse;
Expand Down Expand Up @@ -224,7 +225,7 @@ public ResponseWrapper<FilterResponseCodeDto> filterValues(
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseWrapperV2<IdDto> addDeviceToSbi(@PathVariable("sbiId") @NotBlank String sbiId, @RequestBody @Valid RequestWrapperV2<io.mosip.pms.device.request.dto.DeviceDetailDto> requestWrapper) {
public ResponseWrapperV2<IdDto> addDeviceToSbi(@PathVariable("sbiId") @NotBlank String sbiId, @RequestBody @Valid RequestWrapperV2<DeviceDetailDto> requestWrapper) {
Optional<ResponseWrapperV2<IdDto>> validationResponse = requestValidator.validate(postAddDeviceToSbi, requestWrapper);
if (validationResponse.isPresent()) {
return validationResponse.get();
Expand All @@ -240,7 +241,7 @@ public ResponseWrapperV2<IdDto> addDeviceToSbi(@PathVariable("sbiId") @NotBlank
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema(hidden = true))),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema(hidden = true)))
})
public ResponseWrapperV2<List<DeviceDetailDto>> getAllDevicesForSbi(@PathVariable String sbiId) {
public ResponseWrapperV2<List<DeviceDto>> getAllDevicesForSbi(@PathVariable String sbiId) {
return secureBiometricInterface.getAllDevicesForSbi(sbiId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Data
@Getter
@Setter
public class DeviceDetailDto {
public class DeviceDto {

@Schema(description = "Code representing the id of the device. The id can either be provided by the user as a unique ID or left as null. If it's provided, that unique ID will be used as the device_detail_id. If it's null, the service will automatically generate a unique ID for the device_detail_id.", example = "12345")
private String deviceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
import java.util.ArrayList;
import java.util.List;

import io.mosip.pms.common.request.dto.RequestWrapperV2;
import io.mosip.pms.common.response.dto.ResponseWrapperV2;
import io.mosip.pms.device.dto.SbiFilterDto;
import io.mosip.pms.device.response.dto.SbiSummaryDto;
import io.mosip.pms.partner.dto.DeviceDetailDto;
import io.mosip.pms.partner.dto.DeviceDto;
import io.mosip.pms.device.response.dto.SbiDetailsResponseDto;
import io.mosip.pms.device.dto.SbiDetailsDto;
import org.junit.Before;
Expand Down Expand Up @@ -360,11 +359,11 @@ public void searchMappedDeviceDetailsSecureBiometricTest() throws JsonProcessing
@Test
@WithMockUser(roles = {"DEVICE_PROVIDER"})
public void getAllDevicesForSbiTest() throws Exception {
ResponseWrapperV2<List<DeviceDetailDto>> responseWrapper = new ResponseWrapperV2<>();
List<DeviceDetailDto> deviceDetailDtoList = new ArrayList<>();
DeviceDetailDto deviceDetailDto = new DeviceDetailDto();
deviceDetailDtoList.add(deviceDetailDto);
responseWrapper.setResponse(deviceDetailDtoList);
ResponseWrapperV2<List<DeviceDto>> responseWrapper = new ResponseWrapperV2<>();
List<DeviceDto> deviceDtoList = new ArrayList<>();
DeviceDto deviceDto = new DeviceDto();
deviceDtoList.add(deviceDto);
responseWrapper.setResponse(deviceDtoList);
Mockito.when(secureBiometricInterfaceService.getAllDevicesForSbi(Mockito.any())).thenReturn(responseWrapper);
mockMvc.perform(MockMvcRequestBuilders.get("/securebiometricinterface/123/devices").contentType(MediaType.APPLICATION_JSON_VALUE)
.content(objectMapper.writeValueAsString(responseWrapper))).andExpect(status().isOk());
Expand Down

0 comments on commit 0bf58d7

Please sign in to comment.