4040import com .apple .foundationdb .tuple .Tuple ;
4141import com .apple .foundationdb .tuple .TupleHelpers ;
4242import com .apple .test .BooleanSource ;
43+ import com .apple .test .ParameterizedTestUtils ;
4344import com .apple .test .Tags ;
4445import com .google .common .collect .ImmutableList ;
4546import com .google .common .collect .Lists ;
@@ -1640,8 +1641,8 @@ static Stream<Arguments> testValidationInvalidValues() {
16401641 void testValidationInvalidValues (KeySpaceDirectory .KeyType keyType , Object value ) {
16411642 final KeySpaceDirectory directory = new KeySpaceDirectory ("test_dir" , keyType );
16421643
1643- // Should fail - value doesn't match the key type
1644- Assertions . assertThrows ( RecordCoreArgumentException . class , () -> directory . validateValue ( value ) );
1644+ Assertions . assertThrows ( RecordCoreArgumentException . class , () -> directory . validateValue ( value ),
1645+ " value doesn't match the key type" );
16451646 }
16461647
16471648 static Stream <KeySpaceDirectory .KeyType > testValidationNullToNonNullType () {
@@ -1654,8 +1655,57 @@ static Stream<KeySpaceDirectory.KeyType> testValidationNullToNonNullType() {
16541655 void testValidationNullToNonNullType (KeySpaceDirectory .KeyType keyType ) {
16551656 final KeySpaceDirectory directory = new KeySpaceDirectory ("test_dir" , keyType );
16561657
1657- // Should fail - null not allowed for non-NULL types
1658- Assertions .assertThrows (RecordCoreArgumentException .class , () -> directory .validateValue (null ));
1658+ Assertions .assertThrows (RecordCoreArgumentException .class , () -> directory .validateValue (null ),
1659+ "null not allowed for non-NULL types" );
1660+ }
1661+
1662+ static Stream <Arguments > testDirectoryLayerDirectoryValidateValueValidStrings () {
1663+ return Stream .of (
1664+ // ANY_VALUE directory - accepts any string
1665+ Arguments .of (false , "foo" , true ),
1666+ Arguments .of (false , "bar" , true ),
1667+ Arguments .of (false , "" , true ),
1668+ Arguments .of (false , "any_string_value" , true ),
1669+
1670+ // Constant directory - only accepts matching constant
1671+ Arguments .of (true , "production" , true ),
1672+ Arguments .of (true , "staging" , false ),
1673+ Arguments .of (true , "" , false ),
1674+ Arguments .of (true , "other" , false )
1675+ );
1676+ }
1677+
1678+ @ ParameterizedTest
1679+ @ MethodSource
1680+ void testDirectoryLayerDirectoryValidateValueValidStrings (boolean isConstant , String value , boolean shouldSucceed ) {
1681+ DirectoryLayerDirectory directory = isConstant
1682+ ? new DirectoryLayerDirectory ("test_dir" , "production" )
1683+ : new DirectoryLayerDirectory ("test_dir" );
1684+
1685+ if (shouldSucceed ) {
1686+ directory .validateValue (value );
1687+ } else {
1688+ Assertions .assertThrows (RecordCoreArgumentException .class , () -> directory .validateValue (value ),
1689+ "value doesn't match constant" );
1690+ }
1691+ }
1692+
1693+ static Stream <Arguments > testDirectoryLayerDirectoryValidateValueInvalidTypes () {
1694+ return ParameterizedTestUtils .cartesianProduct (
1695+ ParameterizedTestUtils .booleans ("isConstant" ),
1696+ Stream .of (42L , 123 , 3.14f , 2.718 , true , new byte []{1 , 2 , 3 }, UUID .randomUUID (), null )
1697+ );
1698+ }
1699+
1700+ @ ParameterizedTest
1701+ @ MethodSource
1702+ void testDirectoryLayerDirectoryValidateValueInvalidTypes (boolean isConstant , Object value ) {
1703+ DirectoryLayerDirectory directory = isConstant
1704+ ? new DirectoryLayerDirectory ("test_dir" , "production" )
1705+ : new DirectoryLayerDirectory ("test_dir" );
1706+
1707+ Assertions .assertThrows (RecordCoreArgumentException .class , () -> directory .validateValue (value ),
1708+ "DirectoryLayerDirectory only accepts Strings" );
16591709 }
16601710
16611711 static final class KeyPathValues {
0 commit comments