Skip to content

Commit

Permalink
adding testcase for array of string data type
Browse files Browse the repository at this point in the history
Signed-off-by: khuddus shariff <khuddusshariff0022@gmail.com>
  • Loading branch information
Khuddusshariff0022 committed Nov 7, 2024
1 parent a8a4071 commit cdc871a
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2520,4 +2520,47 @@ public void testUinGenerationSuccessWithSelectedHanhle() throws Exception {
assertFalse(result.getInternalError());
assertTrue(result.getIsValid());
}

@Test
public void testUinGenerationSuccessWithObjectDataType () throws Exception {
ReflectionTestUtils.setField(uinGeneratorStage,"trimWhitespaces",true);
Map<String, String> fieldMap = new HashMap<>();
fieldMap.put("individualBiometrics","{\n" +
" \"format\": \"cbeff\",\n" +
" \"value\": \"individualBiometrics_bio_CBEFF\",\n" +
" \"version\": 1\n" +
" }");
fieldMap.put("email", "mono@mono.com");
fieldMap.put("phoneNumber", "23456");
fieldMap.put("dob", "11/11/2011");
when(packetManagerService.getFields(any(),any(),any(),any())).thenReturn(fieldMap);
ArgumentCaptor<io.mosip.registration.processor.packet.manager.dto.IdRequestDto> argumentCaptor = ArgumentCaptor.forClass(IdRequestDto.class);

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

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

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

MessageDTO result = uinGeneratorStage.process(messageDTO);
verify(idrepoDraftService).idrepoUpdateDraft(any(), any(), argumentCaptor.capture());
ObjectMapper objectMapper = new ObjectMapper();
String jsonobject=objectMapper.writeValueAsString(argumentCaptor.getAllValues().get(0).getRequest().getIdentity());
JsonNode jsonNode=objectMapper.readTree(jsonobject);

assertEquals("cbeff",jsonNode.get("individualBiometrics").get("format").asText());
assertFalse(result.getInternalError());
assertTrue(result.getIsValid());
}
}

0 comments on commit cdc871a

Please sign in to comment.