Пример #1
0
  @Test
  public void writeSaveOrderConfig() throws Exception {
    SaveOrderConfig saveOrderConfig =
        new SaveOrderConfig(
            false,
            new SaveOrderConfig.SortCriterion("author", false),
            new SaveOrderConfig.SortCriterion("year", true),
            new SaveOrderConfig.SortCriterion("abstract", false));
    metaData.setSaveOrderConfig(saveOrderConfig);

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

    assertEquals(
        OS.NEWLINE
            + "@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"
            + OS.NEWLINE,
        session.getStringValue());
  }
Пример #2
0
  @Test
  public void writeEntriesSorted() throws Exception {
    SaveOrderConfig saveOrderConfig =
        new SaveOrderConfig(
            false,
            new SaveOrderConfig.SortCriterion("author", false),
            new SaveOrderConfig.SortCriterion("year", true),
            new SaveOrderConfig.SortCriterion("abstract", false));
    metaData.setSaveOrderConfig(saveOrderConfig);

    BibEntry firstEntry = new BibEntry();
    firstEntry.setType(BibtexEntryTypes.ARTICLE);
    firstEntry.setField("author", "A");
    firstEntry.setField("year", "2000");

    BibEntry secondEntry = new BibEntry();
    secondEntry.setType(BibtexEntryTypes.ARTICLE);
    secondEntry.setField("author", "A");
    secondEntry.setField("year", "2010");

    BibEntry thirdEntry = new BibEntry();
    thirdEntry.setType(BibtexEntryTypes.ARTICLE);
    thirdEntry.setField("author", "B");
    thirdEntry.setField("year", "2000");

    database.insertEntry(secondEntry);
    database.insertEntry(thirdEntry);
    database.insertEntry(firstEntry);

    StringSaveSession session =
        databaseWriter.savePartOfDatabase(
            bibtexContext, database.getEntries(), new SavePreferences());

    assertEquals(
        OS.NEWLINE
            + "@Article{,"
            + OS.NEWLINE
            + "  author = {A},"
            + OS.NEWLINE
            + "  year   = {2000},"
            + OS.NEWLINE
            + "}"
            + OS.NEWLINE
            + OS.NEWLINE
            + "@Article{,"
            + OS.NEWLINE
            + "  author = {A},"
            + OS.NEWLINE
            + "  year   = {2010},"
            + OS.NEWLINE
            + "}"
            + OS.NEWLINE
            + OS.NEWLINE
            + "@Article{,"
            + OS.NEWLINE
            + "  author = {B},"
            + OS.NEWLINE
            + "  year   = {2000},"
            + OS.NEWLINE
            + "}"
            + OS.NEWLINE
            + OS.NEWLINE
            + "@Comment{jabref-meta: databaseType:bibtex;}"
            + OS.NEWLINE
            + OS.NEWLINE
            + "@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"
            + OS.NEWLINE,
        session.getStringValue());
  }