use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class CleanupWorkerTest method cleanupWithDisabledFieldFormatterChangesNothing.
@Test
public void cleanupWithDisabledFieldFormatterChangesNothing() {
CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(false, Collections.singletonList(new FieldFormatterCleanup("month", new NormalizeMonthFormatter()))));
BibEntry entry = new BibEntry();
entry.setField("month", "01");
worker.cleanup(preset, entry);
Assert.assertEquals(Optional.of("01"), entry.getField("month"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup in project jabref by JabRef.
the class CleanupWorkerTest method cleanupUnitsConvertsOneAmpereToLatex.
@Test
public void cleanupUnitsConvertsOneAmpereToLatex() {
CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new UnitsToLatexFormatter()))));
BibEntry entry = new BibEntry();
entry.setField("title", "1 A");
worker.cleanup(preset, entry);
Assert.assertEquals(Optional.of("1~{A}"), entry.getField("title"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup 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"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup 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"));
}
use of org.jabref.model.cleanup.FieldFormatterCleanup 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"));
}
Aggregations