Search in sources :

Example 1 with IdentityFormatter

use of org.jabref.logic.formatter.IdentityFormatter 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 2 with IdentityFormatter

use of org.jabref.logic.formatter.IdentityFormatter 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)

Example 3 with IdentityFormatter

use of org.jabref.logic.formatter.IdentityFormatter 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)

Aggregations

IdentityFormatter (org.jabref.logic.formatter.IdentityFormatter)3 FieldFormatterCleanup (org.jabref.model.cleanup.FieldFormatterCleanup)3 FieldFormatterCleanups (org.jabref.model.cleanup.FieldFormatterCleanups)3 Test (org.junit.Test)3 LowerCaseFormatter (org.jabref.logic.formatter.casechanger.LowerCaseFormatter)2 NormalizeDateFormatter (org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter)1