|
| 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