I need help to write mockito test case for below method.
public void getCouponAndNotifyAsync(String countryId, String channelId,
String storeNumber, String clientId, NotificationRequest notificationRequest)
throws FirestoreException, TurneroServiceException {
CompletableFuture.runAsync(() -> getCouponAndNotify(countryId, channelId,
storeNumber, clientId, notificationRequest));
}
Where getCouponAndNotify() is a void method.
Tried below but its not working
@Test
public void getCouponAndNotifyAsync() throws Exception {
//doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all"));
CompletableFuture<Void> runAsync = CompletableFuture
.runAsync(() -> doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all")));
assertTrue(runAsync.isDone());
}
Updated test cases but still not working.
@Test
public void getCouponAndNotifyAsync() throws Exception {
//doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all"));
CompletableFuture<Void> runAsync = CompletableFuture
.runAsync(() -> doNothing().when(turneroService).getCouponAndNotify(COUNTRYID, CHANNELID, STORENUMBER, CLIENTID, new NotificationRequest("ext_rborse@falabella.cl", "all")));
assertTrue(ForkJoinPool.commonPool().awaitQuiescence(5, TimeUnit.SECONDS));
assertTrue(runAsync.isDone());
}