use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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"));
}
use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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));
}
use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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());
}
use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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());
}
use of org.jabref.logic.formatter.casechanger.LowerCaseFormatter 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());
}
Aggregations