-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6df0c4c
commit 4a7ae57
Showing
14 changed files
with
178 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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 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,2 +1,2 @@ | ||
java=17.0.4-tem | ||
java=17.0.8-tem | ||
maven=3.8.6 |
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -8,24 +8,27 @@ | |
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@SpringBootTest( | ||
properties = {"spring.test.database.replace=none", "spring.datasource.url=jdbc:tc:postgresql:15.3-alpine:///db" | ||
}) | ||
properties = { | ||
"spring.test.database.replace=none", | ||
"spring.datasource.url=jdbc:tc:postgresql:16-alpine:///db", | ||
} | ||
) | ||
@Sql("/test-data.sql") | ||
class PostRepositoryTest { | ||
|
||
@Autowired | ||
PostRepository repository; | ||
@Autowired | ||
PostRepository repository; | ||
|
||
@Test | ||
void shouldGetPostById() { | ||
Post post = repository.getPostById(1L).orElseThrow(); | ||
@Test | ||
void shouldGetPostById() { | ||
Post post = repository.getPostById(1L).orElseThrow(); | ||
|
||
assertThat(post.id()).isEqualTo(1L); | ||
assertThat(post.title()).isEqualTo("Post 1 Title"); | ||
assertThat(post.content()).isEqualTo("Post 1 content"); | ||
assertThat(post.createdBy().id()).isEqualTo(1L); | ||
assertThat(post.createdBy().name()).isEqualTo("Siva"); | ||
assertThat(post.createdBy().email()).isEqualTo("[email protected]"); | ||
assertThat(post.comments()).hasSize(2); | ||
} | ||
assertThat(post.id()).isEqualTo(1L); | ||
assertThat(post.title()).isEqualTo("Post 1 Title"); | ||
assertThat(post.content()).isEqualTo("Post 1 content"); | ||
assertThat(post.createdBy().id()).isEqualTo(1L); | ||
assertThat(post.createdBy().name()).isEqualTo("Siva"); | ||
assertThat(post.createdBy().email()).isEqualTo("[email protected]"); | ||
assertThat(post.comments()).hasSize(2); | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -10,38 +10,41 @@ | |
import org.springframework.test.context.jdbc.Sql; | ||
|
||
@JooqTest( | ||
properties = {"spring.test.database.replace=none", "spring.datasource.url=jdbc:tc:postgresql:15.3-alpine:///db" | ||
}) | ||
properties = { | ||
"spring.test.database.replace=none", | ||
"spring.datasource.url=jdbc:tc:postgresql:16-alpine:///db", | ||
} | ||
) | ||
@Sql("/test-data.sql") | ||
class UserRepositoryJooqTest { | ||
|
||
@Autowired | ||
DSLContext dsl; | ||
@Autowired | ||
DSLContext dsl; | ||
|
||
UserRepository repository; | ||
UserRepository repository; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
this.repository = new UserRepository(dsl); | ||
} | ||
@BeforeEach | ||
void setUp() { | ||
this.repository = new UserRepository(dsl); | ||
} | ||
|
||
@Test | ||
void shouldCreateUserSuccessfully() { | ||
User user = new User(null, "John", "[email protected]"); | ||
@Test | ||
void shouldCreateUserSuccessfully() { | ||
User user = new User(null, "John", "[email protected]"); | ||
|
||
User savedUser = repository.createUser(user); | ||
User savedUser = repository.createUser(user); | ||
|
||
assertThat(savedUser.id()).isNotNull(); | ||
assertThat(savedUser.name()).isEqualTo("John"); | ||
assertThat(savedUser.email()).isEqualTo("[email protected]"); | ||
} | ||
assertThat(savedUser.id()).isNotNull(); | ||
assertThat(savedUser.name()).isEqualTo("John"); | ||
assertThat(savedUser.email()).isEqualTo("[email protected]"); | ||
} | ||
|
||
@Test | ||
void shouldGetUserByEmail() { | ||
User user = repository.getUserByEmail("[email protected]").orElseThrow(); | ||
@Test | ||
void shouldGetUserByEmail() { | ||
User user = repository.getUserByEmail("[email protected]").orElseThrow(); | ||
|
||
assertThat(user.id()).isEqualTo(1L); | ||
assertThat(user.name()).isEqualTo("Siva"); | ||
assertThat(user.email()).isEqualTo("[email protected]"); | ||
} | ||
assertThat(user.id()).isEqualTo(1L); | ||
assertThat(user.name()).isEqualTo("Siva"); | ||
assertThat(user.email()).isEqualTo("[email protected]"); | ||
} | ||
} |
Oops, something went wrong.