Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't trim when migrating review field #3761

Merged
merged 5 commits into from
Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public FieldContentParser(FieldContentParserPreferences prefs) {
multiLineFields = new HashSet<>();
// the following two are also coded in org.jabref.logic.bibtex.LatexFieldFormatter.format(String, String)
multiLineFields.add(FieldName.ABSTRACT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract these fields that should be treated as multilines to InternalBibtexFields (or a better location). Moreover, a few places still work with

public static final String REVIEW = "review";
instead of comments. This should be changed too.

multiLineFields.add(FieldName.COMMENT);
multiLineFields.add(FieldName.REVIEW);
// the file field should not be formatted, therefore we treat it as a multi line field
multiLineFields.addAll(prefs.getNonWrappableFields());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ public void commentField() {
assertEquals(entry, actualParserResult.getDatabase().getEntryByKey("Entry1").get());
}

@Test
public void multiLineReviewField() {
String commentString = "My Review\n\nSecond Paragraph\n\nThird Paragraph";

BibEntry actualEntry = createMinimalBibEntry();
actualEntry.setField(FieldName.REVIEW, commentString);
ParserResult actualParserResult = new ParserResult(Collections.singletonList(actualEntry));

BibEntry expectedEntry = createMinimalBibEntry();
expectedEntry.setField(FieldName.COMMENT, commentString);

action.performMigration(actualParserResult);

assertEquals(expectedEntry, actualParserResult.getDatabase().getEntryByKey("Entry1").get());
}

@Test
@Disabled("Re-enable if the MergeReviewIntoCommentMigration.mergeCommentFieldIfPresent() does not block and wait for user input.")
Expand Down
8 changes: 1 addition & 7 deletions src/test/java/org/jabref/testutils/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
import org.jabref.JabRefGUI;
import org.jabref.JabRefMain;

/**
* UtilsClass for UnitTests.
*
* @author kahlert, cordes
*/
public class TestUtils {

public static final String PATH_TO_TEST_BIBTEX = "src/test/resources/org/jabref/bibtexFiles/test.bib";

private static final String PATH_TO_TEST_BIBTEX = "src/test/resources/org/jabref/bibtexFiles/test.bib";

/**
* Initialize JabRef. Can be cleaned up with
Expand Down