-
Notifications
You must be signed in to change notification settings - Fork 37
Bootstrap test data from JSON fixtures instead of SQL migrations #802
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
Merged
dennisvang
merged 28 commits into
feature/634-boostrapping-fdp
from
proposal/634-remove-sql-test-data-migrations
Dec 16, 2025
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3d28644
remove data migrations from src/test/resources/test/db
dennisvang 6ab040d
remove reference to test data migrations from test config
dennisvang ac0e0ae
explicitly enable bootstrap in test config
dennisvang d5915b1
add test-fixtures location to bootstrap config
dennisvang a86092a
rename 'db-fixtures-dirs' property to 'locations'
dennisvang f5abb80
rename fixturesDir loop variable to location
dennisvang 4618d91
remove 'file:' prefix from fixture location pattern
dennisvang e647d94
clarify RepositoriesPopulatedEvent log message
dennisvang 049eeb2
Revert "remove data migrations from src/test/resources/test/db"
dennisvang f3e49cb
replace V0001.1__dev-data-users.sql test data migration by json fixtu…
dennisvang caddb3d
cherry-pick: Make test logging config easier to use (#806)
dennisvang d14ce0f
adapt bootstrap.locations for DatabaseBootstrapTests
dennisvang a1e6c8c
re-populate db from fixtures after flyway clean in WebIntegrationTest…
dennisvang 636c38c
delete V0001.2__dev-data-schemas.sql because it is covered by the def…
dennisvang 1aa0b16
delete V0001.3__dev-data-rds.sql because it is covered by the 03xx fi…
dennisvang 79ec86f
delete V0001.4__dev-data-membership.sql because it is covered by the …
dennisvang ec5711a
replace V0001.5__dev-settings.sql by 0500_test-settings.json
dennisvang 883e341
replace V0001.6__test-schemas.sql by 0600_test-schemas.json
dennisvang e067b09
allow full ant-style location patterns for populator resources
dennisvang 10e7a18
adapt DatabaseBootstrapTests to use the default fixtures
dennisvang 86225f2
simplify resource location pattern for Windows compatibility
dennisvang 0dd2776
catch all exceptions in RdfMetadataMigration.runMigration (dev only)
dennisvang a531516
fix test data description to match user account uuid
dennisvang 2493791
modify testDuplicateIdEntityOverwriteBootstrap and corresponding fixt…
dennisvang ce810ea
adapt search/query/saved test expectations to updated test data
dennisvang 79cde97
revert default user emails from example.org to example.com
dennisvang 65f641f
adapt order of test users to match the original expectation
dennisvang 2341d09
repopulate test database after flyway.clean in ResourceDefinitionCach…
dennisvang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,5 +114,5 @@ server: | |
|
|
||
| bootstrap: | ||
| enabled: true | ||
| db-fixtures-dirs: | ||
| - "fixtures" | ||
| locations: | ||
| - file:fixtures | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,24 +31,19 @@ | |
| import org.fairdatapoint.entity.apikey.ApiKey; | ||
| import org.fairdatapoint.entity.search.SearchSavedQuery; | ||
| import org.fairdatapoint.entity.user.UserAccount; | ||
| import org.fairdatapoint.util.KnownUUIDs; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager; | ||
| import org.springframework.test.context.TestPropertySource; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| @AutoConfigureTestEntityManager | ||
| @Transactional | ||
| @TestPropertySource( | ||
| properties = """ | ||
| bootstrap.enabled=true | ||
| bootstrap.db-fixtures-dirs=src/test/resources/fixtures | ||
| """ | ||
| ) | ||
| public class DatabaseBootstrapTests extends BaseIntegrationTest { | ||
| @Autowired | ||
| private UserAccountRepository userAccountRepository; | ||
|
|
@@ -59,28 +54,33 @@ public class DatabaseBootstrapTests extends BaseIntegrationTest { | |
| @Autowired | ||
| private SearchSavedQueryRepository searchSavedQueryRepository; | ||
|
|
||
| private final String einsteinEmail = "[email protected]"; | ||
|
|
||
| @Test | ||
| public void testSingleEntityBootstrap() { | ||
| final Optional<UserAccount> userAccount = userAccountRepository.findByEmail("[email protected]"); | ||
| assertEquals(true, userAccount.isPresent()); | ||
| assertEquals("John", userAccount.get().getFirstName()); | ||
| assertEquals("Doe", userAccount.get().getLastName()); | ||
| assertEquals(UUID.fromString("e8f98d8e-0c4f-4a4b-9cc7-dd884f0c75ee"), userAccount.get().getUuid()); | ||
| final Optional<UserAccount> userAccount = userAccountRepository.findByEmail(einsteinEmail); | ||
| assertTrue(userAccount.isPresent()); | ||
| assertEquals("Albert", userAccount.get().getFirstName()); | ||
| assertEquals("Einstein", userAccount.get().getLastName()); | ||
| assertEquals(KnownUUIDs.USER_ALBERT_UUID, userAccount.get().getUuid()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRelatedEntityBootstrap() { | ||
| final Optional<ApiKey> apiKey = apiKeyRepository.findByToken("testing-token"); | ||
| assertEquals(true, apiKey.isPresent()); | ||
| assertEquals("[email protected]", apiKey.get().getUserAccount().getEmail()); | ||
| assertEquals(UUID.fromString("9d734008-91bb-47e3-97aa-2f537e67d9e6"), apiKey.get().getUuid()); | ||
| final UUID einsteinApiKeyUuid = UUID.fromString("a1c00673-24c5-4e0a-bdbe-22e961ee7548"); | ||
| final String einsteinApiKeyToken = "a274793046e34a219fd0ea6362fcca61a001500b71724f4c973a017031653c20"; | ||
| final Optional<ApiKey> apiKey = apiKeyRepository.findByToken(einsteinApiKeyToken); | ||
| assertTrue(apiKey.isPresent()); | ||
| assertEquals(einsteinEmail, apiKey.get().getUserAccount().getEmail()); | ||
| assertEquals(einsteinApiKeyUuid, apiKey.get().getUuid()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDuplicateIdEntityOverwriteBootstrap() { | ||
| final Optional<SearchSavedQuery> savedQuery = searchSavedQueryRepository.findByUuid(UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); | ||
| assertEquals(true, savedQuery.isPresent()); | ||
| assertEquals("[email protected]", savedQuery.get().getUserAccount().getEmail()); | ||
| final Optional<SearchSavedQuery> savedQuery = searchSavedQueryRepository.findByUuid( | ||
| UUID.fromString("4c57eff3-4608-40ae-85af-b442cfea0746")); | ||
| assertTrue(savedQuery.isPresent()); | ||
| assertEquals("[email protected]", savedQuery.get().getUserAccount().getEmail()); | ||
| assertEquals("Some query 2", savedQuery.get().getName()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
That is indeed strange... it was probably there due to close relation to RDF records (it specifies access to an RDF records, but the ACL itself is relational - used to be in Mongo previously).