import clashingdeps.jackson.cache.Cache;
import clashingdeps.jackson.cache.RedisJacksonBackedCache;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.GenericContainer;
import redis.clients.jedis.Jedis;

import java.util.Optional;

import static org.rnorth.visibleassertions.VisibleAssertions.*;

/**
 * Integration test for Redis-backed cache implementation.
 */
public class RedisJacksonBackedCacheTest {

    @Rule
    public GenericContainer redis = new GenericContainer("redis:3.0.6")
                                            .withExposedPorts(6379);
    private Cache cache;

    @Before
    public void setUp() throws Exception {
        Jedis jedis = new Jedis(redis.getContainerIpAddress(), redis.getMappedPort(6379));

        cache = new RedisJacksonBackedCache(jedis, "test");
    }

    @Test
    public void testFindingAnInsertedValue() {
        cache.put("foo", "FOO");
        Optional<String> foundObject = cache.get("foo", String.class);

        assertTrue("When an object in the cache is retrieved, it can be found",
                        foundObject.isPresent());
        assertEquals("When we put a String in to the cache and retrieve it, the value is the same",
                        "FOO",
                        foundObject.get());
    }

    @Test
    public void testNotFindingAValueThatWasNotInserted() {
        Optional<String> foundObject = cache.get("bar", String.class);

        assertFalse("When an object that's not in the cache is retrieved, nothing is found",
                foundObject.isPresent());
    }
}

@@ -164,16 +164,68 @@
 t.Test;%0A
+import org.rnorth.ducttape.unreliables.Unreliables;%0A
 import o
@@ -271,16 +271,16 @@
 tainer;%0A
-
 import r
@@ -332,16 +332,54 @@
 ptional;
+%0Aimport java.util.concurrent.TimeUnit;
 %0A%0Aimport
@@ -642,33 +642,40 @@
         
-                 
+.withExposedPorts(6379)%0A
         
@@ -682,33 +682,43 @@
     
-   
 .w
+a
 it
-hExposedPorts(6379
+ingFor(new RedisWaitStrategy()
 );%0A 
@@ -1194,32 +1194,24 @@
  be found%22,%0A
-        
             
@@ -1236,24 +1236,24 @@
 Present());%0A
+
         asse
@@ -1360,31 +1360,15 @@
     
-        %22FOO%22,%0A        
+%22FOO%22,%0A
     
@@ -1632,32 +1632,32 @@
 hing is found%22,%0A
-
                 
@@ -1687,11 +1687,463 @@
 );%0A    %7D
+%0A%0A    private class RedisWaitStrategy extends GenericContainer.AbstractWaitStrategy %7B%0A        @Override%0A        protected void waitUntilReady() %7B%0A            //noinspection LoopStatementThatDoesntLoop%0A            Unreliables.retryUntilSuccess(10, TimeUnit.SECONDS, () -%3E%0A            %7B%0A                Jedis jedis = new Jedis(redis.getContainerIpAddress(), redis.getMappedPort(6379));%0A                return jedis.ping();%0A            %7D);%0A        %7D%0A    %7D
 %0A%7D%0A

Add custom Redis wait strategy as an example and to mitigate #160