-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Real test linking real other entry #3214
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
Real test linking real other entry #3214
Conversation
String expectedCrossrefValue = targetCiteKey.get(); | ||
crossrefs = actualcrossrefValue.contains(expectedCrossrefValue); | ||
} | ||
assertTrue(crossrefs); |
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.
Are you aware that you can directly call assertEquals on two optionals?
https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#equals-java.lang.Object-
|
||
@Test | ||
public void givenTargetAndSourceWhenSourceCrossrefTargetThenSourceCrossrefsTarget() { | ||
target = BibEntryBuild.ing().withId("target").withCiteKey("target").now(); |
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 don't see why it's necessary to have a BibEntry build class?
Why not just simply create two new BibEntrys? And you won't need the actual database file.
e.g.
database = new BibDatabase()
BibEntry source = new BibEntry()
source.setCiteKey("source")
source.setField(Crossref, "target")
database.insert(source)
BibEntry target = new BibEntry()
target.setCiteKey("target")
database.insert(target)
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.
Put that in the before method and it will be "freshly created" for every 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.
BibEntry
actually contains a withField
method if you want to use a more fluent api,
jabref/src/main/java/org/jabref/model/entry/BibEntry.java
Lines 734 to 737 in 23a0610
public BibEntry withField(String field, String value) { | |
setField(field, value); | |
return this; | |
} |
If you want, you can also add a new method
withCiteKey
along these lines.
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.
Your test code looks a bit more complicated than it could be.
You don't need to access a real bib file on the disk.
Thank you for your valuable feedback, I learned a lot and implemented all change requests |
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.
Now it looks good to me!
* upstream/master: Add tests for removal changes Improve telemetry (#3218) Real test linking real other entry (#3214) Check for explicit group at different location Update java-string-similarity from 0.24 -> 1.0.0 Only remove ExplicitGroups from entries, but not keyword-based groups Remove unused import in GroupTreeNode Move getEntriesInGroup to GroupTreeNode Inline Consumer updateViewModel Undo IntelliJ autoformat of FXML annotations Remove unused import Rewrite selection logic to avoid NPEs Clear group selection when a group is removed Also remove a group from entries when you remove it
* upstream/master: (188 commits) Show file description only if not empty Add file description to gui and fix sync bug (#3210) Don't highlight odd rows in file list editor (#3223) Fix assertion by removing typo (#3220) Update assertion to change of online reference (#3221) Put in null return Reformatted code, renamed method, added try/catch Add tests for removal changes Improve telemetry (#3218) Real test linking real other entry (#3214) Check for explicit group at different location Update java-string-similarity from 0.24 -> 1.0.0 Only remove ExplicitGroups from entries, but not keyword-based groups Localization: French: Translation of a new string (#3212) Fix null return Changed from Path to Optional<Path> Fix #2775: Hyphens in last names are properly parsed (#3209) Followup to Issue #3167 (#3202) Remove unused import in GroupTreeNode Move getEntriesInGroup to GroupTreeNode ...
gradle localizationUpdate
?Why
Based on #3191 (comment) I added two tests concerning cross referencing.
What
Watchout
assertSourceCrossrefsTarget
further due to theOptional<>
concept.BibEntryBuild.
It is an inner class, because I am uncertain where to put it.DatabaseFromFile
to keep test code readable. It is an inner class, because I did not find a similar wrapper nor did I know where to put it. Its construction uses a path to a file to be parsed to a database.