From 47d58c7843cf091e6fb73fb5ca44a32411055583 Mon Sep 17 00:00:00 2001 From: khuddus shariff Date: Mon, 18 Dec 2023 16:01:44 +0530 Subject: [PATCH] test case with empty error responce added Signed-off-by: khuddus shariff --- .../uigenerator/UinGeneratorStageTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) 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 a9b594f5bb2..b8a655d8ec9 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 @@ -2620,4 +2620,48 @@ public void testUinGenerationResponseWillExcedesRetryCount() throws Exception { MessageDTO result = uinGeneratorStage.process(messageDTO); assertTrue(result.getInternalError()); } + @Test + public void testUinGenerationSuccessWithoutUINwithErrorAsEmpty() throws Exception { + MessageDTO messageDTO = new MessageDTO(); + messageDTO.setRid("27847657360002520181210094052"); + 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 = "{\"uin\":\"6517036426\",\"status\":\"ASSIGNED\"}"; + when(registrationProcessorRestClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(str); + when(registrationProcessorRestClientService.putApi(any(), any(), any(), any(), any(), any(), any())) + .thenReturn(response); + messageDTO.setReg_type(RegistrationType.NEW); + IdResponseDTO idResponseDTO = new IdResponseDTO(); + ResponseDTO responseDTO = new ResponseDTO(); + responseDTO.setEntity("https://dev.mosip.io/idrepo/v1.0/identity/203560486746"); + responseDTO.setStatus("ACTIVATED"); + List errorList=new ArrayList<>(); + idResponseDTO.setErrors(errorList); + idResponseDTO.setId("mosip.id.create"); + idResponseDTO.setResponse(responseDTO); + idResponseDTO.setResponsetime("2019-01-17T06:29:01.940Z"); + idResponseDTO.setVersion("1.0"); + + ResponseWrapper responseVid = new ResponseWrapper(); + List errors = new ArrayList<>(); + responseVid.setErrors(errors); + responseVid.setVersion("v1"); + responseVid.setMetadata(null); + DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + LocalDateTime localdatetime = LocalDateTime + .parse(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"), format); + responseVid.setResponsetime(localdatetime); + VidResponseDto vidResponseDto = new VidResponseDto(); + vidResponseDto.setVID("123456"); + vidResponseDto.setVidStatus("ACTIVE"); + responseVid.setResponse(vidResponseDto); + + when(registrationProcessorRestClientService.postApi(any(), any(), any(), any(), any(Class.class))) + .thenReturn(idResponseDTO).thenReturn(responseVid).thenReturn(response); + + // Mockito.when(registrationProcessorRestClientService.postApi(any(), any(), + // any(), any(), any())); + + MessageDTO result = uinGeneratorStage.process(messageDTO); + assertFalse(result.getInternalError()); + } } \ No newline at end of file