Skip to content

Commit 71e0bc2

Browse files
authored
Merge pull request #203 from croz-ltd/feature_addValidationFailureFlag
Add validation failure flag to notifications
2 parents 1e11b09 + 5d2001a commit 71e0bc2

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

nrich-notification-api/src/main/java/net/croz/nrich/notification/api/model/Notification.java

+4
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ public class Notification {
6262
* Timestamp of the notification.
6363
*/
6464
private final Instant timestamp = Instant.now();
65+
66+
public boolean isValidationFailure() {
67+
return false;
68+
}
6569
}

nrich-notification-api/src/main/java/net/croz/nrich/notification/api/model/ValidationFailureNotification.java

+5
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@ public ValidationFailureNotification(String title, String content, List<String>
3939
super(title, content, messageList, severity, uxNotificationOptions);
4040
this.validationErrorList = validationErrorList;
4141
}
42+
43+
@Override
44+
public boolean isValidationFailure() {
45+
return true;
46+
}
4247
}

nrich-notification/src/test/java/net/croz/nrich/notification/service/WebMvcNotificationResponseServiceTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ void shouldCreateResponseForValidationFailureForConstraintViolation() {
9696
assertThat(notificationResponse.getNotification()).isNotNull();
9797
assertThat(notificationResponse.getNotification().getSeverity()).isEqualTo(NotificationSeverity.INFO);
9898
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Validation failed 2");
99+
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Validation failed 2");
100+
assertThat(notificationResponse.getNotification().isValidationFailure()).isTrue();
99101
}
100102

101103
@Test
@@ -108,6 +110,7 @@ void shouldCreateResponseForException() {
108110
assertThat(notificationResponse.getNotification()).isNotNull();
109111
assertThat(notificationResponse.getNotification().getSeverity()).isEqualTo(NotificationSeverity.ERROR);
110112
assertThat(notificationResponse.getNotification().getContent()).isEqualTo("Exception");
113+
assertThat(notificationResponse.getNotification().isValidationFailure()).isFalse();
111114
}
112115

113116
@Test

0 commit comments

Comments
 (0)