diff --git a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java index 8606ef3588d..07a779587b9 100644 --- a/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java +++ b/resident/resident-service/src/main/java/io/mosip/resident/service/impl/DownloadCardServiceImpl.java @@ -275,16 +275,13 @@ public Tuple2 downloadPersonalizedCard( return Tuples.of(utility.signPdf(new ByteArrayInputStream(decodedData), password), eventId); } - Map getIdentityData(String individualId) throws IOException { + private Map getIdentityData(String individualId) { Map identityAttributes = null; try { - identityAttributes = (Map) identityService.getIdentityAttributes(individualId, null); + identityAttributes = (Map) identityService.getIdentity(individualId); } catch (ResidentServiceCheckedException e) { logger.error("Unable to get attributes- " + e); throw new ResidentServiceException(ResidentErrorCode.DOWNLOAD_PERSONALIZED_CARD, e); - } catch (IOException e) { - logger.error("Unable to get attributes- " + e); - throw new IOException(ResidentErrorCode.DOWNLOAD_PERSONALIZED_CARD.getErrorCode(), e); } return identityAttributes; } diff --git a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/DownloadCardServiceTest.java b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/DownloadCardServiceTest.java index f8a9b091692..c7408980877 100644 --- a/resident/resident-service/src/test/java/io/mosip/resident/service/impl/DownloadCardServiceTest.java +++ b/resident/resident-service/src/test/java/io/mosip/resident/service/impl/DownloadCardServiceTest.java @@ -1,5 +1,26 @@ package io.mosip.resident.service.impl; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.isNull; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.core.env.Environment; +import org.springframework.test.context.ContextConfiguration; + import io.mosip.kernel.core.exception.BaseCheckedException; import io.mosip.kernel.core.exception.ServiceError; import io.mosip.resident.constant.IdType; @@ -30,30 +51,9 @@ import io.mosip.resident.util.ResidentServiceRestClient; import io.mosip.resident.util.Utilities; import io.mosip.resident.util.Utility; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.core.env.Environment; -import org.springframework.test.context.ContextConfiguration; import reactor.util.function.Tuple2; import reactor.util.function.Tuples; -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.isNull; - /** * This class is used to create service class test for getting cards. * @@ -107,7 +107,7 @@ public class DownloadCardServiceTest { private MainRequestDTO downloadPersonalizedCardMainRequestDTO; - private Map identityMap; + private IdentityDTO identityMap; private ResidentTransactionEntity residentTransactionEntity; @@ -144,7 +144,7 @@ public void setup() throws Exception { Mockito.when(identityService.getResidentIndvidualIdFromSession()).thenReturn("1234567890"); Mockito.when(idAuthService.validateOtpV2(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(Tuples.of(true, residentTransactionEntity)); - identityMap = new LinkedHashMap(); + identityMap = new IdentityDTO(); identityMap.put("UIN", "8251649601"); identityMap.put("email", "manojvsp12@gmail.com"); identityMap.put("phone", "9395910872"); @@ -155,8 +155,7 @@ public void setup() throws Exception { Mockito.when(identityService.getIdentity("1234567890")).thenReturn(identityDTO); Mockito.when(identityService.getIdentity("7841261580")).thenReturn(identityDTO); identityDTO.setUIN("123"); - Map identityAttributes = new HashMap<>(); - Mockito.when(identityService.getIdentityAttributes("1234567890",null)).thenReturn(identityAttributes); + Mockito.when(identityService.getIdentity("1234567890")).thenReturn(new IdentityDTO()); } @Test @@ -214,7 +213,7 @@ public void testDownloadPersonalizedCardWithAttributesListAndPassword() name.put("language", "eng"); name.put("value", "kamesh"); identityMap.put("firstName", List.of(name)); - Mockito.when(identityService.getIdentityAttributes(Mockito.anyString(), isNull())).thenReturn(identityMap); + Mockito.when(identityService.getIdentity(Mockito.anyString())).thenReturn(identityMap); Mockito.when(utilities.getLanguageCode()).thenReturn("eng"); Mockito.when(utility.getPassword(Mockito.anyList())).thenReturn("kame1970"); Tuple2 actualResult = downloadCardService @@ -234,18 +233,11 @@ public void testDownloadPersonalizedCardPasswordFailed() throws ResidentServiceC @Test(expected = ResidentServiceException.class) public void testDownloadPersonalizedCardResidentServiceCheckedException() throws ResidentServiceCheckedException, IOException { - Mockito.when(identityService.getIdentityAttributes(Mockito.anyString(), Mockito.isNull())) + Mockito.when(identityService.getIdentity(Mockito.anyString())) .thenThrow(new ResidentServiceCheckedException()); downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO, 0, LOCALE_EN_US); } - @Test(expected = ResidentServiceException.class) - public void testDownloadPersonalizedCardIOException() throws ResidentServiceCheckedException, IOException { - Mockito.when(identityService.getIdentityAttributes(Mockito.anyString(), Mockito.isNull())) - .thenThrow(new IOException()); - downloadCardService.downloadPersonalizedCard(downloadPersonalizedCardMainRequestDTO, 0, LOCALE_EN_US); - } - @Test public void testGetVidCardEventIdWithVidDetails() throws BaseCheckedException, IOException { Mockito.when(identityService.getResidentIndvidualIdFromSession()).thenReturn("3257091426984315");