Skip to content
Merged
Changes from 2 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 @@ -3,7 +3,7 @@
import java.util.List;
import java.util.Optional;

import org.jabref.logic.os.OS;
import org.jabref.logic.util.strings.StringUtil;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.UserSpecificCommentField;
import org.jabref.model.entry.types.StandardEntryType;
Expand Down Expand Up @@ -58,7 +58,7 @@ void insertMatchedRelatedWorkAppendsToExistingUserSpecificCommentField() {
List<RelatedWorkInsertionResult> insertionResults = inserter.insertMatchedRelatedWork(sourceEntry, List.of(matchResult), "koppor");

assertInstanceOf(RelatedWorkInsertionResult.Inserted.class, insertionResults.getFirst());
assertEquals("[test]: blahblah" + OS.NEWLINE + OS.NEWLINE + "[LunaOstos_2024]: Colombia is a middle-income country with a population of approximately 50 million.",
assertEquals(StringUtil.unifyLineBreaks("[test]: blahblah".stripTrailing(), "\n") + "\n\n" + "[LunaOstos_2024]: Colombia is a middle-income country with a population of approximately 50 million.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure why double (!) changes

  • Use \n instead of OS.NEWLINE
  • Unify linebreaks at tests

I think, the first one is enough to do.

If BOTH is needed, there should be a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the confusion arises from a prior discussion #15316 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. In #15316 (comment), my thought is that we should first normalize the linebreak at the end of the sentence, before adding new linebreaks, so I use unifyLineBreaks.

In this test, I think we don't need unifyLineBreaks because the sentences contain no linebreaks. But I am not sure if we should also remove unifyLineBreaks in RelatedWorkInserter.

matchedLibraryEntry.getField(userSpecificCommentField).orElseThrow());
}
}
Loading