Skip to main content

All Questions

Filter by
Sorted by
Tagged with
0 votes
0 answers
51 views

JUnit integration test fails but Postman test passes with NullPointerException

Please ignore the excessive proliferation of logging. I'm desperate. The code below works when I run the application as a Spring Boot Applicant and use Postman to do a PUT with all of the same ...
joe gaber's user avatar
0 votes
1 answer
123 views

JUnit Test method invocation with CompletableFuture.supplyAsync

in my class i have i class-field, which i'am verfing, that the method of this class-field is invoked three times. Now i moved the logic to "CompletableFuture.sypplyAsync" approach and it ...
Roma Kap's user avatar
  • 636
0 votes
1 answer
211 views

PowerMockito verifyStatic: validating async call to static method

I'm making call to an external system via a static method MyExternalServiceAccessor.myMethod(param1, param2); And so far I've been unit-testing above using PowerMockito's verifyStatic as follows ...
y2k-shubham's user avatar
  • 11.7k
0 votes
1 answer
106 views

How to test private method passed in the supplier method of CompletableFuture.supplyAsync method?

I want to write JUnit test for a public method which uses CompletableFuture.supplyAsync to process some data and then save it to the DB. However, the supplier method passed contains a private method ...
Gargi Chaurasia's user avatar
2 votes
1 answer
1k views

Mocking static objects under completable future supply async

Consider below code snippet: class XYZ { public static getFieldABC(){ return new ABC(); } } ... CompletableFuture.supplyAsync(() -> XYZ.getFieldABC()) ... I need to unit test this piece of ...
Jay Patel's user avatar
0 votes
0 answers
303 views

Unit testing CompletableFutures, Junit, Mockito, @RunWith(SpringRunner.class)

I need help testing this CF's. public class RateHandler { public Response firstMethod(RateRequest, Context context) { CompletableFuture<Response> rateRespCf = CompletableFuture....
sai23's user avatar
  • 149
2 votes
1 answer
1k views

How to write JUnit5 or Mockito test for a retry mechanism built using Supplier<CompletableFuture> as a method param?

Have a common framework that isn't server specific which we use to import and re-use objects inside our microservices but can be used for any particular Java program which supports Java 8. Was tasked ...
PacificNW_Lover's user avatar
0 votes
1 answer
1k views

Mocking the CompletableFuture.join() for IntegrationTests

Iam writing the Integration test cases and i was stuck at point where i was not able to mock the CompletableFuture.join() Firstly, I will make an async call and add all the responses to list @Async(&...
J Harish's user avatar
  • 195
3 votes
2 answers
15k views

Testing CompletableFuture.supplyAsync with Mockito

I am trying to test CompletableFuture.supplyAsync function with mockito but the test is not completing probably because the completable future is not returning. I am not sure what I am missing in the ...
rakesh's user avatar
  • 304
0 votes
1 answer
950 views

How to mock a CompletableFuture in Kotlin

We have some code to read data from DynamoDB: suspend fun getKeys(owner: String): Set<String> { ... val query = ... query.subscribe { page -> foo(page) }.await() return ... } ...
Deqing's user avatar
  • 14.7k
0 votes
1 answer
266 views

Test method which invokes another method with runAsync() block

I would be grateful for any advice or practices which you follow. We use Mockito and Junit4/5 to to write unit tests. However, I see that some tests fail at prod (when at the end of a test you verify ...
John Smith's user avatar
0 votes
1 answer
2k views

Unit tests for testing methods returning CompletableFuture always returns NullPointerException

I have a SpringBoot Component and few methods. It returns CompletableFuture and I want to cover those lines with Unit Tests. But it always ends up in NullPointer Exception. @Component Class ...
Prasaanth's user avatar
  • 101
2 votes
0 answers
440 views

How to test that method is called after all previous async tasks are done? CompletableFuture in java

I have a case where I have three methods like this: public void mainMethod() { foo1(); foo2(); bar(); } In second method (foo2) I am using CompletableFuture to block all async tasks which ...
MrFisherman's user avatar
0 votes
1 answer
743 views

Java - Mockito - CompletableFutures - Unexpected Result of Tested Method

I have a very strange corner case where a future doesn't complete as expected once every couple of thousands of runs. Only way I'm able to consistently trigger the fault is to have the test run on ...
David S's user avatar
  • 187
1 vote
1 answer
5k views

Testing CompletableFuture.allOf. join takes forever

I am trying to test a method that uses CompletableFuture.allOf. I mock the futures so that they return the needed value when joined. for some reason which I can't understand. join() of result takes ...
Avishai Yaniv's user avatar

15 30 50 per page