Skip to content

Commit

Permalink
MOSIP-29780 fixed test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Sowmya Ujjappa Banakar <[email protected]>
  • Loading branch information
Sowmya Ujjappa Banakar committed Nov 6, 2023
1 parent 3922076 commit ab30bb0
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

}

0 comments on commit ab30bb0

Please sign in to comment.