Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port : fix notification rule test for rule not found #1045

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,18 @@ public Response restoreDefaultTemplates() {
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Test notification dispatched successfully"),
@ApiResponse(responseCode = "401", description = "Unauthorized")
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Notification rule not found")
})
@PermissionRequired(Permissions.Constants.SYSTEM_CONFIGURATION)
public Response testSlackPublisherConfig(
public Response testNotificationRule(
@Parameter(description = "The UUID of the rule to test", schema = @Schema(type = "string", format = "uuid"), required = true)
@PathParam("uuid") @ValidUuid String ruleUuid) {
try (QueryManager qm = new QueryManager()) {
NotificationRule rule = qm.getObjectByUuid(NotificationRule.class, ruleUuid);
if (rule == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
final KafkaEventDispatcher eventDispatcher = new KafkaEventDispatcher();
for(NotificationGroup group : rule.getNotifyOn()){
eventDispatcher.dispatchNotification(new Notification()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,12 @@ public void testNotificationRuleTest() {
Assert.assertEquals(200, response.getStatus());
assertThat(kafkaMockProducer.history().size()).isEqualTo(11);
}

@Test
public void testNotificationRuleNotFoundTest() {
final Response response = jersey.target(V1_NOTIFICATION_PUBLISHER + "/test/" + UUID.randomUUID()).request()
.header(X_API_KEY, apiKey)
.post(null);
assertThat(response.getStatus()).isEqualTo(404);
}
}
Loading