Skip to content
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

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from

Conversation

ffritze
Copy link
Contributor

@ffritze ffritze commented Aug 9, 2024

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.

@pdurbin pdurbin requested a review from GPortas August 12, 2024 14:43
@pdurbin
Copy link
Member

pdurbin commented Aug 12, 2024

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!

Copy link
Member

@pdurbin pdurbin left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- /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.

Copy link
Contributor

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;
}
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ffritze

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:

  1. Use mvn -Pct package to build the application image.
  2. Use docker-compose -f docker-compose-dev.yml up to run the containerized environment
  3. 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.

Copy link
Contributor

@GPortas GPortas left a 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.

@ffritze
Copy link
Contributor Author

ffritze commented Aug 29, 2024

@pdurbin @GPortas The branch was updated. The integration test is now passing.

@pdurbin pdurbin added the Size: 3 A percentage of a sprint. 2.1 hours. label Sep 3, 2024
@pdurbin pdurbin added the Type: Bug a defect label Oct 9, 2024
@cmbz cmbz added FY25 Sprint 8 FY25 Sprint 8 (2024-10-09 - 2024-10-23) FY25 Sprint 9 FY25 Sprint 9 (2024-10-23 - 2024-11-06) labels Oct 23, 2024
@sekmiller sekmiller assigned sekmiller and unassigned sekmiller Nov 1, 2024
@cmbz cmbz added the FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) label Nov 7, 2024
@stevenwinship stevenwinship added the Status: Needs Input Applied to issues in need of input from someone currently unavailable label Nov 13, 2024
@ffritze
Copy link
Contributor Author

ffritze commented Nov 20, 2024

@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?

@stevenwinship
Copy link
Contributor

@ffritze
Please make the above change and get the tests to pass

@pdurbin
Copy link
Member

pdurbin commented Dec 16, 2024

@ffritze I made a PR for you:

Please take a look.

@coveralls
Copy link

coveralls commented Dec 17, 2024

Coverage Status

coverage: 22.571%. remained the same
when pulling 957adab on TIK-NFL:master_json_fix
into e3b5795 on IQSS:develop.

@ffritze
Copy link
Contributor Author

ffritze commented Dec 17, 2024

@pdurbin Thanks for the pull request. I merged into my branch and now the "continuous integration" test is failing. Does that matter?

@pdurbin
Copy link
Member

pdurbin commented Dec 17, 2024

@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:

1 expectation failed.
JSON path data[0].fields.size() doesn't match.
Expected: is <28>
  Actual: <10>

https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-10764/5/testReport/edu.harvard.iq.dataverse.api/MetadataBlocksIT/testListMetadataBlocks/ is showing this:

1 expectation failed.
JSON path data[0].fields.size() doesn't match.
Expected: <80>
  Actual: <35>

@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 pdurbin removed the Status: Needs Input Applied to issues in need of input from someone currently unavailable label Dec 17, 2024
@ffritze
Copy link
Contributor Author

ffritze commented Dec 18, 2024

@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.

@pdurbin
Copy link
Member

pdurbin commented Dec 18, 2024

@pdurbin pdurbin assigned pdurbin and unassigned stevenwinship Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FY25 Sprint 8 FY25 Sprint 8 (2024-10-09 - 2024-10-23) FY25 Sprint 9 FY25 Sprint 9 (2024-10-23 - 2024-11-06) FY25 Sprint 10 FY25 Sprint 10 (2024-11-06 - 2024-11-20) Size: 3 A percentage of a sprint. 2.1 hours. Type: Bug a defect
Projects
Status: In Review 🔎
Development

Successfully merging this pull request may close these issues.

8 participants