package org.graphwalker.java.source.cache;

import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.junit.Assert.*;

public class SimpleCacheTest {

  @Test
  public void get() throws IOException {
    SimpleCache cache = new SimpleCache(Paths.get("./"));
    // create temporary file
    File foo = File.createTempFile("prefix", "suffix");
    foo.deleteOnExit();
    Path key = foo.toPath();
    long lastModified = foo.lastModified();
    cache.add(key, new CacheEntry(lastModified, true));
    CacheEntry cached = cache.get(key);
    assertEquals(lastModified, cached.getLastModifiedTime().toMillis());
    assertEquals(true, cached.isGenerated());

    assertTrue(cache.contains(key));
  }
}

@@ -800,14 +800,103 @@
 (key));%0A
+    %0A      // Clean up after test%0A      assertTrue( new File(%22./cache.json%22).delete() );%0A
   %7D%0A%7D%0A

Clean up after test