ROT: Verhalten beim Abrufen von einer nicht existierenden Partition definiert
authorKai Moritz <kai@juplo.de>
Mon, 7 Apr 2025 17:42:59 +0000 (19:42 +0200)
committerKai Moritz <kai@juplo.de>
Wed, 21 May 2025 18:14:13 +0000 (20:14 +0200)
src/test/java/de/juplo/kafka/ApplicationTests.java

index 0f78ea7..942bf69 100644 (file)
@@ -10,6 +10,8 @@ import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -74,6 +76,15 @@ public class ApplicationTests
     assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value()));
   }
 
+  @DisplayName("Non-existent partition")
+  @ParameterizedTest(name = "partition: {0}")
+  @ValueSource(ints = { -1, NUM_PARTITIONS, 66 })
+  void testNonExistentPartition(int partition)
+  {
+    ResponseEntity<String> response = restTemplate.getForEntity("/{partition}/0", String.class, partition);
+    assertThat(response.getStatusCode()).isEqualTo(HttpStatusCode.valueOf(HttpStatus.NOT_FOUND.value()));
+  }
+
 
   static final String TOPIC = "ExampleConsumerTest_TEST";
   static final int NUM_PARTITIONS = 7;