@Before
  public void before() {
    localKeyValueStoreServiceBuilder =
        LowLevelLocalKeyValueStoreServiceBuilder.localKeyValueStoreBuilder();

    testTimer = new TestTimer();
    testTimer.setTime();

    localKeyValueStoreServiceBuilder.useDefaultFlushCacheDuration();
    localKeyValueStoreServiceBuilder.setTimer(testTimer).build();
    localKeyValueStoreService = localKeyValueStoreServiceBuilder.setDebug(true).build();

    localKeyValueStoreService.process();

    jsonKeyValueStoreServiceBuilder =
        JsonKeyValueStoreServiceBuilder.jsonKeyValueStoreServiceBuilder();

    jsonKeyValueStoreServiceBuilder.setLowLevelKeyValueStoreService(localKeyValueStoreService);

    keyValueStoreService = jsonKeyValueStoreServiceBuilder.buildKeyValueStore(Todo.class);
  }
  @Test
  public void testTodo() {
    final boolean[] hasKeyRef = new boolean[1];
    final String[] valueHolder = new String[1];
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    assertEquals(false, hasKeyRef[0]);
    keyValueStoreService.put("key", new Todo("value"));
    keyValueStoreService.process();

    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(true, hasKeyRef[0]);

    keyValueStoreService.get(
        returnValue -> {
          if (returnValue.isPresent()) {
            valueHolder[0] = returnValue.get().name;
          }
        },
        "key");

    keyValueStoreService.process();
    assertEquals("value", valueHolder[0]);

    keyValueStoreService.delete("key");
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(false, hasKeyRef[0]);

    keyValueStoreService.putWithTimeout("key", new Todo("value"), TEN_SECONDS);
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(true, hasKeyRef[0]);

    testTimer.seconds(5);
    keyValueStoreService.process();
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(true, hasKeyRef[0]);

    keyValueStoreService.get(
        returnValue -> {
          if (returnValue.isPresent()) {
            valueHolder[0] = returnValue.get().name;
          }
        },
        "key");

    keyValueStoreService.process();

    assertEquals("value", valueHolder[0]);

    testTimer.seconds(6);
    keyValueStoreService.process();
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(false, hasKeyRef[0]);

    valueHolder[0] = null;

    keyValueStoreService.get(
        returnValue -> {
          if (returnValue.isPresent()) {
            valueHolder[0] = returnValue.get().name;
          }
        },
        "key");

    keyValueStoreService.process();

    assertNull(valueHolder[0]);

    //

    keyValueStoreService.putWithTimeout("key", new Todo("value"), TEN_SECONDS);
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(true, hasKeyRef[0]);

    testTimer.seconds(5);
    localKeyValueStoreService.process();

    keyValueStoreService.get(
        returnValue -> {
          if (returnValue.isPresent()) {
            valueHolder[0] = returnValue.get().name;
          }
        },
        "key");

    keyValueStoreService.process();
    assertEquals("value", valueHolder[0]);

    testTimer.seconds(6);
    keyValueStoreService.process();

    valueHolder[0] = null;

    keyValueStoreService.get(
        returnValue -> {
          if (returnValue.isPresent()) {
            valueHolder[0] = returnValue.get().name;
          }
        },
        "key");
    assertNull(valueHolder[0]);

    //

    keyValueStoreService.putWithConfirmation(aBoolean -> {}, "key", new Todo("value"));
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();
    assertEquals(true, hasKeyRef[0]);
    keyValueStoreService.delete("key");

    //

    keyValueStoreService.putWithConfirmationAndTimeout(
        aBoolean -> {}, "key", new Todo("value"), TEN_SECONDS);
    keyValueStoreService.hasKey(hasKey -> hasKeyRef[0] = hasKey, "key");
    keyValueStoreService.process();

    assertEquals(true, hasKeyRef[0]);
    keyValueStoreService.delete("key");

    keyValueStoreService.deleteWithConfirmation(aBoolean -> {}, "key");

    jsonKeyValueStoreServiceBuilder.setJsonMapper(null);
    jsonKeyValueStoreServiceBuilder.setReactor(null);

    jsonKeyValueStoreServiceBuilder.buildKeyListOfValueStore(Todo.class);
  }