3131import org .junit .jupiter .params .provider .MethodSource ;
3232
3333import javax .annotation .Nullable ;
34+ import java .util .Arrays ;
35+ import java .util .Collections ;
36+ import java .util .HashMap ;
37+ import java .util .Map ;
3438import java .util .UUID ;
39+ import java .util .stream .Collectors ;
3540import java .util .stream .Stream ;
3641
3742import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
4550 */
4651class KeySpacePathSerializerTest {
4752
53+ private static final UUID TEST_UUID = UUID .randomUUID ();
54+ private static final Map <KeyType , Object > KEY_TYPE_TEST_VALUES ;
55+
56+ static {
57+ // Using HashMap to allow null values (Map.of() doesn't allow nulls)
58+ Map <KeyType , Object > testValues = new HashMap <>();
59+ testValues .put (KeyType .NULL , null );
60+ testValues .put (KeyType .STRING , "test_string" );
61+ testValues .put (KeyType .LONG , 12345L );
62+ testValues .put (KeyType .FLOAT , 3.14f );
63+ testValues .put (KeyType .DOUBLE , 2.71828 );
64+ testValues .put (KeyType .BOOLEAN , true );
65+ testValues .put (KeyType .BYTES , new byte []{1 , 2 , 3 , (byte ) 0xFF });
66+ testValues .put (KeyType .UUID , TEST_UUID );
67+ KEY_TYPE_TEST_VALUES = Collections .unmodifiableMap (testValues );
68+ }
69+
4870 @ Test
4971 void testSerializeAndDeserializeSimplePath () {
5072 KeySpace root = new KeySpace (
@@ -118,8 +140,21 @@ void testSerializeAndDeserializeMultiLevelPath() {
118140 assertArrayEquals (value , deserialized .getValue ());
119141 }
120142
143+ private static Stream <Arguments > testSerializeDeserializeAllKeyTypes () {
144+ return KEY_TYPE_TEST_VALUES .entrySet ().stream ()
145+ .map (entry -> Arguments .of (entry .getKey (), entry .getValue ()));
146+ }
147+
148+ @ Test
149+ void testKeyTypeTestValuesIncludesAllKeyTypes () {
150+ // Verify that KEY_TYPE_TEST_VALUES contains all KeyType enum values
151+ var allKeyTypes = Arrays .stream (KeyType .values ()).collect (Collectors .toSet ());
152+ var coveredKeyTypes = KEY_TYPE_TEST_VALUES .keySet ();
153+ assertEquals (allKeyTypes , coveredKeyTypes );
154+ }
155+
121156 @ ParameterizedTest
122- @ MethodSource ( "provideKeyTypes" )
157+ @ MethodSource
123158 void testSerializeDeserializeAllKeyTypes (KeyType keyType , Object value ) {
124159 KeySpace root = new KeySpace (
125160 new KeySpaceDirectory ("root" , KeyType .STRING , "root" )
@@ -144,21 +179,6 @@ void testSerializeDeserializeAllKeyTypes(KeyType keyType, Object value) {
144179 assertArrayEquals (dataValue , deserialized .getValue ());
145180 }
146181
147- private static Stream <Arguments > provideKeyTypes () {
148- UUID testUuid = UUID .randomUUID ();
149- return Stream .of (
150- Arguments .of (KeyType .NULL , null ),
151- Arguments .of (KeyType .STRING , "test_string" ),
152- Arguments .of (KeyType .LONG , 12345L ),
153- Arguments .of (KeyType .FLOAT , 3.14f ),
154- Arguments .of (KeyType .DOUBLE , 2.71828 ),
155- Arguments .of (KeyType .BOOLEAN , true ),
156- Arguments .of (KeyType .BOOLEAN , false ),
157- Arguments .of (KeyType .BYTES , new byte []{1 , 2 , 3 , (byte ) 0xFF }),
158- Arguments .of (KeyType .UUID , testUuid )
159- );
160- }
161-
162182 @ Test
163183 void testSerializeWithIntegerForLongKeyType () {
164184 KeySpace root = new KeySpace (
0 commit comments