How junit this observable async method
<p>I have repo that tests an async execution using java8 and reactive:</p>

<p>interface of zadd:</p>

<pre><code>Observable&lt;Long&gt; zadd(K key, double score, V member);



 public class TargetClass()
{
..
     public void executeMethod(List&lt;String&gt; input) {
            input.forEach(item -&gt; redisConnection.reactive().zadd(...).subscribe(
                    result -&gt; log.info("Success")
                    error -&gt; log.error("Failed...")
            ));
        }
..
}
</code></pre>

<p>my junit testing code:</p>

<pre><code>@Test
public void testMethod() {
  TargetClass targetClass=new TargetClass();
    targetClass.executeMethod(Arrays.asList("input1", "input2", "input3"));

    //as you can see I must put here Thread.sleep in order to let my execution to finish before continue since we have dependency on it

    try {
        Thread.sleep(4000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    //continue with testing..
</code></pre>

<p>how can I modify my code parts rights. It doesn't feel right to add <code>Thread.sleep</code> to let the async method code to take place</p>

<p>Thanks,
ray.</p>