diff --git a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/integration/NotificationManager.java b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/integration/NotificationManager.java index 43322798fd..770c2d80d8 100644 --- a/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/integration/NotificationManager.java +++ b/authentication/authentication-common/src/main/java/io/mosip/authentication/common/service/integration/NotificationManager.java @@ -56,8 +56,8 @@ public void sendSmsNotification(String notificationMobileNo, String message) RestRequestDTO restRequestDTO = null; restRequestDTO = restRequestFactory.buildRequest(RestServicesConstants.SMS_NOTIFICATION_SERVICE, RestRequestFactory.createRequest(smsRequestDto), String.class); - restHelper.requestAsync(restRequestDTO); - } catch (IDDataValidationException e) { + restHelper.requestSync(restRequestDTO); + } catch (IDDataValidationException | RestServiceException e) { logger.error(IdAuthCommonConstants.SESSION_ID, "Inside SMS Notification >>>>>", e.getErrorCode(), e.getErrorText()); throw new IdAuthenticationBusinessException(IdAuthenticationErrorConstants.DATA_VALIDATION_FAILED, e); } diff --git a/authentication/authentication-common/src/test/java/io/mosip/authentication/common/service/integration/NotificationManagerTest.java b/authentication/authentication-common/src/test/java/io/mosip/authentication/common/service/integration/NotificationManagerTest.java index 069ca625ab..752a3bfaf5 100644 --- a/authentication/authentication-common/src/test/java/io/mosip/authentication/common/service/integration/NotificationManagerTest.java +++ b/authentication/authentication-common/src/test/java/io/mosip/authentication/common/service/integration/NotificationManagerTest.java @@ -5,6 +5,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; +import io.mosip.idrepository.core.constant.IdRepoErrorConstants; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -116,4 +117,13 @@ public void TestInvalidNotificationConfig() throws IdAuthenticationBusinessExcep Mockito.when(restHelper.requestAsync(Mockito.any())).thenReturn(Supplier); notificationManager.sendEmailNotification("abc@test.com", "test", "test"); } + + @Test(expected = IdAuthenticationBusinessException.class) + public void testInValidSendNotificationPhone() throws IdAuthenticationBusinessException, RestServiceException { + Set notificationtype = new HashSet<>(); + notificationtype.add(NotificationType.SMS); + Mockito.when(restHelper.requestSync(Mockito.any())) + .thenThrow(new RestServiceException(IdRepoErrorConstants.UNKNOWN_ERROR)); + notificationManager.sendSmsNotification("1234567890", "test"); + } }