-
-
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
Add simple Unit Tests for #6207 #6240
Merged
koppor
merged 20 commits into
JabRef:dimitra-karadima-fix-for-issue-6207
from
dimitra-karadima:fix-for-issue-6207
May 13, 2020
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b9c73fd
Unit tests improvement for #6207
dimitra-karadima b37a921
Fix some problems
dimitra-karadima fe9546d
Fix merge conflict
dimitra-karadima 02e8f67
Add more unit tests
dimitra-karadima b204b6b
Solve some issues
dimitra-karadima 0595351
Merge from upstream/master
dimitra-karadima 3a4f9d7
Rework the added tests
dimitra-karadima c9320d4
Merge branch 'master' into fix-for-issue-6207
dimitra-karadima ed2e7ea
Fix conflicts
dimitra-karadima dc72c05
Merge master to branch
dimitra-karadima 3933821
Merge branch 'master' into fix-for-issue-6207
koppor ca9f2f4
Rework IntegrityCheckTest and BibtexKeyCheckerTest
dimitra-karadima 207b28f
Change JournalInAbbreviationListCheckerTest
dimitra-karadima 1544c73
Remove @BeforeEach from test classes
dimitra-karadima 16129ca
Rework EditionCheckerTest
dimitra-karadima 870ce0d
Fix checkstyle
dimitra-karadima 8529050
Fix checkstyle again
dimitra-karadima 193d420
Rework PersonNamesCheckersTest
dimitra-karadima 08afd12
Update PersonNamesCheckerTest
dimitra-karadima 4eae95a
Update IntegrityCheckTest
dimitra-karadima 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
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,6 +7,7 @@ | |||||||||||
import java.util.List; | ||||||||||||
import java.util.Optional; | ||||||||||||
import java.util.UUID; | ||||||||||||
import java.util.stream.Stream; | ||||||||||||
|
||||||||||||
import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator; | ||||||||||||
import org.jabref.logic.bibtexkeypattern.BibtexKeyPatternPreferences; | ||||||||||||
|
@@ -27,13 +28,21 @@ | |||||||||||
|
||||||||||||
import org.junit.jupiter.api.Test; | ||||||||||||
import org.junit.jupiter.api.io.TempDir; | ||||||||||||
import org.junit.jupiter.params.ParameterizedTest; | ||||||||||||
import org.junit.jupiter.params.provider.MethodSource; | ||||||||||||
import org.mockito.Mockito; | ||||||||||||
|
||||||||||||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||||||||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||||||||||||
import static org.mockito.Matchers.any; | ||||||||||||
import static org.mockito.Mockito.mock; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* This class tests the Integrity Checker as a whole. | ||||||||||||
* Aspects are: selected fields, issues arising in a complete BibTeX entry, ... When testing a checker works with a certain input, | ||||||||||||
* this test has to go to a test belonging to the respective checker. See PersonNamesCheckerTest for an example test. | ||||||||||||
*/ | ||||||||||||
|
||||||||||||
class IntegrityCheckTest { | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, a JavaDoc should be added explaning the difference between this test and the CheckerTests. Here a proposal:
Suggested change
|
||||||||||||
|
||||||||||||
@Test | ||||||||||||
|
@@ -56,6 +65,33 @@ void bibLaTexAcceptsStandardEntryType() { | |||||||||||
assertCorrect(withMode(createContext(StandardField.TITLE, "sometitle", StandardEntryType.Article), BibDatabaseMode.BIBLATEX)); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@ParameterizedTest | ||||||||||||
@MethodSource("provideCorrectFormat") | ||||||||||||
void authorNameChecksCorrectFormat(String input) { | ||||||||||||
for (Field field : FieldFactory.getPersonNameFields()) { | ||||||||||||
assertCorrect(withMode(createContext(field, input), BibDatabaseMode.BIBLATEX)); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
@ParameterizedTest | ||||||||||||
@MethodSource("provideIncorrectFormat") | ||||||||||||
void authorNameChecksIncorrectFormat(String input) { | ||||||||||||
for (Field field : FieldFactory.getPersonNameFields()) { | ||||||||||||
assertWrong(withMode(createContext(field, input), BibDatabaseMode.BIBLATEX)); | ||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
private static Stream<String> provideCorrectFormat() { | ||||||||||||
return Stream.of("", "Knuth", "Donald E. Knuth and Kurt Cobain and A. Einstein"); | ||||||||||||
} | ||||||||||||
|
||||||||||||
private static Stream<String> provideIncorrectFormat() { | ||||||||||||
return Stream.of(" Knuth, Donald E. ", | ||||||||||||
"Knuth, Donald E. and Kurt Cobain and A. Einstein", | ||||||||||||
", and Kurt Cobain and A. Einstein", "Donald E. Knuth and Kurt Cobain and ,", | ||||||||||||
"and Kurt Cobain and A. Einstein", "Donald E. Knuth and Kurt Cobain and"); | ||||||||||||
} | ||||||||||||
|
||||||||||||
@Test | ||||||||||||
void testFileChecks() { | ||||||||||||
MetaData metaData = mock(MetaData.class); | ||||||||||||
|
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.
No empty line between JavaDoc and code.