use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkMultipleSaveActions.
@Test
public void checkMultipleSaveActions() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("pages[normalize_page_numbers]title[lower_case]"));
List<FieldFormatterCleanup> formatterCleanups = actions.getConfiguredActions();
FieldFormatterCleanup normalizePages = new FieldFormatterCleanup("pages", new NormalizePagesFormatter());
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
assertEquals(Arrays.asList(normalizePages, lowerCaseTitle), formatterCleanups);
actions.applySaveActions(entry);
assertEquals(Optional.of("educational session 1"), entry.getField("title"));
assertEquals(Optional.of("1--7"), entry.getField("pages"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class BibtexDatabaseWriterTest method writeSaveActions.
@Test
public void writeSaveActions() throws Exception {
FieldFormatterCleanups saveActions = new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new LowerCaseFormatter())));
metaData.setSaveActions(saveActions);
StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
assertEquals(OS.NEWLINE + "@Comment{jabref-meta: saveActions:enabled;" + OS.NEWLINE + "title[lower_case]" + OS.NEWLINE + ";}" + OS.NEWLINE, session.getStringValue());
}
use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class FieldFormatterCleanupTest method testInternalAllTextFieldsField.
@Test
public void testInternalAllTextFieldsField() throws Exception {
FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UpperCaseFormatter());
cleanup.cleanup(entry);
Assert.assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get());
Assert.assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get());
Assert.assertEquals(fieldMap.get("year"), entry.getField("year").get());
Assert.assertEquals(fieldMap.get("month"), entry.getField("month").get());
Assert.assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get());
Assert.assertEquals(fieldMap.get("doi"), entry.getField("doi").get());
Assert.assertEquals(fieldMap.get("issn"), entry.getField("issn").get());
}
Aggregations