@Test
public void testGet() throws Exception {

    final MemoryPersistentStore persistentStore = new MemoryPersistentStore();
    this.formatterCache = new FormatterCache(persistentStore, 1, 5000);
    final boolean hideWithheld = true;
    final long changeDate = new Date().getTime();
    final Key key = new Key(1, "eng", FormatType.html, "full_view", hideWithheld, FormatterWidth._100);
    final TestLoader loader = new TestLoader("result", changeDate, false);
    String result = getAsString(key, changeDate, loader);
    assertEquals("result", result);
    StoreInfoAndData info = persistentStore.get(key);
    assertEquals(changeDate, info.getChangeDate());
    assertEquals(false, info.isPublished());
    assertEquals("result", info.getDataAsString());
    StoreInfo basicInfo = persistentStore.getInfo(key);
    assertEquals(changeDate, basicInfo.getChangeDate());
    assertEquals(false, basicInfo.isPublished());
    result = getAsString(key, changeDate, new Callable<StoreInfoAndDataLoadResult>() {
        @Override
        public StoreInfoAndDataLoadResult call() throws Exception {
            throw new AssertionError("Should not be called because cache should be up-to-date");
        }
    });
    assertEquals("result", result);
    final long updatedChangeDate = changeDate + 600;
    result = getAsString(key, updatedChangeDate, new TestLoader("newVal", updatedChangeDate, false));
    assertEquals("newVal", result);
    info = persistentStore.get(key);
    assertEquals(updatedChangeDate, info.getChangeDate());
    assertEquals(false, info.isPublished());
    assertEquals("newVal", info.getDataAsString());
    basicInfo = persistentStore.getInfo(key);
    assertEquals(updatedChangeDate, basicInfo.getChangeDate());
    assertEquals(false, basicInfo.isPublished());
}