-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from all commits
755ea05
06b601f
7524ceb
35f04ea
18196e1
98f29aa
361a2c8
338329d
697704b
4327ad5
a416124
a2c0c0c
435658e
6bf74a0
52a7fc0
c5544e6
f23748c
1f34b90
013edad
5b9fbbd
2260925
2bf9b32
5547012
3a50cdf
0e35402
4e17e12
ab8e69a
cc796aa
54fd1f2
0b49008
205bd20
c301b0f
7711596
8595d5b
452fd66
72212a8
3bfc522
3b08016
c9b9732
76dc461
c868457
1e76248
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,5 +30,8 @@ jobs: | |
| - name: Set up Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still here from last round. This patches the symptom; the cause is that backend/gradlew is committed as mode 100644 instead of 100755. Fix the file once with |
||
|
|
||
| - name: Spotless, Checkstyle, compile, and test | ||
| run: ./gradlew check --no-daemon | ||
| 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 | ||
|
|
| 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") | ||
| } | ||
|
|
||
|
|
||
| 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; | ||
| } | ||
| } |
| 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> {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| public enum AccountType { | ||
| USER, | ||
| ORG | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package dev.cleat.persistence; | ||
|
|
||
| public enum Plan { | ||
| FREE, | ||
| TEAM | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.