Search in sources :

Example 6 with FieldFormatterCleanups

use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.

the class CleanupWorkerTest method cleanupPageNumbersConvertsSingleDashToDouble.

@Test
public void cleanupPageNumbersConvertsSingleDashToDouble() {
    CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("pages", new NormalizePagesFormatter()))));
    BibEntry entry = new BibEntry();
    entry.setField("pages", "1-2");
    worker.cleanup(preset, entry);
    Assert.assertEquals(Optional.of("1--2"), entry.getField("pages"));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) NormalizePagesFormatter(org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter) Test(org.junit.Test)

Example 7 with FieldFormatterCleanups

use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.

the class CleanupWorkerTest method cleanupLatexMergesTwoLatexMathEnvironments.

@Test
public void cleanupLatexMergesTwoLatexMathEnvironments() {
    CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new LatexCleanupFormatter()))));
    BibEntry entry = new BibEntry();
    entry.setField("title", "$\\alpha$$\\beta$");
    worker.cleanup(preset, entry);
    Assert.assertEquals(Optional.of("$\\alpha\\beta$"), entry.getField("title"));
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) LatexCleanupFormatter(org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) Test(org.junit.Test)

Example 8 with FieldFormatterCleanups

use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.

the class FieldFormatterCleanupsTest method checkSimpleUseCase.

@Test
public void checkSimpleUseCase() {
    FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[identity]"));
    FieldFormatterCleanup identityInTitle = new FieldFormatterCleanup("title", new IdentityFormatter());
    assertEquals(Collections.singletonList(identityInTitle), actions.getConfiguredActions());
    actions.applySaveActions(entry);
    assertEquals(Optional.of("Educational session 1"), entry.getField("title"));
}
Also used : IdentityFormatter(org.jabref.logic.formatter.IdentityFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) Test(org.junit.Test)

Example 9 with FieldFormatterCleanups

use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.

the class FieldFormatterCleanupsTest method invalidSaveActionSting.

@Test
public void invalidSaveActionSting() {
    FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title"));
    assertEquals(Collections.emptyList(), actions.getConfiguredActions());
    actions.applySaveActions(entry);
    assertEquals(Optional.of("Educational session 1"), entry.getField("title"));
}
Also used : FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) Test(org.junit.Test)

Example 10 with FieldFormatterCleanups

use of org.jabref.model.cleanup.FieldFormatterCleanups in project jabref by JabRef.

the class FieldFormatterCleanupsTest method checkTwoSaveActionsForOneField.

@Test
public void checkTwoSaveActionsForOneField() {
    FieldFormatterCleanups actions = new FieldFormatterCleanups(true, Cleanups.parse("title[lower_case,identity]"));
    FieldFormatterCleanup lowerCaseTitle = new FieldFormatterCleanup("title", new LowerCaseFormatter());
    FieldFormatterCleanup identityInTitle = new FieldFormatterCleanup("title", new IdentityFormatter());
    assertEquals(Arrays.asList(lowerCaseTitle, identityInTitle), actions.getConfiguredActions());
    actions.applySaveActions(entry);
    assertEquals(Optional.of("educational session 1"), entry.getField("title"));
}
Also used : IdentityFormatter(org.jabref.logic.formatter.IdentityFormatter) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Aggregations

FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)26 Test (org.junit.Test)23 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)20 LowerCaseFormatter (org.jabref.logic.formatter.casechanger.LowerCaseFormatter)10 BibEntry (org.jabref.model.entry.BibEntry)10 IdentityFormatter (org.jabref.logic.formatter.IdentityFormatter)3 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)3 NormalizePagesFormatter (org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter)3 StringReader (java.io.StringReader)2 CleanupActionsListModel (org.jabref.gui.cleanup.CleanupActionsListModel)2 NormalizeMonthFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter)2 ParserResult (org.jabref.logic.importer.ParserResult)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 ListDataEvent (javax.swing.event.ListDataEvent)1 ListDataListener (javax.swing.event.ListDataListener)1 ClearFormatter (org.jabref.logic.formatter.bibtexfields.ClearFormatter)1 HtmlToLatexFormatter (org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter)1 LatexCleanupFormatter (org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter)1 UnitsToLatexFormatter (org.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter)1