@Test
  public void roundtripWithUserCommentBeforeStringAndChange() throws Exception {
    Path testBibtexFile = Paths.get("src/test/resources/testbib/complex.bib");
    Charset encoding = StandardCharsets.UTF_8;
    ParserResult result =
        new BibtexParser(importFormatPreferences)
            .parse(Importer.getReader(testBibtexFile, encoding));

    for (BibtexString string : result.getDatabase().getStringValues()) {
      // Mark them as changed
      string.setContent(string.getContent());
    }

    SavePreferences preferences =
        new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
    BibDatabaseContext context =
        new BibDatabaseContext(
            result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));

    StringSaveSession session =
        databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);

    try (Scanner scanner = new Scanner(testBibtexFile, encoding.name())) {
      assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
    }
  }
  @Test
  public void roundtripWithUserCommentAndEntryChange() throws Exception {
    Path testBibtexFile = Paths.get("src/test/resources/testbib/bibWithUserComments.bib");
    Charset encoding = StandardCharsets.UTF_8;
    ParserResult result =
        new BibtexParser(importFormatPreferences)
            .parse(Importer.getReader(testBibtexFile, encoding));

    BibEntry entry = result.getDatabase().getEntryByKey("1137631").get();
    entry.setField("author", "Mr. Author");

    SavePreferences preferences =
        new SavePreferences().withEncoding(encoding).withSaveInOriginalOrder(true);
    BibDatabaseContext context =
        new BibDatabaseContext(
            result.getDatabase(), result.getMetaData(), new Defaults(BibDatabaseMode.BIBTEX));

    StringSaveSession session =
        databaseWriter.savePartOfDatabase(context, result.getDatabase().getEntries(), preferences);

    try (Scanner scanner =
        new Scanner(
            Paths.get("src/test/resources/testbib/bibWithUserCommentAndEntryChange.bib"),
            encoding.name())) {
      assertEquals(scanner.useDelimiter("\\A").next(), session.getStringValue());
    }
  }