use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkThreeSaveActionsForOneField.
@Test
public void checkThreeSaveActionsForOneField() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[lower_case,identity,normalize_date]"));
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
FieldFormatterCleanup identityInTitle = new FieldFormatterCleanup("title", new IdentityFormatter());
FieldFormatterCleanup normalizeDatesInTitle = new FieldFormatterCleanup("title", new NormalizeDateFormatter());
assertEquals(Arrays.asList(lowerCaseTitle, identityInTitle, normalizeDatesInTitle), actions.getConfiguredActions());
actions.applySaveActions(entry);
assertEquals(Optional.of("educational session 1"), entry.getField("title"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkLowerCaseSaveAction.
@Test
public void checkLowerCaseSaveAction() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[lower_case]"));
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
assertEquals(Collections.singletonList(lowerCaseTitle), actions.getConfiguredActions());
actions.applySaveActions(entry);
assertEquals(Optional.of("educational session 1"), entry.getField("title"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanups 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.FieldFormatterCleanups 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.FieldFormatterCleanups in project jabref by JabRef.
the class FieldFormatterCleanupsTest method clearFormatterRemovesField.
@Test
public void clearFormatterRemovesField() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("mont[clear]"));
actions.applySaveActions(entry);
assertEquals(Optional.empty(), entry.getField("mont"));
}
Aggregations