diff --git a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/src/test/java/io/mosip/registration/processor/stages/biometric/extraction/stages/test/BiometricExtractionStageTest.java b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/src/test/java/io/mosip/registration/processor/stages/biometric/extraction/stages/test/BiometricExtractionStageTest.java index 2e582565e47..a443b07f2f5 100644 --- a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/src/test/java/io/mosip/registration/processor/stages/biometric/extraction/stages/test/BiometricExtractionStageTest.java +++ b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/src/test/java/io/mosip/registration/processor/stages/biometric/extraction/stages/test/BiometricExtractionStageTest.java @@ -10,6 +10,7 @@ import java.util.List; import org.apache.commons.io.IOUtils; +import org.assertj.core.util.Lists; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,6 +36,8 @@ import io.mosip.registration.processor.core.code.EventId; import io.mosip.registration.processor.core.code.EventName; import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; import io.mosip.registration.processor.core.constant.RegistrationType; import io.mosip.registration.processor.core.exception.ApisResourceAccessException; import io.mosip.registration.processor.core.http.ResponseWrapper; @@ -331,4 +334,26 @@ public void testBiometricExtractionDraftException() throws Exception { public void testDeployVerticle() { biometricExtractionStage.deployVerticle(); } + + @Test + public void testIdrepoDraftReprocessableException() throws Exception { + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setRid("27847657360002520181210094052"); + messageDTO.setReg_type(RegistrationType.NEW.name()); + messageDTO.setWorkflowInstanceId("123er"); + messageDTO.setIteration(1); + when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.IDREPO_DRAFT_REPROCESSABLE_EXCEPTION)) + .thenReturn("REPROCESS"); + ErrorDTO errorDTO = new ErrorDTO(); + errorDTO.setMessage("Failed to either encrypt/decrypt message using Kernel Crypto Manager"); + errorDTO.setErrorCode("IDR-IDS-003"); + IdResponseDTO idResponseDTO1 = new IdResponseDTO(); + idResponseDTO1.setErrors(Lists.newArrayList(errorDTO)); + when(registrationProcessorRestClientService.putApi(any(), any(), anyString(), anyString(), any(), any(), any())) + .thenReturn(idResponseDTO1); + MessageDTO result = biometricExtractionStage.process(messageDTO); + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } } diff --git a/registration-processor/core-processor/registration-processor-finalization-stage/src/test/java/io/mosip/registration/processor/stages/finalization/stage/tests/FinalizationStageTest.java b/registration-processor/core-processor/registration-processor-finalization-stage/src/test/java/io/mosip/registration/processor/stages/finalization/stage/tests/FinalizationStageTest.java index 5def776c4cd..f559b8ed629 100644 --- a/registration-processor/core-processor/registration-processor-finalization-stage/src/test/java/io/mosip/registration/processor/stages/finalization/stage/tests/FinalizationStageTest.java +++ b/registration-processor/core-processor/registration-processor-finalization-stage/src/test/java/io/mosip/registration/processor/stages/finalization/stage/tests/FinalizationStageTest.java @@ -29,6 +29,7 @@ import io.mosip.registration.processor.core.code.EventId; import io.mosip.registration.processor.core.code.EventName; import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; import io.mosip.registration.processor.core.constant.RegistrationType; import io.mosip.registration.processor.core.exception.ApisResourceAccessException; import io.mosip.registration.processor.core.http.ResponseWrapper; @@ -37,6 +38,7 @@ import io.mosip.registration.processor.packet.manager.dto.IdResponseDTO; import io.mosip.registration.processor.packet.manager.dto.ResponseDTO; import io.mosip.registration.processor.packet.manager.exception.IdrepoDraftException; +import io.mosip.registration.processor.packet.manager.exception.IdrepoDraftReprocessableException; import io.mosip.registration.processor.packet.manager.idreposervice.IdrepoDraftService; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; @@ -247,4 +249,20 @@ public void testBiometricExtractionUnknownException() throws Exception { public void testDeployVerticle() { finalizationStage.deployVerticle(); } + + @Test + public void testIdrepoDraftReprocessableException() throws Exception { + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setRid("27847657360002520181210094052"); + messageDTO.setReg_type(RegistrationType.NEW.name()); + messageDTO.setWorkflowInstanceId("123er"); + messageDTO.setIteration(1); + when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.IDREPO_DRAFT_REPROCESSABLE_EXCEPTION)) + .thenReturn("REPROCESS"); + when(idrepoDraftService.idrepoPublishDraft(anyString())).thenThrow(IdrepoDraftReprocessableException.class); + MessageDTO result = finalizationStage.process(messageDTO); + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } } diff --git a/registration-processor/core-processor/registration-processor-uin-generator-stage/src/test/java/io/mosip/registration/processor/stages/uigenerator/UinGeneratorStageTest.java b/registration-processor/core-processor/registration-processor-uin-generator-stage/src/test/java/io/mosip/registration/processor/stages/uigenerator/UinGeneratorStageTest.java index 43a261bf0d4..f3328aafd64 100644 --- a/registration-processor/core-processor/registration-processor-uin-generator-stage/src/test/java/io/mosip/registration/processor/stages/uigenerator/UinGeneratorStageTest.java +++ b/registration-processor/core-processor/registration-processor-uin-generator-stage/src/test/java/io/mosip/registration/processor/stages/uigenerator/UinGeneratorStageTest.java @@ -2413,5 +2413,23 @@ public void testUinUpdationIOExceptionFaliure() throws Exception { assertTrue(result.getInternalError()); assertTrue(result.getIsValid()); } - + + @Test + public void testUinGenerationIDRepoDraftReprocessableException() throws Exception { + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setRid("27847657360002520181210094052"); + messageDTO.setReg_type(RegistrationType.NEW.name()); + + when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.IDREPO_DRAFT_REPROCESSABLE_EXCEPTION)) + .thenReturn("REPROCESS"); + when(idrepoDraftService.idrepoUpdateDraft(anyString(), any(), any())) + .thenThrow(IdrepoDraftReprocessableException.class); + when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY)).thenReturn(identityObj); + when(utility.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT)).thenReturn(documentObj); + + MessageDTO result = uinGeneratorStage.process(messageDTO); + assertTrue(result.getInternalError()); + assertTrue(result.getIsValid()); + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-packet-manager/src/test/java/io/mosip/registration/processor/packet/manager/service/impl/test/IdrepoDraftServiceTest.java b/registration-processor/registration-processor-packet-manager/src/test/java/io/mosip/registration/processor/packet/manager/service/impl/test/IdrepoDraftServiceTest.java index 1925eebd183..580e2b3c17d 100644 --- a/registration-processor/registration-processor-packet-manager/src/test/java/io/mosip/registration/processor/packet/manager/service/impl/test/IdrepoDraftServiceTest.java +++ b/registration-processor/registration-processor-packet-manager/src/test/java/io/mosip/registration/processor/packet/manager/service/impl/test/IdrepoDraftServiceTest.java @@ -203,5 +203,29 @@ public void idrepoUpdateDraftExceptionTest() } + @Test(expected = IdrepoDraftReprocessableException.class) + public void idrepoDraftReprocessableExceptionTest() + throws ApisResourceAccessException, IdrepoDraftException, IOException, IdrepoDraftReprocessableException { + RequestDto requestDto = new RequestDto(); + requestDto.setIdentity(idResponseDTO.getResponse().getIdentity()); + IdRequestDto idRequestDto = new IdRequestDto(); + idRequestDto.setRequest(requestDto); + + ErrorDTO errorDTO = new ErrorDTO(); + errorDTO.setMessage("Failed to either encrypt/decrypt message using Kernel Crypto Manager"); + errorDTO.setErrorCode("IDR-IDS-003"); + IdResponseDTO idResponseDTO1 = new IdResponseDTO(); + idResponseDTO1.setErrors(Lists.newArrayList(errorDTO)); + + when(registrationProcessorRestClientService.headApi(ApiName.IDREPOHASDRAFT, Lists.newArrayList(ID), null, null)) + .thenReturn(200); + when(registrationProcessorRestClientService.getApi(ApiName.IDREPOGETDRAFT, Lists.newArrayList(ID), + Lists.emptyList(), null, IdResponseDTO.class)).thenReturn(idResponseDTO); + when(registrationProcessorRestClientService.patchApi(any(), any(), any(), any(), any(), any())) + .thenReturn(idResponseDTO1); + + idrepoDraftService.idrepoUpdateDraft(ID, null, idRequestDto); + + } }