-
Notifications
You must be signed in to change notification settings - Fork 492
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
Correction of JsonPrinter output for metadatablock api calls #10764
base: develop
Are you sure you want to change the base?
Conversation
Merge v6.1 into master
Merge 6.2 into master
merge develop into master for 6.3
See also discussion at https://dataverse.zulipchat.com/#narrow/stream/378866-troubleshooting/topic/metadatablocks.20api/near/457293229 @GPortas I requested a review from you because you last worked on this code in PR #10642 to fix #10637. I have to admit I haven't looked deeply into this! |
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.
Some more feedback.
v6.4 | ||
---- | ||
|
||
- /api/metadatablocks is now returning no duplicated metadata properties and does not ommit metadata properties when called. The JsonPrinter class output is fixed. |
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.
- /api/metadatablocks is now returning no duplicated metadata properties and does not ommit metadata properties when called. The JsonPrinter class output is fixed. | |
- **/api/metadatablocks** is now returning no duplicated metadata properties and does not omit metadata properties when called. |
I'm suggesting that we remove the reference to JsonPrinter because API users don't need to worry about the underlying implementation.
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.
@ffritze
The requested change was not made. Also this now has to be added under V6.5 in the changeling.rst
@@ -658,7 +662,7 @@ public static JsonObjectBuilder json(MetadataBlock metadataBlock, boolean printO | |||
fieldsBuilder.add(datasetFieldType.getName(), json(datasetFieldType, ownerDataverse)); | |||
} | |||
} | |||
|
|||
jsonObjectBuilder.add("fields", fieldsBuilder); | |||
return jsonObjectBuilder; | |||
} |
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 just going to put this comment here at the bottom but @ffritze can you please get the following test passing?
edu.harvard.iq.dataverse.api.DataversesIT.testListMetadataBlocks is failing with this:
1 expectation failed.
JSON path data[1].fields.size() doesn't match.
Expected: <10>
Actual: <2>
I also mentioned this here: https://dataverse.zulipchat.com/#narrow/stream/378866-troubleshooting/topic/metadatablocks.20api/near/460096243
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.
When I start mvn clean package from my pull request branch which has dataverse 6.3 as basis there are no failing tests:
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.020 s -- in edu.harvard.iq.dataverse.feedback.FeedbackUtilTest
[INFO]
[INFO] Results:
[INFO]
[WARNING] Tests run: 1595, Failures: 0, Errors: 0, Skipped: 36
[INFO]
[INFO]
[INFO] --- jacoco:0.8.11:report (jacoco-after-unit) @ dataverse ---
[INFO] Loading execution data file /home/ff/github/dataverse/target/coverage-reports/jacoco-unit.exec
[INFO] Analyzed bundle 'dataverse' with 1044 classes
[INFO]
[INFO] --- war:3.3.2:war (default-war) @ dataverse ---
[INFO] Packaging webapp
[INFO] Assembling webapp [dataverse] in [/home/ff/github/dataverse/target/dataverse]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ff/github/dataverse/src/main/webapp]
[INFO] Building war: /home/ff/github/dataverse/target/dataverse-6.3.war
[INFO] Packaging classes
[INFO] Building jar: /home/ff/github/dataverse/target/dataverse-6.3-classes.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:02 min
[INFO] Finished at: 2024-08-26T08:06:19+02:00
[INFO] ------------------------------------------------------------------------
That's why I am not quite sure if the failing test has something to do with my pull request. Should I switch to develop and try to fix the test anyway?
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.
Those tests executed at build time are unit tests. @pdurbin is referring to the integration tests, and in particular the test testListMetadataBlocks
, present in: DataversesIT.java
.
To run integration tests, you need to have the environment running locally. You can do this by using the containerized dev environment.
Steps:
- Use
mvn -Pct package
to build the application image. - Use
docker-compose -f docker-compose-dev.yml up
to run the containerized environment - When all containers are up and running, execute:
mvn test -Dtest=DataversesIT
and all the IT tests from DataversesIT will be executed.
I recommend that you update this branch with develop, as the metadata blocks endpoint was recently modified, and I'm not sure if you have the latest changes.
The test may fail because of the changes you have made. There are assertions in the test that check the number of fields returned, and your changes likely reduced this number by removing duplicate child fields that were previously listed (repeated) as parents.
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.
Integration tests should be updated. Possibly new test cases should be added to verify that the child field exclusion logic works as expected.
Please read my comment above.
edf12ec
to
7884bdb
Compare
@stevenwinship I am not quite sure if there is an open task for me regarding this pull request. Is there still something to do from my side? |
@ffritze |
@ffritze I made a PR for you: Please take a look. |
10764 updates
@pdurbin Thanks for the pull request. I merged into my branch and now the "continuous integration" test is failing. Does that matter? |
@ffritze yes, it matters. 😄 Here are the latest test failures: https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-10764/5/testReport/edu.harvard.iq.dataverse.api/DataversesIT/testListMetadataBlocks/ is showing this:
@GPortas gave some advice on running DataversesIT here: #10764 (comment) . Can you please give that a try? And if it works, try running the MetadataBlocksIT tests. If you need help running these tests, please feel free to start a thread in #dev over at https://dataverse.zulipchat.com . Thanks! |
@pdurbin I have fixed both of the two tests. When I run it locally, all tests are passing. Could you please provide me with another error log regarding the jenkins fail. Thanks in advance. |
@ffritze thanks for adding those tests! https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-10764/8/consoleFull failed due to an unrelated S3 bucket error: I just kicked off another run: https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-10764/9/ |
What this PR does / why we need it:
This fixes the issue that some metadata properties are ommitted or duplicated in the JsonPrinter output if someone is calling the api/metadablock endpoint.
Which issue(s) this PR closes:
Closes #
Special notes for your reviewer:
Suggestions on how to test this:
All tests are passed.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No user interface changes it only affects the api json output.
Is there a release notes update needed for this change?:
Additional documentation:
The fix filters the metadata properties out of a list which are chield fields. Only parent properties are in the list which are then cast to an ordered set. The order logic is not changed. The addition of child properties is not changed because it is called correctly in another json() method in the JsonPrinter class.