### Question:
IndexTextValueLengthValidator extends AbstractIndexKeyLengthValidator { public void validate( byte[] encodedValue ) { if ( encodedValue == null ) { throw new IllegalArgumentException( "Null value" ); } validateLength( encodedValue.length ); } IndexTextValueLengthValidator( int maxByteLength ); void validate( byte[] encodedValue );  }### Answer:
@Test public void tooLongByteArrayIsNotAllowed() { int length = MAX_BYTE_LENGTH * 2; expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( containsString( "Property value size is too large for index. Please see index documentation for limitations." ) ); validator.validate( RandomUtils.nextBytes( length ) ); }
@Test public void tooLongStringIsNotAllowed() { int length = MAX_BYTE_LENGTH * 2; expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( containsString( "Property value size is too large for index. Please see index documentation for limitations." ) ); validator.validate( string( length ) ); }
@Test public void shortByteArrayIsValid() { validator.validate( RandomUtils.nextBytes( 3 ) ); validator.validate( RandomUtils.nextBytes( 30 ) ); validator.validate( RandomUtils.nextBytes( 300 ) ); validator.validate( RandomUtils.nextBytes( 4303 ) ); validator.validate( RandomUtils.nextBytes( 13234 ) ); validator.validate( RandomUtils.nextBytes( MAX_BYTE_LENGTH ) ); }
@Test public void shortStringIsValid() { validator.validate( string( 3 ) ); validator.validate( string( 30 ) ); validator.validate( string( 300 ) ); validator.validate( string( 4303 ) ); validator.validate( string( 13234 ) ); validator.validate( string( MAX_BYTE_LENGTH ) ); }
@Test public void nullIsNotAllowed() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Null value" ); validator.validate( (byte[]) null ); }
@Test public void nullValueIsNotAllowed() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Null value" ); validator.validate( (Value) null ); }
@Test public void noValueIsNotAllowed() { expectedException.expect( IllegalArgumentException.class ); expectedException.expectMessage( "Null value" ); validator.validate( NO_VALUE ); }
@Test( expected = IllegalArgumentException.class ) public void shouldFailOnTooLongNonLatinString() { byte[] facesBytes = stringOfEmojis( 1 ); validator.validate( stringValue( new String( facesBytes, UTF_8 ) ) ); }
@Test public void shouldSucceedOnReasonablyLongNonLatinString() { byte[] facesBytes = stringOfEmojis( 0 ); validator.validate( stringValue( new String( facesBytes, UTF_8 ) ) ); }