@Test
  public void writeMetadata() throws Exception {
    DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(prefs.getKeyPattern());
    bibtexKeyPattern.setDefaultValue("test");
    metaData.setCiteKeyPattern(bibtexKeyPattern);

    StringSaveSession session =
        databaseWriter.savePartOfDatabase(
            bibtexContext, Collections.emptyList(), new SavePreferences());

    assertEquals(
        OS.NEWLINE + "@Comment{jabref-meta: keypatterndefault:test;}" + OS.NEWLINE,
        session.getStringValue());
  }
  @Test
  public void writeMetadataAndEncoding() throws Exception {
    SavePreferences preferences = new SavePreferences().withEncoding(Charsets.US_ASCII);
    DatabaseBibtexKeyPattern bibtexKeyPattern = new DatabaseBibtexKeyPattern(prefs.getKeyPattern());
    bibtexKeyPattern.setDefaultValue("test");
    metaData.setCiteKeyPattern(bibtexKeyPattern);

    StringSaveSession session =
        databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), preferences);

    assertEquals(
        "% Encoding: US-ASCII"
            + OS.NEWLINE
            + OS.NEWLINE
            + "@Comment{jabref-meta: keypatterndefault:test;}"
            + OS.NEWLINE,
        session.getStringValue());
  }