-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mosip-30240]Release 1.2.0.1 mosip 30240 (#1840)
* Merge pull request #1831 from Khuddusshariff0022/develop_Mosip_30241 MOSIP-30241 adding trim functionality based on property. Signed-off-by: khuddus shariff <[email protected]> * [Mosip-30241] Merge pull request #1831 from Khuddusshariff0022/develop-Mosip_30241 Signed-off-by: khuddus shariff <[email protected]> --------- Signed-off-by: khuddus shariff <[email protected]> Co-authored-by: Vishwa <[email protected]>
- Loading branch information
1 parent
4137411
commit 1d4ce75
Showing
5 changed files
with
99 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package io.mosip.registration.processor.stages.uigenerator; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.*; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyDouble; | ||
import static org.mockito.ArgumentMatchers.anyList; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.File; | ||
|
@@ -15,13 +14,19 @@ | |
import java.io.InputStream; | ||
import java.lang.reflect.Field; | ||
import java.nio.charset.StandardCharsets; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.mosip.kernel.core.util.DateUtils; | ||
import io.mosip.registration.processor.packet.manager.dto.IdRequestDto; | ||
import io.mosip.registration.processor.stages.uingenerator.dto.VidResponseDto; | ||
import org.apache.commons.io.IOUtils; | ||
import org.assertj.core.util.Lists; | ||
import org.json.JSONException; | ||
|
@@ -30,11 +35,7 @@ | |
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.Spy; | ||
import org.mockito.*; | ||
import org.powermock.api.mockito.PowerMockito; | ||
import org.powermock.core.classloader.annotations.PowerMockIgnore; | ||
import org.powermock.core.classloader.annotations.PrepareForTest; | ||
|
@@ -144,13 +145,13 @@ public void send(MessageBusAddress toAddress, MessageDTO message) { | |
|
||
@Override | ||
public void consumerHealthCheck(Handler<HealthCheckDTO> eventHandler, String address) { | ||
// TODO Auto-generated method stub | ||
|
||
|
||
} | ||
|
||
@Override | ||
public void senderHealthCheck(Handler<HealthCheckDTO> eventHandler, String address) { | ||
// TODO Auto-generated method stub | ||
|
||
|
||
} | ||
|
||
|
@@ -2432,4 +2433,46 @@ public void testUinGenerationIDRepoDraftReprocessableException() throws Exceptio | |
assertTrue(result.getInternalError()); | ||
assertTrue(result.getIsValid()); | ||
} | ||
|
||
@Test | ||
public void testUinGenerationSuccessWithEmptyName() throws Exception { | ||
ReflectionTestUtils.setField(uinGeneratorStage,"trimWhitespaces",true); | ||
Map<String, String> fieldMap = new HashMap<>(); | ||
fieldMap.put("firstName","[ {\n" + | ||
" \"language\" : \"eng\",\n" + | ||
" \"value\" : \" \"\n" + | ||
"} ]"); | ||
fieldMap.put("email", "[email protected]"); | ||
fieldMap.put("phone", "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("",jsonNode.get("firstName").asText()); | ||
assertFalse(result.getInternalError()); | ||
assertTrue(result.getIsValid()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters