Skip to content

Commit

Permalink
Add validation failure flag to notifications to make it easier to det…
Browse files Browse the repository at this point in the history
…erime notification type
  • Loading branch information
agrancaric committed Apr 4, 2024
1 parent 1e11b09 commit 5d2001a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ public class Notification {
* Timestamp of the notification.
*/
private final Instant timestamp = Instant.now();

public boolean isValidationFailure() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public ValidationFailureNotification(String title, String content, List<String>
super(title, content, messageList, severity, uxNotificationOptions);
this.validationErrorList = validationErrorList;
}

@Override
public boolean isValidationFailure() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void shouldCreateResponseForValidationFailureForConstraintViolation() {
assertThat(notificationResponse.getNotification()).isNotNull();
assertThat(notificationResponse.getNotification().getSeverity()).isEqualTo(NotificationSeverity.INFO);
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Validation failed 2");
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Validation failed 2");
assertThat(notificationResponse.getNotification().isValidationFailure()).isTrue();
}

@Test
Expand All @@ -108,6 +110,7 @@ void shouldCreateResponseForException() {
assertThat(notificationResponse.getNotification()).isNotNull();
assertThat(notificationResponse.getNotification().getSeverity()).isEqualTo(NotificationSeverity.ERROR);
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Exception");
assertThat(notificationResponse.getNotification().isValidationFailure()).isFalse();
}

@Test
Expand Down

0 comments on commit 5d2001a

Please sign in to comment.