Add new unit tests for JsonParser; implement getContactEmails in Dataverse #2795
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.
Rebased on the 4.3 branch, thinking that you should enough time to review the PR :)
Although I promised to not spend more free time on coding for Dataverse, I couldn't
help myself after interacting with the "native API" and talking about code coverage
with @pdurbin some more.
The new tests parse JSON test files from the test resources - rather than test that
JsonPrinter output can be parsed. Only date and date-time tests test a round-trip.
I added comments to explain what the test tries to accomplish.
Although line coverage of JsonParser with these tests is > 56%, not all branches are
covered even though NetBeans may show green: inline if/else statements 'hide' some
branches in the green lines.
To make the tests pass, I added
dv.setAffiliation
inJsonParser.parseDataverse
with a default value of
null
if the JSON doesn't include affiliation andimplemented
Dataverse.getContactEmails
to produce a comma-separated string ofemail addresses. I hope these have been good assumptions for how the API behaves.
Note that because the JsonParser works on a different level than the API, the default
values that the parser uses may be different than the business logic prescribes
(see
dv.setPermissionRoot
inparseDataverse
). The tests expect the parser'sdefaults.