Skip to content

Commit 8ade88f

Browse files
committed
Add shouldUpdatePostWhenPostIsValid🫸🌀✏️📗🐧🐳⬆
1 parent dfd0144 commit 8ade88f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/java/id/my/hendisantika/testcontainerpostgresql/SpringBootTestContainerPostgresqlApplicationTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,20 @@ void shouldNotCreateNewPostWhenValidationFails() {
7878

7979
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
8080
}
81+
82+
@Test
83+
@Rollback
84+
void shouldUpdatePostWhenPostIsValid() {
85+
ResponseEntity<Post> response = restTemplate.exchange("/api/posts/99", HttpMethod.GET, null, Post.class);
86+
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
87+
88+
Post existing = response.getBody();
89+
assertThat(existing).isNotNull();
90+
Post updated = new Post(existing.id(), existing.userId(), "NEW POST TITLE #1", "NEW POST BODY #1", existing.version());
91+
92+
assertThat(updated.id()).isEqualTo(99);
93+
assertThat(updated.userId()).isEqualTo(10);
94+
assertThat(updated.title()).isEqualTo("NEW POST TITLE #1");
95+
assertThat(updated.body()).isEqualTo("NEW POST BODY #1");
96+
}
8197
}

0 commit comments

Comments
 (0)