-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix DBLPFetcherTest -- dblp changed the format #5582
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5f7fe7e
Clean URLs in DBLPFetcher
koppor cbb3836
Use RemoveLatexCommandsFormatter directly
koppor 6070126
Improve code of ShortenDoiFormatter
koppor e3e22e3
Reformat code and more speaking variable name
koppor 7261699
Introduce LayoutFormatterBasedFormatter
koppor 569667f
Fix checkstyle
koppor 83cbb3d
Do not apply RemoveLatexCommandsFormatter in CleanupUrlFormatter
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/java/org/jabref/logic/layout/format/RemoveLatexCommandsFormatterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.jabref.logic.layout.format; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class RemoveLatexCommandsFormatterTest { | ||
|
||
private RemoveLatexCommandsFormatter formatter; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
formatter = new RemoveLatexCommandsFormatter(); | ||
} | ||
|
||
@Test | ||
public void withoutLatexCommandsUnmodified() { | ||
assertEquals("some text", formatter.format("some text")); | ||
} | ||
|
||
@Test | ||
public void singleCommandWiped() { | ||
assertEquals("", formatter.format("\\sometext")); | ||
} | ||
|
||
@Test | ||
public void singleSpaceAfterCommandRemoved() { | ||
assertEquals("text", formatter.format("\\some text")); | ||
} | ||
|
||
@Test | ||
public void multipleSpacesAfterCommandRemoved() { | ||
assertEquals("text", formatter.format("\\some text")); | ||
} | ||
|
||
@Test | ||
public void escapedBackslashBecomesBackslash() { | ||
assertEquals("\\", formatter.format("\\\\")); | ||
} | ||
|
||
@Test | ||
public void escapedBackslashFollowedByTextBecomesBackslashFollowedByText() { | ||
assertEquals("\\some text", formatter.format("\\\\some text")); | ||
} | ||
|
||
@Test | ||
public void escapedBackslashKept() { | ||
assertEquals("\\some text\\", formatter.format("\\\\some text\\\\")); | ||
} | ||
|
||
@Test | ||
public void escapedUnderscoreReplaces() { | ||
assertEquals("some_text", formatter.format("some\\_text")); | ||
} | ||
|
||
@Test | ||
public void exampleUrlCorrectlyCleaned() { | ||
assertEquals("http://pi.informatik.uni-siegen.de/stt/36_2/./03_Technische_Beitraege/ZEUS2016/beitrag_2.pdf", formatter.format("http://pi.informatik.uni-siegen.de/stt/36\\_2/./03\\_Technische\\_Beitraege/ZEUS2016/beitrag\\_2.pdf")); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although somewhat of an edge case, but doesn't this lead to problems with the valid url
jabref.org/test%5Ctest
(which I guess would be reduced tojabref.org/test
instead of the expectedjabref.org/test\test
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not this LOC in particularly, but in general: Yes. I added a test case for that.
In the fetcher itself, I use the RemoveLatexCommandsFormatter directly. I did not know how to convert a LayoutFormatter to a Formatter. Thus, I "manually" updated the field in cbb3836. Moments later, I worked on
LayoutFormatterBasedFormatter
which wraps aLayoutFormatter
in aFormatter
and IMHO made the code more nice.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unsure if we should really remove latex commands from the URL. I guess this is only an issue for the DBLP fetcher and nowhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, now I got it. Reverted that in 83cbb3d