Skip to content

Commit 907d4af

Browse files
authored
Add NotificationClassification.SCHEMA (#1567)
A new notification classification for notifications about indexes and constraints.
1 parent adcbf49 commit 907d4af

File tree

4 files changed

+79
-1
lines changed

4 files changed

+79
-1
lines changed

driver/src/main/java/org/neo4j/driver/NotificationCategory.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,15 @@ public sealed interface NotificationCategory extends Serializable permits Notifi
9090
* For instance, notifications that are not part of a more specific class.
9191
*/
9292
NotificationCategory GENERIC = NotificationClassification.GENERIC;
93+
94+
/**
95+
* A schema category.
96+
* <p>
97+
* For instance, notifications about indexes and constraints.
98+
* <p>
99+
* Please note that this category was added to a later server version. Therefore, a compatible server version is
100+
* required to use it.
101+
* @since 5.24.0
102+
*/
103+
NotificationCategory SCHEMA = NotificationClassification.SCHEMA;
93104
}

driver/src/main/java/org/neo4j/driver/NotificationClassification.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,15 @@ public enum NotificationClassification implements NotificationCategory {
8686
* <p>
8787
* For instance, notifications that are not part of a more specific class.
8888
*/
89-
GENERIC
89+
GENERIC,
90+
/**
91+
* A schema category.
92+
* <p>
93+
* For instance, notifications about indexes and constraints.
94+
* <p>
95+
* Please note that this category was added to a later server version. Therefore, a compatible server version is
96+
* required to use it.
97+
* @since 5.24.0
98+
*/
99+
SCHEMA
90100
}

driver/src/main/java/org/neo4j/driver/internal/summary/InternalNotification.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static Optional<NotificationCategory> valueOf(String value) {
4141
case SECURITY -> NotificationCategory.SECURITY;
4242
case TOPOLOGY -> NotificationCategory.TOPOLOGY;
4343
case GENERIC -> NotificationCategory.GENERIC;
44+
case SCHEMA -> NotificationCategory.SCHEMA;
4445
});
4546
}
4647

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [https://neo4j.com]
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.neo4j.driver.internal.summary;
18+
19+
import static org.junit.jupiter.api.Assertions.assertEquals;
20+
21+
import java.util.Arrays;
22+
import java.util.stream.Stream;
23+
import org.junit.jupiter.params.ParameterizedTest;
24+
import org.junit.jupiter.params.provider.Arguments;
25+
import org.junit.jupiter.params.provider.MethodSource;
26+
import org.neo4j.driver.NotificationCategory;
27+
import org.neo4j.driver.NotificationClassification;
28+
29+
class InternalNotificationTest {
30+
@ParameterizedTest
31+
@MethodSource("shouldMapArgs")
32+
void shouldMap(String value, NotificationCategory expectedNotificationCategory) {
33+
var notificationCategory = InternalNotification.valueOf(value).orElse(null);
34+
35+
assertEquals(expectedNotificationCategory, notificationCategory);
36+
}
37+
38+
static Stream<Arguments> shouldMapArgs() {
39+
return Arrays.stream(NotificationClassification.values())
40+
.map(notificationClassification -> switch (notificationClassification) {
41+
case HINT -> Arguments.of(notificationClassification.toString(), NotificationCategory.HINT);
42+
case UNRECOGNIZED -> Arguments.of(
43+
notificationClassification.toString(), NotificationCategory.UNRECOGNIZED);
44+
case UNSUPPORTED -> Arguments.of(
45+
notificationClassification.toString(), NotificationCategory.UNSUPPORTED);
46+
case PERFORMANCE -> Arguments.of(
47+
notificationClassification.toString(), NotificationCategory.PERFORMANCE);
48+
case DEPRECATION -> Arguments.of(
49+
notificationClassification.toString(), NotificationCategory.DEPRECATION);
50+
case SECURITY -> Arguments.of(notificationClassification.toString(), NotificationCategory.SECURITY);
51+
case TOPOLOGY -> Arguments.of(notificationClassification.toString(), NotificationCategory.TOPOLOGY);
52+
case GENERIC -> Arguments.of(notificationClassification.toString(), NotificationCategory.GENERIC);
53+
case SCHEMA -> Arguments.of(notificationClassification.toString(), NotificationCategory.SCHEMA);
54+
});
55+
}
56+
}

0 commit comments

Comments
 (0)