Skip to content

Commit ce8665f

Browse files
author
Madhavan
committed
StringToVectorCodecTest.should_fail_to_encode_too_many_or_too_few:111 » IllegalArgument fix
1 parent 856357b commit ce8665f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

codecs/text/src/test/java/com/datastax/oss/dsbulk/codecs/text/string/StringToVectorCodecTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ void should_not_convert_from_invalid_external() {
9292
assertThat(codec).cannotConvertFromExternal("[6.646329843]");
9393
}
9494

95-
// To keep usage consistent with VectorCodec we confirm that we support encoding when too many
96-
// elements are available but not when too few are. Note that it's actually VectorCodec that
97-
// enforces this constraint so we have to go through encode() rather than the internal/external
98-
// methods.
95+
// VectorCodec enforces strict dimension matching: encoding fails for both too-many and too-few
96+
// elements. We have to go through encode() rather than the internal/external methods because
97+
// the dimension check is performed by VectorCodec during binary encoding, not during
98+
// String-to-CqlVector conversion.
9999
@Test
100100
void should_fail_to_encode_too_many_or_too_few() {
101101

@@ -108,7 +108,8 @@ void should_fail_to_encode_too_many_or_too_few() {
108108
CqlVector<Float> tooFewVector = CqlVector.newInstance(tooFew);
109109
String tooFewString = codec.internalToExternal(tooFewVector);
110110

111-
assertThat(codec.encode(tooManyString, ProtocolVersion.DEFAULT)).isNotNull();
111+
assertThatThrownBy(() -> codec.encode(tooManyString, ProtocolVersion.DEFAULT))
112+
.isInstanceOf(IllegalArgumentException.class);
112113
assertThatThrownBy(() -> codec.encode(tooFewString, ProtocolVersion.DEFAULT))
113114
.isInstanceOf(IllegalArgumentException.class);
114115
}

0 commit comments

Comments
 (0)