APISonar


org.jabref.model.entry.field.StandardField.DATE

> org > jabref > model > entry > field > StandardField > DATE
org APIs jabref APIs model APIs entry APIs field APIs StandardField APIs DATE APIs

Example 1
void cleanupDatesConvertsToCorrectFormat() {
        CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true,
                Collections.singletonList(new FieldFormatterCleanup(StandardField.DATE, new NormalizeDateFormatter()))));
        BibEntry entry = new BibEntry();
        entry.setField(StandardField.DATE, "01/1999");

        worker.cleanup(preset, entry);
        assertEquals(Optional.of("1999-01"), entry.getField(StandardField.DATE));
    }
Example 2
void parseRecognizesDateFieldWithConcatenation() throws IOException {
        ParserResult result = parser
                .parse(new StringReader("@article{test,date = {1-4~} # nov}"));

        Collection<BibEntry> parsed = result.getDatabase().getEntries();
        BibEntry entry = parsed.iterator().next();

        assertEquals(1, parsed.size());
        assertEquals(StandardEntryType.Article, entry.getType());
        assertEquals(Optional.of("test"), entry.getCiteKeyOptional());
        assertEquals(2, entry.getFields().size());
        assertEquals(Optional.of("1-4~#nov#"), entry.getField(StandardField.DATE));
    }
Example 3
public void searchByIdWithOldHtmlFormatWithoutDateCheck(String id) throws FetcherException {
        Optional<BibEntry> fetchedEntry = fetcher.performSearchById(id);
        assertTrue(fetchedEntry.isPresent(), "Expected to get an entry for id " + id);
        assertNotEquals(Optional.empty(), fetchedEntry.get().getField(StandardField.DATE), "Expected non empty date field, entry is\n" + fetchedEntry.toString());
        assertTrue(fetchedEntry.get().getField(StandardField.DATE).get().length() == 10, "Expected yyyy-MM-dd date format, entry is\n" + fetchedEntry.toString());
        assertNotEquals(Optional.empty(), fetchedEntry.get().getField(StandardField.ABSTRACT), "Expected non empty abstract field, entry is\n" + fetchedEntry.toString());
    }
Example 4
public void searchByIdWithOldHtmlFormatAndCheckDate() throws FetcherException {
        Optional<BibEntry> fetchedEntry = fetcher.performSearchById("1997/006");
        assertEquals(Optional.of("1997-05-04"), fetchedEntry.get().getField(StandardField.DATE));
    }
Example 5
public void cleanupWithDateAlreadyPresentDoesNothing() {
        BibEntry entry = new BibEntry();
        entry.setField(StandardField.YEAR, "2011");
        entry.setField(StandardField.MONTH, "#jan#");
        entry.setField(StandardField.DATE, "2012");

        worker.cleanup(entry);

        assertEquals(Optional.of("2011"), entry.getField(StandardField.YEAR));
        assertEquals(Optional.of("#jan#"), entry.getField(StandardField.MONTH));
        assertEquals(Optional.of("2012"), entry.getField(StandardField.DATE));
    }
Example 6
public void sameBooksWithMissingEditionAreDuplicates() {
        BibEntry editionOne = new BibEntry(StandardEntryType.Book);
        editionOne.setField(StandardField.TITLE, "Effective Java");
        editionOne.setField(StandardField.AUTHOR, "Bloch, Joshua");
        editionOne.setField(StandardField.PUBLISHER, "Prentice Hall");
        editionOne.setField(StandardField.DATE, "2001");

        BibEntry editionTwo = new BibEntry(StandardEntryType.Book);
        editionTwo.setField(StandardField.TITLE, "Effective Java");
        editionTwo.setField(StandardField.AUTHOR, "Bloch, Joshua");
        editionTwo.setField(StandardField.PUBLISHER, "Prentice Hall");
        editionTwo.setField(StandardField.DATE, "2008");

        assertTrue(duplicateChecker.isDuplicate(editionOne, editionTwo, BibDatabaseMode.BIBTEX));
    }