Skip to content

Commit

Permalink
fix : assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Jan 10, 2025
1 parent f17a48e commit 3dcf553
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kafka-spring-boot/boot-kafka-sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ curl -X POST http://localhost:8080/listeners \
```

### Error Responses
* `400 Bad Request`: Invalid operation value or malformed request
* `404 Not Found`: Specified listener container ID not found
- `400 Bad Request`: Invalid operation value or malformed request
- `404 Not Found`: Specified listener container ID not found
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class MessageRestController {
this.messageService = messageService;
}

@Operation(summary = "Get the state of all Kafka listeners")
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "Retrieved listeners state successfully",
content =
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class)))
})
@GetMapping("/listeners")
ResponseEntity<Map<String, Boolean>> getListeners() {
return ResponseEntity.ok(messageService.getListenersState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;

public record KafkaListenerRequest(
@NotBlank(message = "Container ID must not be blank") String containerId,
@NotBlank(message = "Container ID must not be blank")
@Pattern(regexp = "^\\S.*$", message = "Container ID must not start with whitespace")
String containerId,
@NotNull(message = "Operation must not be null") Operation operation) {}
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ void stopAndStartContainers() throws Exception {
String expectedJson =
"""
{
"topic_2_Listener-dlt": %s,
"topic_2_Listener": true,
"topic_2_Listener-retry": true,
"topic_1_Listener": true
"topic_1_Listener": true,
"topic_2_Listener-dlt": %s
}
""";
this.mockMvcTester
Expand All @@ -168,7 +168,7 @@ void stopAndStartContainers() throws Exception {
.post()
.uri("/listeners")
.content(this.objectMapper.writeValueAsString(
new KafkaListenerRequest(" topic_2_Listener-dlt", Operation.START)))
new KafkaListenerRequest("topic_2_Listener-dlt", Operation.START)))
.contentType(MediaType.APPLICATION_JSON)
.assertThat()
.hasStatusOk()
Expand Down

0 comments on commit 3dcf553

Please sign in to comment.