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

8251 refactor api tests #8254

Closed
wants to merge 39 commits into from

Conversation

poikilotherm
Copy link
Contributor

What this PR does / why we need it:

This pull request is adding a few example refactorings for API tests (and might be extended to do this for more).

It also add the JUnit 5 extensions described in #8251

Which issue(s) this PR closes:

Closes #8251

Special notes for your reviewer:
This is a showcase for now. Enjoy.

Suggestions on how to test this:
"Simply" use the usual integration testing routines. Will be included in CI based API test.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Nope.

Is there a release notes update needed for this change?:
It might be good to write one once this matures.

Additional documentation:
None yet.

This will allow for a standardized collection of Strings
thus avoid typos
This extension allows to set and reset database settings within
a target Dataverse instance. It will make sure to reset to
old setting or remove the setting if not set before the test.

This was introduced for three reasons:
1. Don't execute a test if the setting did not go through
2. Don't forget to reset or remove to keep a consistent state after a
   test execution
3. Make the code more readable, as setting the setting has been part of
   the test before (which is bad design and might go booboo, see 2)
…IQSS#8251

When no stored procedure has been set up in the instance under test,
test running after
DatasetsIT.testStoredProcGeneratedAsIdentifierGenerationStyle() failed,
as the database setting was never reverted.

Making use of the new @DBSetting extension helps with that.
@coveralls
Copy link

coveralls commented Nov 22, 2021

Coverage Status

Coverage increased (+0.01%) to 18.924% when pulling 75aa5b9 on poikilotherm:8251-refactor-api-tests into 2495690 on IQSS:develop.

@poikilotherm
Copy link
Contributor Author

poikilotherm commented Nov 22, 2021

I started some implementation work last week, backporting from my container branch. See #8253

This is a showcase for now.

poikilotherm and others added 16 commits November 30, 2021 23:53
Many API tests require the use of a random user, which is no SuT
(subject under test). To gather such a user and ensure its deletion
from a target Dataverse instance after a test, this extension
provides a convenient way. Simple use ExtendWith and provide a
RandomUser parameter, you're done.
This helper class tries to abstract the store retrieval and handles all
the tiny details on retrieving in-depth context for a store.
With this commit, the RandomUserExtension may be used on
a test class, @BeforeEach/All, @AfterEach/All methods and
test methods.

It will take care of deletion in the appropriate ways to ensure a
healthy target environment.

Using it on @AfterEach/All will return the formerly created user via
@BeforeEach/All and enabled aftermath reuse of the user.
…o that only the terms of use and access are considered (and not the guestbook which should only be considered at file download in isDownloadPopupRequired).
"application/octet-stream" is the default when the user doesn't supply a
content type. So if it's this, send it through Tika. Yes, a user
can supply "application/octet-stream" and this will also be sent through
Tika.
This avoids an NPE when the empty embargo (from the dialog that isn't
shown) is found to be invalid and then getMaxDate() returns null and the
code tries to format it for display in the error message (which also
wouldn't show).
verified that the names withheld bundle entry already exists.
@mreekie mreekie added the bk2211 label Nov 1, 2022
@mreekie mreekie removed the bk2211 label Jan 11, 2023
@poikilotherm
Copy link
Contributor Author

Duplicate of #9796, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor API tests to using JUnit5 + custom extensions
9 participants