-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ritik Jain <[email protected]>
- Loading branch information
Ritik Jain
authored and
Ritik Jain
committed
Nov 10, 2023
1 parent
95e696e
commit 86685ba
Showing
2 changed files
with
28 additions
and
39 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,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<DownloadPersonalizedCardDto> 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", "[email protected]"); | ||
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<String, Object> 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<byte[], String> 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"); | ||
|