-
Notifications
You must be signed in to change notification settings - Fork 2
feat(persistence): set up JPA,Flyway and integration test with Testcontainers #21
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
Open
Arzu-N
wants to merge
42
commits into
main
Choose a base branch
from
feature/persistence-foundation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
755ea05
feat(persistence): set up JPA,Flayway and integration test with TestC…
Arzu-N 06b601f
style(persistence): fix code formatting and violations detected by sp…
Arzu-N 7524ceb
fix(persistence): remove star imports and order them alphabetically i…
Arzu-N 35f04ea
fix(test): fix checkstyle method name and resolve pipeline test failu…
Arzu-N 18196e1
fix(test): exclude db autoconfig in api test and pass dynamic flyway …
Arzu-N 98f29aa
fix(persistence): import FlywayAutoConfiguration explicitly in reposi…
Arzu-N 361a2c8
fix(persistence): add flyway-database-postgresql driver dependency fo…
Arzu-N 338329d
refactor: revert api configuration and cleanup project structure
Arzu-N 697704b
fix: ensure gradlew is executable
Arzu-N 4327ad5
test: fix persistence test context and remove redundant bean configur…
Arzu-N a416124
style: apply spotless code formatting
Arzu-N a2c0c0c
fix(ci): fix gradle execution permission
Arzu-N 435658e
fix: fix initialization error using ContextConfiguration
Arzu-N 6bf74a0
style: apply spotless code formatting
Arzu-N 52a7fc0
refactor: revert unnecessary scanBasePackages from application class
Arzu-N c5544e6
style: fix spotless violations in AccountRepositoryTest
Arzu-N f23748c
style: fix code formatting with spotless
Arzu-N 1f34b90
refactor: remove autoconfigure excludes to enable database support
Arzu-N 013edad
test: link persistence tests to application context
Arzu-N 5b9fbbd
test: refactor persistence test to use testconainers with local test …
Arzu-N 2260925
fix(persistence): resolve context loading issues in AccountRepository…
Arzu-N 2bf9b32
refactor(persistence): remove circular dependency in persistence modu…
Arzu-N 5547012
fix(build): remove circular project dependency in apps:api
Arzu-N 3a50cdf
refactor(persistence): cllean up dependencies
Arzu-N 0e35402
refactor(persistence): remove Lombok in favor of standard Java boiler…
Arzu-N 4e17e12
feat(persistence): add account and repo schema and entities
Arzu-N ab8e69a
refactor(persistence): fix checkstyle violations and optimize imports
Arzu-N cc796aa
fix(persistence): import missing JPA annotations for AccountEntity
Arzu-N 54fd1f2
fix(persistence): resolve IdentifierGenerationException by adding @Ge…
Arzu-N 0b49008
chore(persistence): fix import ordering violations via spotless
Arzu-N 205bd20
chore(persistence): add index to repo account_id for performance
Arzu-N c301b0f
test(persistence): improve AccountRepositoryTest with flush and clear…
Arzu-N 7711596
test(persistence): implement robust test for Account-Repo persistence
Arzu-N 8595d5b
fix(persistence): align RepoEntity column names with schema
Arzu-N 452fd66
fix(persistence): resolve column name typo in RepoEntity to match schema
Arzu-N 72212a8
refactor(persistence): revert hardcoded spring boot version to use BO…
Arzu-N 3bfc522
chore(persistence): update entity types and database schemas
Arzu-N 3b08016
feat(persistence): implement Enums with @JsonValue for correct JSON s…
Arzu-N c9b9732
chore(persistence): fix enum mapping,restore ddl-validate,and cleanup…
Arzu-N 76dc461
refactor(persistence): update data types for account and repo entities
Arzu-N c868457
refactor(flyway): update data types in migration scripts for consist…
Arzu-N 1e76248
fix(flyway): resolve SQL syntax error in migration
Arzu-N 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
Empty file.
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| org.gradle.caching=true | ||
| org.gradle.parallel=true | ||
| org.gradle.configuration-cache=true | ||
|
|
Empty file.
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 |
|---|---|---|
| @@ -1,13 +1,17 @@ | ||
| plugins { | ||
| `java-library` | ||
| } | ||
|
|
||
| dependencies { | ||
| api(project(":libs:domain")) | ||
| implementation(project(":libs:common")) | ||
| api("org.springframework.boot:spring-boot-starter-data-jpa") | ||
| implementation("org.flywaydb:flyway-core") | ||
| implementation("org.flywaydb:flyway-database-postgresql") | ||
| runtimeOnly("org.flywaydb:flyway-database-postgresql") | ||
|
Arzu-N marked this conversation as resolved.
|
||
| runtimeOnly("org.postgresql:postgresql") | ||
| testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
| testImplementation("org.testcontainers:junit-jupiter") | ||
| testImplementation("org.testcontainers:postgresql") | ||
| testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
| } | ||
|
|
||
|
|
||
200 changes: 200 additions & 0 deletions
200
backend/libs/persistence/src/main/java/dev/cleat/persistence/AccountEntity.java
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 |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| import jakarta.persistence.CascadeType; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.OneToMany; | ||
| import jakarta.persistence.Table; | ||
| import java.math.BigDecimal; | ||
| import java.time.OffsetDateTime; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import org.hibernate.annotations.CreationTimestamp; | ||
|
|
||
| @Entity | ||
| @Table(name = "account") | ||
| public class AccountEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| private UUID id; | ||
|
|
||
| @Column(name = "login", nullable = false) | ||
| private String login; | ||
|
|
||
| @Column(name = "name", nullable = false) | ||
| private String name; | ||
|
|
||
| @Column(name = "type", nullable = false) | ||
| @Enumerated(EnumType.STRING) | ||
| private AccountType type; | ||
|
|
||
| @Column(name = "plan") | ||
| @Enumerated(EnumType.STRING) | ||
| private Plan plan; | ||
|
|
||
| @Column(name = "repo_count") | ||
| private Integer repoCount; | ||
|
|
||
| @Column(name = "member_count") | ||
| private Integer memberCount; | ||
|
|
||
| @Column(name = "posture_score") | ||
| private Integer postureScore; | ||
|
|
||
| @Column(name = "monthly_spend") | ||
| private BigDecimal monthlySpend; | ||
|
|
||
| @Column(name = "reclaimable") | ||
| private BigDecimal reclaimable; | ||
|
|
||
| @CreationTimestamp | ||
| @Column(name = "created_at", nullable = false, updatable = false) | ||
| private OffsetDateTime createdAt; | ||
|
|
||
| @OneToMany(mappedBy = "account", cascade = CascadeType.ALL, orphanRemoval = true) | ||
| private List<RepoEntity> repos = new ArrayList<>(); | ||
|
|
||
| public AccountEntity( | ||
| UUID id, | ||
| String login, | ||
| String name, | ||
| AccountType type, | ||
| Plan plan, | ||
| Integer repoCount, | ||
| Integer memberCount, | ||
| Integer postureScore, | ||
| BigDecimal monthlySpend, | ||
| BigDecimal reclaimable, | ||
| OffsetDateTime createdAt, | ||
| List<RepoEntity> repos) { | ||
| this.id = id; | ||
| this.login = login; | ||
| this.name = name; | ||
| this.type = type; | ||
| this.plan = plan; | ||
| this.repoCount = repoCount; | ||
| this.memberCount = memberCount; | ||
| this.postureScore = postureScore; | ||
| this.monthlySpend = monthlySpend; | ||
| this.reclaimable = reclaimable; | ||
| this.createdAt = createdAt; | ||
| this.repos = repos; | ||
| } | ||
|
|
||
| public AccountEntity() {} | ||
|
|
||
| public UUID getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public AccountEntity setId(UUID id) { | ||
| this.id = id; | ||
| return this; | ||
| } | ||
|
|
||
| public String getLogin() { | ||
| return login; | ||
| } | ||
|
|
||
| public AccountEntity setLogin(String login) { | ||
| this.login = login; | ||
| return this; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public AccountEntity setName(String name) { | ||
| this.name = name; | ||
| return this; | ||
| } | ||
|
|
||
| public AccountType getType() { | ||
| return type; | ||
| } | ||
|
|
||
| public AccountEntity setType(AccountType type) { | ||
| this.type = type; | ||
| return this; | ||
| } | ||
|
|
||
| public Plan getPlan() { | ||
| return plan; | ||
| } | ||
|
|
||
| public AccountEntity setPlan(Plan plan) { | ||
| this.plan = plan; | ||
| return this; | ||
| } | ||
|
|
||
| public Integer getRepoCount() { | ||
| return repoCount; | ||
| } | ||
|
|
||
| public AccountEntity setRepoCount(Integer repoCount) { | ||
| this.repoCount = repoCount; | ||
| return this; | ||
| } | ||
|
|
||
| public Integer getMemberCount() { | ||
| return memberCount; | ||
| } | ||
|
|
||
| public AccountEntity setMemberCount(Integer memberCount) { | ||
| this.memberCount = memberCount; | ||
| return this; | ||
| } | ||
|
|
||
| public Integer getPostureScore() { | ||
| return postureScore; | ||
| } | ||
|
|
||
| public AccountEntity setPostureScore(Integer postureScore) { | ||
| this.postureScore = postureScore; | ||
| return this; | ||
| } | ||
|
|
||
| public BigDecimal getMonthlySpend() { | ||
| return monthlySpend; | ||
| } | ||
|
|
||
| public AccountEntity setMonthlySpend(BigDecimal monthlySpend) { | ||
| this.monthlySpend = monthlySpend; | ||
| return this; | ||
| } | ||
|
|
||
| public BigDecimal getReclaimable() { | ||
| return reclaimable; | ||
| } | ||
|
|
||
| public AccountEntity setReclaimable(BigDecimal reclaimable) { | ||
| this.reclaimable = reclaimable; | ||
| return this; | ||
| } | ||
|
|
||
| public OffsetDateTime getCreatedAt() { | ||
| return createdAt; | ||
| } | ||
|
|
||
| public AccountEntity setCreatedAt(OffsetDateTime createdAt) { | ||
| this.createdAt = createdAt; | ||
| return this; | ||
| } | ||
|
|
||
| public List<RepoEntity> getRepos() { | ||
| return repos; | ||
| } | ||
|
|
||
| public AccountEntity setRepos(List<RepoEntity> repos) { | ||
| this.repos = repos; | ||
| return this; | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
backend/libs/persistence/src/main/java/dev/cleat/persistence/AccountRepository.java
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| import java.util.UUID; | ||
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface AccountRepository extends JpaRepository<AccountEntity, UUID> {} |
6 changes: 6 additions & 0 deletions
6
backend/libs/persistence/src/main/java/dev/cleat/persistence/AccountType.java
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| public enum AccountType { | ||
| USER, | ||
| ORG | ||
| } |
6 changes: 6 additions & 0 deletions
6
backend/libs/persistence/src/main/java/dev/cleat/persistence/Plan.java
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| public enum Plan { | ||
| FREE, | ||
| TEAM | ||
| } |
Oops, something went wrong.
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.