Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2775,4 +2775,210 @@ public void testProcess_WithLostPacket_ShouldReturnNull() throws Exception {
assertNull(demographicIdentity.get("packetCreatedOn"));
}

@Test
public void testProcess_UinGenerationReprocess_ShouldSetReprocessStatus() throws IOException, PacketManagerException, ApisResourceAccessException, JsonProcessingException,
IdrepoDraftReprocessableException, IdrepoDraftException {
List<ErrorDTO> errors = new ArrayList<>();
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setErrorCode("IDR-IDC-004");
errorDTO.setMessage("Unknown error occurred");
errors.add(errorDTO);

MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("10031100110005020190313110030");
messageDTO.setReg_type(RegistrationType.UPDATE.name());
IdResponseDTO idResponseDTO = new IdResponseDTO();
idResponseDTO.setErrors(errors);

when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj);
Mockito.when(registrationStatusMapperUtil
.getStatusCode(RegistrationExceptionTypeCode.PACKET_UIN_GENERATION_REPROCESS)).thenReturn(RegistrationTransactionStatusCode.REPROCESS.toString());

when(packetManagerService.getFields(any(), any(), any(), any())).thenReturn(new HashMap<>());
when(packetManagerService.getFieldByMappingJsonKey(anyString(), anyString(), any(), any())).thenReturn("0.1");

when(idrepoDraftService.idrepoUpdateDraft(anyString(), any(), any())).thenReturn(idResponseDTO);

MessageDTO result = uinGeneratorStage.process(messageDTO);

assertEquals(RegistrationTransactionStatusCode.REPROCESS.toString(), registrationStatusDto.getLatestTransactionStatusCode());
assertTrue(result.getInternalError());
assertTrue(result.getIsValid());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Test
public void testProcess_UinGenerationFailed_ShouldSetReprocessStatus() throws IOException, PacketManagerException, ApisResourceAccessException, JsonProcessingException,
IdrepoDraftReprocessableException, IdrepoDraftException {

List<ErrorDTO> errors = new ArrayList<>();
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setErrorCode("IDR-IDC-005");
errors.add(errorDTO);

MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("10031100110005020190313110030");
messageDTO.setReg_type(RegistrationType.UPDATE.name());
IdResponseDTO idResponseDTO = new IdResponseDTO();
idResponseDTO.setErrors(errors);

when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj);
Mockito.when(registrationStatusMapperUtil
.getStatusCode(RegistrationExceptionTypeCode.PACKET_UIN_GENERATION_FAILED)).thenReturn(RegistrationTransactionStatusCode.REPROCESS.toString());

when(packetManagerService.getFields(any(), any(), any(), any())).thenReturn(new HashMap<>());
when(packetManagerService.getFieldByMappingJsonKey(anyString(), anyString(), any(), any())).thenReturn("0.1");

when(idrepoDraftService.idrepoUpdateDraft(anyString(), any(), any())).thenReturn(idResponseDTO);

MessageDTO result = uinGeneratorStage.process(messageDTO);

assertEquals(RegistrationTransactionStatusCode.REPROCESS.toString(), registrationStatusDto.getLatestTransactionStatusCode());
assertTrue(result.getInternalError());
assertTrue(result.getIsValid());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Test
public void testLostAndUpdateUin_WhenIdRepoDraftReturnsNull_ShouldSetValidStatusFalse() throws Exception {
Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("UIN", "123456");
fieldMap.put("name", "mono");
fieldMap.put("email", "mono@mono.com");

List<String> defaultFields = new ArrayList<>();
defaultFields.add("name");
defaultFields.add("dob");
defaultFields.add("gender");
defaultFields.add("UIN");
when(idRepoService.getUinByRid(anyString(), anyString())).thenReturn("9403107397");

when(utility.getUIn(any(),any(),any(ProviderStageName.class))).thenReturn("123456");
when(packetManagerService.getFieldByMappingJsonKey(anyString(),anyString(),any(),any())).thenReturn("0.1");
when(packetManagerService.getFields(anyString(),anyList(),anyString(),any())).thenReturn(fieldMap);
when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);

when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);
MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("27847657360002520181210094052");
messageDTO.setReg_type(RegistrationType.LOST.name());
String str = "{\"id\":\"mosip.id.read\",\"version\":\"1.0\",\"responsetime\":\"2019-04-05\",\"metadata\":null,\"response\":{\"uin\":\"2812936908\"},\"errors\":[{\"errorCode\":null,\"errorMessage\":null}]}";
String response = "{\"timestamp\":1553771083721,\"status\":404,\"errors\":[{\"errorCode\":\"KER-UIG-004\",\"errorMessage\":\"Given UIN is not in ISSUED status\"}]}";

when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(registrationProcessorRestClientService.putApi(any(), any(), any(), any(), any(), any(), any()))
.thenReturn(response);

when(packetManagerService.getField(any(), any(), any(),any())).thenReturn("989879234");

