Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -19,6 +19,7 @@
import io.mosip.registration.processor.biodedupe.stage.exception.CbeffNotFoundException;
import io.mosip.registration.processor.core.code.*;
import io.mosip.registration.processor.core.constant.ProviderStageName;
import io.mosip.registration.processor.core.constant.RegistrationType;
import io.mosip.registration.processor.core.exception.*;
import io.mosip.registration.processor.core.packet.dto.abis.ProcessedMatchedResult;
import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService;
Expand Down Expand Up @@ -947,4 +948,32 @@ public void testProcess_ThrowsBiometricClassificationException() throws PacketMa
assertEquals(MessageBusAddress.VERIFICATION_BUS_IN, result.getMessageBusAddress());
}

@Test
public void testProcessWhenExceptionOccursShouldSetValidStatusFalseAndInternalErrorTrue() {

MessageDTO messageDTO = new MessageDTO();
messageDTO.setRid("10031100110005020190313110030");
when(abisHandlerUtil.getPacketStatus(any()))
.thenThrow(new RuntimeException("test exception"));
MessageDTO result = bioDedupeProcessor.process(messageDTO, stageName);

assertFalse(result.getIsValid());
assertTrue(result.getInternalError());
}

@Test
public void testNewPacketPreAbisIdentificationWhenInfantDedupeDisabledSuccessStatus() throws ApisResourceAccessException, PacketManagerException, IOException, JsonProcessingException {

ReflectionTestUtils.setField(bioDedupeProcessor, "infantDedupe", "N");
MessageDTO messageDTO = new MessageDTO();
messageDTO.setReg_type(RegistrationType.NEW.name());
Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null);
Mockito.when(utility.getApplicantAge(any(),any(),any())).thenReturn(3);
MessageDTO messageDto = bioDedupeProcessor.process(messageDTO, stageName);
assertTrue(messageDto.getIsValid());
assertEquals(MessageBusAddress.BIO_DEDUPE_BUS_IN, messageDTO.getMessageBusAddress());
assertEquals(RegistrationStatusCode.PROCESSING.name(), registrationStatusDto.getStatusCode());
assertEquals(RegistrationTransactionStatusCode.SUCCESS.name(), registrationStatusDto.getLatestTransactionStatusCode());
}
Comment thread
ashok-ksharma marked this conversation as resolved.

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.*;

import java.io.File;
Expand All @@ -22,6 +24,7 @@
import io.mosip.registration.processor.adjudication.request.dto.Filter;
import io.mosip.registration.processor.adjudication.request.dto.ShareableAttributes;
import io.mosip.registration.processor.adjudication.request.dto.Source;
import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode;
import io.mosip.registration.processor.core.exception.PacketManagerNonRecoverableException;
import org.apache.commons.io.IOUtils;
import org.assertj.core.groups.Tuple;
Expand All @@ -31,6 +34,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand Down Expand Up @@ -812,4 +816,93 @@ public void PacketManagerNonRecoverableExceptionTest() throws Exception {
assertFalse(messageDTO.getIsValid());
assertTrue(messageDTO.getInternalError());
}

@Test
public void testProcessShouldInvalidateMessageWhenDataShareUrlPresent() throws Exception {
Comment thread
ashok-ksharma marked this conversation as resolved.

ShareableAttributes shareableAttributes1 = new ShareableAttributes();
shareableAttributes1.setAttributeName("biometrics");
shareableAttributes1.setEncrypted(true);

List<Source> sourceList = new ArrayList<>();
Source source1 = new Source();
source1.setAttribute("biometrics");
List<Filter> filterlist = new ArrayList<>();
Filter filter11 = new Filter();
filter11.setLanguage("lang");
filter11.setType("type");
filterlist.add(filter11);
source1.setFilter(filterlist);
sourceList.add(source1);

shareableAttributes1.setSource(sourceList);
shareableAttributes1.setFormat("");
shareableAttributes1.setGroup("");

MessageDTO object = new MessageDTO();
object.setReg_type("NEW");
object.setRid("92379526572940");
object.setIteration(1);
object.setWorkflowInstanceId("26fa3eff-f3b9-48f7-b365-d7f7c2e56e00");
setDataShareDetails();

Map<String, String> identity = new HashMap<String, String>();
identity.put("fullName", "Satish");
Mockito.when(packetManagerService.getFields(anyString(), any(), anyString(), any())).thenReturn(identity);
Mockito.when(mapper.writeValueAsString(any())).thenReturn("");
Mockito.when(mapper.readValue(anyString(),any(Class.class))).thenReturn(shareableAttributes1).thenReturn(shareableAttributes1).thenReturn(shareableAttributes1);

MessageDTO messageDTO = manualAdjudicationService.process(object,queue);

assertFalse(messageDTO.getIsValid());
assertFalse(messageDTO.getInternalError());
}

