@Test
  public void shouldSyncReposToDisk() throws ClassNotFoundException, IOException {
    SubsetSizeRepo subsetRepo = factory.createSubsetRepo("dev", LATEST_VERSION);
    SuiteTimeRepo suiteTimeRepo = factory.createSuiteTimeRepo("dev", LATEST_VERSION);
    SuiteResultRepo suiteResultRepo = factory.createSuiteResultRepo("dev", LATEST_VERSION);
    subsetRepo.add(new SubsetSizeEntry(10));
    suiteTimeRepo.update(new SuiteTimeEntry("foo.bar.Quux", 25));
    suiteResultRepo.update(new SuiteResultEntry("foo.bar.Baz", true));

    assertThat(
        "No files should exist as sync on this factory has never been called.",
        baseDir.list().length,
        is(0));

    factory.syncReposToDisk();

    assertThat(
        "Files should exist as sync on this factory has been called.",
        baseDir.list().length,
        is(3));

    assertContentIs(EntryRepoFactory.name("dev", LATEST_VERSION, SUBSET_SIZE), "10");
    assertContentIs(EntryRepoFactory.name("dev", LATEST_VERSION, SUITE_TIME), "foo.bar.Quux: 25");
    assertContentIs(
        EntryRepoFactory.name("dev", LATEST_VERSION, SUITE_RESULT), "foo.bar.Baz: true");
  }
  @Test
  public void should_NOT_SyncReposToDisk_unlessDirty() throws ClassNotFoundException, IOException {
    SubsetSizeRepo subsetRepo = factory.createSubsetRepo("dev", LATEST_VERSION);
    SuiteTimeRepo suiteTimeRepo = factory.createSuiteTimeRepo("dev", LATEST_VERSION);
    SuiteResultRepo suiteResultRepo = factory.createSuiteResultRepo("dev", LATEST_VERSION);
    subsetRepo.add(new SubsetSizeEntry(10));
    suiteTimeRepo.update(new SuiteTimeEntry("foo.bar.Quux", 25));
    suiteResultRepo.update(new SuiteResultEntry("foo.bar.Baz", true));

    factory.syncReposToDisk();

    FileUtils.cleanDirectory(baseDir);

    assertThat(baseDir.list().length, is(0));

    factory.syncReposToDisk();

    assertThat(
        "No files should exist as no repos were dirty when sync-to-disk was called.",
        baseDir.list().length,
        is(0));

    subsetRepo.add(new SubsetSizeEntry(21));
    suiteTimeRepo.update(new SuiteTimeEntry("foo.bar.Bang", 35));
    suiteResultRepo.update(new SuiteResultEntry("foo.bar.Baz", true));

    factory.syncReposToDisk();

    assertThat(
        "Files should exist as sync on this factory has been called.",
        baseDir.list().length,
        is(3));

    assertContentIs(EntryRepoFactory.name("dev", LATEST_VERSION, SUBSET_SIZE), "10", "21");
    assertContentIs(
        EntryRepoFactory.name("dev", LATEST_VERSION, SUITE_TIME),
        "foo.bar.Quux: 25",
        "foo.bar.Bang: 35");
    assertContentIs(
        EntryRepoFactory.name("dev", LATEST_VERSION, SUITE_RESULT), "foo.bar.Baz: true");
  }
  @Test
  public void shouldBeAbleToLoadFromDumpedFile()
      throws ClassNotFoundException, IOException, InterruptedException {
    SubsetSizeRepo subsetSizeRepo = factory.createSubsetRepo("foo", LATEST_VERSION);
    subsetSizeRepo.add(new SubsetSizeEntry(50));
    subsetSizeRepo.add(new SubsetSizeEntry(100));
    subsetSizeRepo.add(new SubsetSizeEntry(200));

    SuiteTimeRepo subsetTimeRepo = factory.createSuiteTimeRepo("bar", LATEST_VERSION);
    subsetTimeRepo.update(new SuiteTimeEntry("foo.bar.Baz", 10));
    subsetTimeRepo.update(new SuiteTimeEntry("bar.baz.Quux", 20));

    SuiteResultRepo subsetResultRepo = factory.createSuiteResultRepo("baz", LATEST_VERSION);
    subsetResultRepo.update(new SuiteResultEntry("foo.bar.Baz", true));
    subsetResultRepo.update(new SuiteResultEntry("bar.baz.Quux", false));

    Thread exitHook = factory.exitHook();
    exitHook.start();
    exitHook.join();
    EntryRepoFactory otherFactoryInstance = new EntryRepoFactory(env());
    assertThat(
        otherFactoryInstance.createSubsetRepo("foo", LATEST_VERSION).list(),
        is(
            (Collection<SubsetSizeEntry>)
                Arrays.asList(
                    new SubsetSizeEntry(50), new SubsetSizeEntry(100), new SubsetSizeEntry(200))));
    assertThat(
        otherFactoryInstance.createSuiteTimeRepo("bar", LATEST_VERSION).list().size(), is(2));
    assertThat(
        otherFactoryInstance.createSuiteTimeRepo("bar", LATEST_VERSION).list(),
        hasItems(new SuiteTimeEntry("foo.bar.Baz", 10), new SuiteTimeEntry("bar.baz.Quux", 20)));
    assertThat(
        otherFactoryInstance.createSuiteResultRepo("baz", LATEST_VERSION).list().size(), is(2));
    assertThat(
        otherFactoryInstance.createSuiteResultRepo("baz", LATEST_VERSION).list(),
        hasItems(
            new SuiteResultEntry("foo.bar.Baz", true),
            new SuiteResultEntry("bar.baz.Quux", false)));
  }