Search in sources :

Example 26 with FieldFormatterCleanup

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"));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) HtmlToLatexFormatter(org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter) Test(org.junit.Test)

Example 27 with FieldFormatterCleanup

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"));
}
Also used : ProtectedTermsLoader(org.jabref.logic.protectedterms.ProtectedTermsLoader) BibEntry(org.jabref.model.entry.BibEntry) ProtectTermsFormatter(org.jabref.logic.formatter.casechanger.ProtectTermsFormatter) ProtectedTermsPreferences(org.jabref.logic.protectedterms.ProtectedTermsPreferences) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) Test(org.junit.Test)

Example 28 with FieldFormatterCleanup

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"));
}
Also used : NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 29 with FieldFormatterCleanup

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"));
}
Also used : IdentityFormatter(org.jabref.logic.formatter.IdentityFormatter) NormalizeDateFormatter(org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 30 with FieldFormatterCleanup

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"));
}
Also used : FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Aggregations

FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)33 Test (org.junit.Test)22 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)20 LowerCaseFormatter (org.jabref.logic.formatter.casechanger.LowerCaseFormatter)10 BibEntry (org.jabref.model.entry.BibEntry)9 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)7 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)5 MoveFieldCleanup (org.jabref.logic.cleanup.MoveFieldCleanup)3 IdentityFormatter (org.jabref.logic.formatter.IdentityFormatter)3 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)3 NormalizeMonthFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter)3 StringReader (java.io.StringReader)2 NormalizeNamesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter)2 RemoveBracesFormatter (org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter)2 UpperCaseFormatter (org.jabref.logic.formatter.casechanger.UpperCaseFormatter)2 ParserResult (org.jabref.logic.importer.ParserResult)2 FormBuilder (com.jgoodies.forms.builder.FormBuilder)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 Component (java.awt.Component)1 ArrayList (java.util.ArrayList)1