use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class CleanupWorkerTest method cleanupHtmlToLatexConvertsEpsilonToLatex.
@Test
public void cleanupHtmlToLatexConvertsEpsilonToLatex() {
CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new HtmlToLatexFormatter()))));
BibEntry entry = new BibEntry();
entry.setField("title", "Ε");
worker.cleanup(preset, entry);
Assert.assertEquals(Optional.of("{{$\\Epsilon$}}"), entry.getField("title"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class CleanupWorkerTest method cleanupCasesAddsBracketAroundAluminiumGalliumArsenid.
@Test
public void cleanupCasesAddsBracketAroundAluminiumGalliumArsenid() {
ProtectedTermsLoader protectedTermsLoader = new ProtectedTermsLoader(new ProtectedTermsPreferences(ProtectedTermsLoader.getInternalLists(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
Assert.assertNotEquals(Collections.emptyList(), protectedTermsLoader.getProtectedTerms());
CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new ProtectTermsFormatter(protectedTermsLoader)))));
BibEntry entry = new BibEntry();
entry.setField("title", "AlGaAs");
worker.cleanup(preset, entry);
Assert.assertEquals(Optional.of("{AlGaAs}"), entry.getField("title"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class FieldFormatterCleanupsTest method checkMultipleSaveActionsWithMultipleFormatters.
@Test
public void checkMultipleSaveActionsWithMultipleFormatters() {
FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("pages[normalize_page_numbers,normalize_date]title[lower_case]"));
List<FieldFormatterCleanup> formatterCleanups = actions.getConfiguredActions();
FieldFormatterCleanup normalizePages = new FieldFormatterCleanup("pages", new NormalizePagesFormatter());
FieldFormatterCleanup normalizeDatesInPages = new FieldFormatterCleanup("pages", new NormalizeDateFormatter());
FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
assertEquals(Arrays.asList(normalizePages, normalizeDatesInPages, 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 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.FieldFormatterCleanup 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"));
}
Aggregations