@Test
public void updatePacketStatusSuccessFlowWhenStatusRejected() {

ManualAdjudicationResponseDTO adjudicationResponseDTO = new ManualAdjudicationResponseDTO();
adjudicationResponseDTO.setReturnValue(4);
adjudicationResponseDTO.setResponsetime(DateUtils.getCurrentDateTimeString());
adjudicationResponseDTO.setId("mosip.manual.adjudication.adjudicate");
adjudicationResponseDTO.setRequestId("4d4f27d3-ec73-41c4-a384-bf87fce4969e");
CandidateList candidateList = new CandidateList();
candidateList.setCount(0);
adjudicationResponseDTO.setCandidateList(candidateList);

Mockito.when(basePacketRepository.getAllAssignedRecord(anyString(), anyString())).thenReturn(entities);
Mockito.when(registrationStatusService.getRegistrationStatus(any(), any(), any(), any())).thenReturn(registrationStatusDto);
Mockito.when(basePacketRepository.getAssignedApplicantDetails(anyString(), anyString())).thenReturn(null);
Mockito.when(basePacketRepository.update(any(ManualVerificationEntity.class))).thenReturn(manualVerificationEntity);
Mockito.when(basePacketRepository.getRegistrationIdbyRequestId(anyString())).thenReturn(Lists.newArrayList(manualVerificationEntity));

manualVerificationDTO.setStatusCode(ManualVerificationStatus.REJECTED.name());

ArgumentCaptor<MessageDTO> messageCaptor = ArgumentCaptor.forClass(MessageDTO.class);

Mockito.doNothing().when(manualAdjudicationStage).sendMessage(messageCaptor.capture());
boolean result = manualAdjudicationService.updatePacketStatus(adjudicationResponseDTO, stageName, queue);
assertTrue(result);
Comment thread
ashok-ksharma marked this conversation as resolved.
MessageDTO capturedMessage = messageCaptor.getValue();
assertNotNull(capturedMessage);
assertEquals(Boolean.FALSE, capturedMessage.getInternalError());
assertEquals(Boolean.FALSE, capturedMessage.getIsValid());
}

@Test
public void testProcessShouldHandleInvalidRidException() {

MessageDTO object = new MessageDTO();
object.setRid("");
object.setReg_type("NEW");
object.setIteration(1);
object.setWorkflowInstanceId("wf-123");

Mockito.when(registrationExceptionMapperUtil.getStatusCode(RegistrationExceptionTypeCode.MANUAL_VERIFICATION_FAILED))
.thenReturn("FAILED_CODE");

MessageDTO response = manualAdjudicationService.process(object, queue);
assertTrue(response.getInternalError());
assertFalse(response.getIsValid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public Integer getPort() {

/** The Constant CONFIG_SERVER_URL. */
private static final String CONFIG_SERVER_URL = "url";
private static final String IDREPO_STATUS = "DRAFTED";

private String identityMappingjsonString;

Expand Down Expand Up @@ -2775,4 +2776,206 @@ public void testProcess_WithLostPacket_ShouldReturnNull() throws Exception {
assertNull(demographicIdentity.get("packetCreatedOn"));
}

@Test
public void testProcessUinGenerationReprocessShouldSetReprocessStatus() throws IOException, PacketManagerException, ApisResourceAccessException, JsonProcessingException,
Comment thread
ashok-ksharma marked this conversation as resolved.
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.NEW.name());
IdResponseDTO idResponseDTO = new IdResponseDTO();
idResponseDTO.setErrors(errors);

when(utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utilities.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);
assertTrue(result.getInternalError());
assertTrue(result.getIsValid());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Test
public void testProcessUinGenerationFailedShouldSetFailedStatus() 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.NEW.name());
IdResponseDTO idResponseDTO = new IdResponseDTO();
idResponseDTO.setErrors(errors);

when(utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj);
Mockito.when(registrationStatusMapperUtil
.getStatusCode(RegistrationExceptionTypeCode.PACKET_UIN_GENERATION_FAILED)).thenReturn(RegistrationTransactionStatusCode.FAILED.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);
assertTrue(result.getInternalError());
assertFalse(result.getIsValid());
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

@Test
public void testLostAndUpdateUinWhenIdRepoDraftReturnsNullShouldSetValidStatusFalse() throws Exception {
Comment thread
ashok-ksharma marked this conversation as resolved.
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(utilities.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 testReactivateUinWhenStatusActivated() 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("DEACTIVATED");
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 testUinUpdateWhenIdRepoStatusDraftedShouldReturnTrue() 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(utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj);
when(utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj);

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

}
Loading