Search in sources :

Example 11 with FieldFormatterCleanups

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

the class MetaDataSerializerTest method serializeSingleSaveAction.

@Test
public void serializeSingleSaveAction() {
    FieldFormatterCleanups saveActions = new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("title", new LowerCaseFormatter())));
    metaData.setSaveActions(saveActions);
    Map<String, String> expectedSerialization = new TreeMap<>();
    expectedSerialization.put("saveActions", "enabled;" + OS.NEWLINE + "title[lower_case]" + OS.NEWLINE + ";");
    assertEquals(expectedSerialization, MetaDataSerializer.getSerializedStringMap(metaData, pattern));
}
Also used : FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) TreeMap(java.util.TreeMap) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 12 with FieldFormatterCleanups

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

the class BibtexParserTest method parseRecognizesSaveActionsAfterEntry.

@Test
public void parseRecognizesSaveActionsAfterEntry() throws IOException {
    BibtexParser parser = this.parser;
    ParserResult parserResult = parser.parse(new StringReader("@InProceedings{6055279,\n" + "  Title                    = {Educational session 1},\n" + "  Booktitle                = {Custom Integrated Circuits Conference (CICC), 2011 IEEE},\n" + "  Year                     = {2011},\n" + "  Month                    = {Sept},\n" + "  Pages                    = {1-7},\n" + "  Abstract                 = {Start of the above-titled section of the conference proceedings record.},\n" + "  DOI                      = {10.1109/CICC.2011.6055279},\n" + "  ISSN                     = {0886-5930}\n" + "}\n" + "\n" + "@comment{jabref-meta: saveActions:enabled;title[lower_case]}"));
    FieldFormatterCleanups saveActions = parserResult.getMetaData().getSaveActions().get();
    assertTrue(saveActions.isEnabled());
    assertEquals(Collections.singletonList(new FieldFormatterCleanup("title", new LowerCaseFormatter())), saveActions.getConfiguredActions());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 13 with FieldFormatterCleanups

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

the class BibtexParserTest method integrationTestSaveActions.

@Test
public void integrationTestSaveActions() throws IOException {
    BibtexParser parser = this.parser;
    ParserResult parserResult = parser.parse(new StringReader("@comment{jabref-meta: saveActions:enabled;title[lower_case]}"));
    FieldFormatterCleanups saveActions = parserResult.getMetaData().getSaveActions().get();
    assertTrue(saveActions.isEnabled());
    assertEquals(Collections.singletonList(new FieldFormatterCleanup("title", new LowerCaseFormatter())), saveActions.getConfiguredActions());
}
Also used : ParserResult(org.jabref.logic.importer.ParserResult) StringReader(java.io.StringReader) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 14 with FieldFormatterCleanups

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

the class DBMSSynchronizerTest method testApplyMetaData.

@Test
public void testApplyMetaData() {
    BibEntry bibEntry = getBibEntryExample(1);
    bibDatabase.insertEntry(bibEntry);
    MetaData testMetaData = new MetaData();
    testMetaData.setSaveActions(new FieldFormatterCleanups(true, Collections.singletonList(new FieldFormatterCleanup("author", new LowerCaseFormatter()))));
    dbmsSynchronizer.setMetaData(testMetaData);
    dbmsSynchronizer.applyMetaData();
    Assert.assertEquals("wirthlin, michael j1", bibEntry.getField("author").get());
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) MetaData(org.jabref.model.metadata.MetaData) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) LowerCaseFormatter(org.jabref.logic.formatter.casechanger.LowerCaseFormatter) Test(org.junit.Test)

Example 15 with FieldFormatterCleanups

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

the class CleanupActionsListModelTest method resetSetsFormattersToPassedList.

@Test
public void resetSetsFormattersToPassedList() throws Exception {
    CleanupActionsListModel model = new CleanupActionsListModel(Collections.emptyList());
    FieldFormatterCleanups defaultFormatters = mock(FieldFormatterCleanups.class);
    List<FieldFormatterCleanup> formatters = Arrays.asList(new FieldFormatterCleanup("test", new ClearFormatter()));
    when(defaultFormatters.getConfiguredActions()).thenReturn(formatters);
    model.reset(defaultFormatters);
    assertEquals(formatters, model.getAllActions());
}
Also used : CleanupActionsListModel(org.jabref.gui.cleanup.CleanupActionsListModel) FieldFormatterCleanups(org.jabref.model.cleanup.FieldFormatterCleanups) FieldFormatterCleanup(org.jabref.model.cleanup.FieldFormatterCleanup) ClearFormatter(org.jabref.logic.formatter.bibtexfields.ClearFormatter) 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