From f1aba630b1cd3d2fa12fba326ad04c35d93fb4aa Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Mon, 7 Apr 2025 22:14:47 +0200 Subject: [PATCH] Refactor: Asserts in Test leesbarer --- .../java/de/juplo/kafka/ApplicationTests.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index c70d705..def547c 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -51,8 +51,10 @@ public class ApplicationTests public void testApplicationStartup() { ResponseEntity response = restTemplate.getForEntity("/actuator/health", String.class); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.OK.value())); - assertThat(JsonPath.parse(response.getBody()).read("$.status", String.class)).isEqualTo("UP"); + assertThat(response.getStatusCode()) + .isEqualTo(HttpStatusCode.valueOf(HttpStatus.OK.value())); + assertThat(JsonPath.parse(response.getBody()).read("$.status", String.class)) + .isEqualTo("UP"); } @DisplayName("Existing offset") @@ -68,8 +70,10 @@ public class ApplicationTests String.class, recordMetadata.partition(), recordMetadata.offset()); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.OK.value())); - assertThat(response.getBody()).isEqualTo(value); + assertThat(response.getStatusCode()) + .isEqualTo(HttpStatusCode.valueOf(HttpStatus.OK.value())); + assertThat(response.getBody()) + .isEqualTo(value); } @DisplayName("Not yet existing offset") @@ -78,7 +82,8 @@ public class ApplicationTests void testNotYetExistingOffset(int partition) { ResponseEntity response = restTemplate.getForEntity("/{partition}/666", String.class, partition); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value())); + assertThat(response.getStatusCode()) + .isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value())); } @DisplayName("Already deleted offset") @@ -93,7 +98,8 @@ public class ApplicationTests String.class, recordMetadata.partition(), recordMetadata.offset()); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value())); + assertThat(response.getStatusCode()) + .isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value())); } @DisplayName("Non-existent partition") @@ -102,7 +108,8 @@ public class ApplicationTests void testNonExistentPartition(int partition) { ResponseEntity response = restTemplate.getForEntity("/{partition}/0", String.class, partition); - assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.BAD_REQUEST.value())); + assertThat(response.getStatusCode()) + .isEqualTo(HttpStatusCode.valueOf(HttpStatus.BAD_REQUEST.value())); } -- 2.20.1