@Test
public void should_persist_all_artifact_id_in_index_when_refresh_indexing_is_called() throws Exception {

    List<Page> pages = new ArrayList<>();
    Page page = PageBuilder.aPage().withUUID("baz-uuid").withId("page1").build();
    Page page2 = PageBuilder.aPage().withUUID("foo-uuid").withId("page2").withName("page2").build();
    pages.add(page);
    pages.add(page2);
    JsonFileBasedPersister<Page> pageRepository = new JsonFileBasedPersister<>(objectMapper, validator);
    Path metadataFolder = repoDirectory.resolve(".metadata");
    metadataFolder.toFile().mkdir();
    new Thread(() -> {
        try {
            pageRepository.refreshIndexing(metadataFolder, pages);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }).start();
    Awaitility.await()
            .atMost(3, TimeUnit.SECONDS)
            .untilAsserted(new ThrowingRunnable() {
                @Override
                public void run() throws Throwable {
                    String index = new String(readAllBytes(metadataFolder.resolve(".index.json")));
                    assertThat(index).contains("\"baz-uuid\":\"page1\"").contains("\"foo-uuid\":\"page2\"");
                }
            });
}