when(packetManagerService.getFieldByMappingJsonKey(any(), any(), any(), any())).thenReturn("1.0");
when(regLostUinDetEntity.getLostUinMatchedRegIdByWorkflowId(any())).thenReturn("27847657360002520181210094052");
MessageDTO result = uinGeneratorStage.process(messageDTO);
assertFalse(result.getInternalError());
assertFalse(result.getIsValid());
}

@Test
public void testReactivateUin_WhenStatusActivated() throws Exception {

Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("UIN", "123456");
fieldMap.put("name", "mono");
fieldMap.put("email", "mono@mono.com");

List<String> defaultFields = new ArrayList<>();
defaultFields.add("name");
defaultFields.add("dob");
defaultFields.add("gender");
defaultFields.add("UIN");

when(utility.getUIn(any(),any(),any(ProviderStageName.class))).thenReturn("123456");
when(packetManagerService.getFieldByMappingJsonKey(anyString(),anyString(),any(),any())).thenReturn("0.1");
when(packetManagerService.getFields(any(), any(), any(), any())).thenReturn(fieldMap);
when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);

when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);

MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("27847657360002520181210094052");
messageDTO.setReg_type(RegistrationType.valueOf("ACTIVATED").name());

IdResponseDTO idResponseDTO = new IdResponseDTO();
ResponseDTO responseDTO = new ResponseDTO();
idResponseDTO.setErrors(null);
idResponseDTO.setId("mosip.id.update");
responseDTO.setStatus(io.mosip.registration.processor.status.code.RegistrationType.ACTIVATED.toString());
idResponseDTO.setResponse(responseDTO);
idResponseDTO.setResponsetime("2019-01-17T06:29:01.940Z");
idResponseDTO.setVersion("1.0");

IdResponseDTO idResponseDTO1 = new IdResponseDTO();
ResponseDTO responseDTO1 = new ResponseDTO();
idResponseDTO1.setErrors(null);
idResponseDTO1.setId("mosip.id.update");
responseDTO1.setStatus("ANY");
idResponseDTO1.setResponse(responseDTO1);
idResponseDTO1.setResponsetime("2019-01-17T06:29:01.940Z");
idResponseDTO1.setVersion("1.0");

when(registrationProcessorRestClientService.getApi(any(), any(), anyString(), any(), any()))
.thenReturn(idResponseDTO1);

when(idrepoDraftService.idrepoUpdateDraft(anyString(), any(), any())).thenReturn(idResponseDTO);
when(registrationProcessorRestClientService.patchApi(any(), any(), any(), any(), any(), any()))
.thenReturn(idResponseDTO1);
MessageDTO result = uinGeneratorStage.process(messageDTO);
assertTrue(result.getIsValid());
assertFalse(result.getInternalError());
}
Comment thread
ashok-ksharma marked this conversation as resolved.

@Test
public void testUinUpdate_WhenIdRepoStatusDrafted_ShouldReturnTrue() throws ApisResourceAccessException, IOException, JsonProcessingException,
PacketManagerException, JSONException, IdrepoDraftException, IdrepoDraftReprocessableException {
Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("UIN", "123456");
fieldMap.put("name", "mono");
fieldMap.put("email", "mono@mono.com");

List<String> defaultFields = new ArrayList<>();
defaultFields.add("name");
defaultFields.add("dob");
defaultFields.add("gender");
defaultFields.add("UIN");

when(utility.getUIn(any(),any(),any(ProviderStageName.class))).thenReturn("123456");
when(packetManagerService.getFields(any(), any(), any(), any())).thenReturn(fieldMap);

when(packetManagerService.getFieldByMappingJsonKey(anyString(),anyString(),any(),any())).thenReturn("0.1");
when(packetManagerService.getFields(anyString(),anyList(),anyString(),any())).thenReturn(fieldMap);
when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);

when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(defaultFields);
MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("10031100110005020190313110030");
messageDTO.setReg_type(RegistrationType.valueOf("UPDATE").name());
IdResponseDTO responsedto = new IdResponseDTO();

IdResponseDTO idResponseDTO = new IdResponseDTO();
ResponseDTO responseDTO = new ResponseDTO();
idResponseDTO.setErrors(null);
idResponseDTO.setId("mosip.id.update");
responseDTO.setStatus(IDREPO_STATUS);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
idResponseDTO.setResponse(responseDTO);
idResponseDTO.setResponsetime("2019-03-12T06:49:30.779Z");
idResponseDTO.setVersion("1.0");

when(idrepoDraftService.idrepoUpdateDraft(anyString(), any(), any())).thenReturn(idResponseDTO);
when(registrationProcessorRestClientService.getApi(any(), any(), anyString(), any(), any()))
.thenReturn(responsedto);
when(registrationProcessorRestClientService.patchApi(any(), any(), any(), any(), any(), any()))
.thenReturn(idResponseDTO);
when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj);

MessageDTO result = uinGeneratorStage.process(messageDTO);
assertTrue(result.getIsValid());
assertFalse(result.getInternalError());
}

}
Loading