Skip to content

Commit

Permalink
Fixed test cases error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mahammedtaheer committed Sep 15, 2023
1 parent 181e784 commit d4ab05b
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class AuthAnonymousProfileServiceImplTest {
Map<String, Object> requestMetadata = null;
Map<String, Object> responseMetadata = null;
Map<String,List<IdentityInfoDTO>> idInfoMap = null;
List<AuthError> errorCodes = null;

@Before
public void before() {
Expand All @@ -79,6 +80,7 @@ public void before() {
requestMetadata = new HashMap<>();
responseMetadata = new HashMap<>();
idInfoMap = new HashMap<String, List<IdentityInfoDTO>>();
errorCodes = new ArrayList<>();

ReflectionTestUtils.setField(anonymousProfileServiceImpl, "mapper", mapper);
ReflectionTestUtils.setField(idInfoHelper, "idInfoFetcher", idInfoFetcherImpl);
Expand All @@ -103,7 +105,7 @@ public void createAnonymousProfileWith_YourOfBirthTest() throws IdAuthentication
responseBody.put("response", authResponse);

Mockito.when(idInfoHelper.getEntityInfoAsString(DemoMatchType.DOB, idInfoMap)).thenReturn("1993/04/11");
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(anonymousProfile.getYearOfBirth(), "1993");
}

Expand All @@ -123,7 +125,7 @@ public void createAnonymousProfileWith_PreferredLangTest() throws IdAuthenticati
responseBody.put("response", authResponse);

Mockito.when(idInfoHelper.getDynamicEntityInfoAsString(idInfoMap, null, "preferredLanguage")).thenReturn("eng");
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(List.of("eng"), anonymousProfile.getPreferredLanguages());
}

Expand All @@ -143,7 +145,7 @@ public void createAnonymousProfileWith_GenderTest() throws IdAuthenticationBusin
responseBody.put("response", authResponse);

Mockito.when(idInfoHelper.getEntityInfoAsString(DemoMatchType.GENDER, "eng", idInfoMap)).thenReturn("Female");
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody,requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody,requestMetadata, responseMetadata, true, errorCodes);
assertEquals("Female", anonymousProfile.getGender());
}

Expand All @@ -168,7 +170,7 @@ public void createAnonymousProfileWith_LocationTest() throws IdAuthenticationBus
responseBody.put("response", authResponse);

Mockito.when(idInfoHelper.getIdEntityInfoMap(DemoMatchType.DYNAMIC, idInfoMap, "eng", "locationHierarchyForProfiling")).thenReturn(locationMap);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(List.of("zone1", "123456"), anonymousProfile.getLocation());
}

Expand Down Expand Up @@ -202,7 +204,7 @@ public void createAnonymousProfileWith_BiometricInfoTest() throws IdAuthenticati
authResponse.put("authStatus", "true");
authResponse.put("authToken", "1234567890");
responseBody.put("response", authResponse);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(1, anonymousProfile.getBiometricInfo().size());
assertEquals("Iris", anonymousProfile.getBiometricInfo().get(0).getType());
assertEquals("LEFT", anonymousProfile.getBiometricInfo().get(0).getSubtype());
Expand All @@ -221,7 +223,7 @@ public void createAnonymousProfileWith_AuthFactorsTest() throws IdAuthentication
authResponse.put("authToken", "1234567890");
responseBody.put("response", authResponse);

AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(3, anonymousProfile.getAuthFactors().size());
assertEquals(List.of("OTP-REQUEST","DEMO-AUTH","BIO-AUTH"), anonymousProfile.getAuthFactors());

Expand All @@ -234,7 +236,7 @@ public void createAnonymousProfileWith_PartnerTest() throws IdAuthenticationBusi
partner.setPartnerId("abc");
requestMetadata.put("partnerId", "abc");
requestMetadata.put("abc", partner);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, null);
AnonymousAuthenticationProfile anonymousProfile = ReflectionTestUtils.invokeMethod(anonymousProfileServiceImpl, "createAnonymousProfile",requestBody, requestMetadata, responseMetadata, true, errorCodes);
assertEquals(partner.getPartnerName(), anonymousProfile.getPartnerName());
}

Expand Down

0 comments on commit d4ab05b

Please sign in to comment.