1818package com .datastax .oss .driver .core .data ;
1919
2020import static org .assertj .core .api .Assertions .assertThat ;
21+ import static org .assertj .core .api .InstanceOfAssertFactories .type ;
2122import static org .junit .Assert .fail ;
2223
2324import com .datastax .oss .driver .api .core .CqlIdentifier ;
@@ -185,6 +186,7 @@ public static Object[][] typeSamples() {
185186 // 5) include map<type, int>
186187 // 6) include tuple<int, type>
187188 // 7) include udt<int, type>
189+ // 8) include vector<type>
188190 return Arrays .stream (primitiveSamples )
189191 .flatMap (
190192 o -> {
@@ -281,6 +283,23 @@ public static Object[][] typeSamples() {
281283 .toArray (Object [][]::new );
282284 }
283285
286+ @ DataProvider
287+ public static Object [][] addVectors (){
288+ Object [][] previousSamples = typeSamples ();
289+ if (CCM_RULE .getCassandraVersion ().compareTo (Version .parse ("5.0" )) < 0 ) return previousSamples ;
290+ return Arrays .stream (previousSamples ).flatMap (
291+ o -> {
292+ List <Object []> samples = new ArrayList <>();
293+ samples .add (o );
294+ if (o [1 ] == null ) return samples .stream ();
295+ DataType dataType = (DataType ) o [0 ];
296+ CqlVector <?> vector = CqlVector .newInstance (o [1 ]);
297+ samples .add (new Object [] {DataTypes .vectorOf (dataType , 1 ), vector });
298+ return samples .stream ();
299+ }).toArray (Object [][]::new );
300+ }
301+
302+
284303 @ BeforeClass
285304 public static void createTable () {
286305 // Create a table with all types being tested with.
@@ -291,7 +310,7 @@ public static void createTable() {
291310
292311 List <String > columnData = new ArrayList <>();
293312
294- for (Object [] sample : typeSamples ()) {
313+ for (Object [] sample : addVectors ()) {
295314 DataType dataType = (DataType ) sample [0 ];
296315
297316 if (!typeToColumnName .containsKey (dataType )) {
@@ -321,7 +340,7 @@ private static int nextKey() {
321340 return keyCounter .incrementAndGet ();
322341 }
323342
324- @ UseDataProvider ("typeSamples " )
343+ @ UseDataProvider ("addVectors " )
325344 @ Test
326345 public <K > void should_insert_non_primary_key_column_simple_statement_using_format (
327346 DataType dataType , K value , K expectedPrimitiveValue ) {
@@ -348,7 +367,7 @@ public <K> void should_insert_non_primary_key_column_simple_statement_using_form
348367 readValue (select , dataType , value , expectedPrimitiveValue );
349368 }
350369
351- @ UseDataProvider ("typeSamples " )
370+ @ UseDataProvider ("addVectors " )
352371 @ Test
353372 public <K > void should_insert_non_primary_key_column_simple_statement_positional_value (
354373 DataType dataType , K value , K expectedPrimitiveValue ) {
@@ -371,7 +390,7 @@ public <K> void should_insert_non_primary_key_column_simple_statement_positional
371390 readValue (select , dataType , value , expectedPrimitiveValue );
372391 }
373392
374- @ UseDataProvider ("typeSamples " )
393+ @ UseDataProvider ("addVectors " )
375394 @ Test
376395 public <K > void should_insert_non_primary_key_column_simple_statement_named_value (
377396 DataType dataType , K value , K expectedPrimitiveValue ) {
@@ -395,7 +414,7 @@ public <K> void should_insert_non_primary_key_column_simple_statement_named_valu
395414 readValue (select , dataType , value , expectedPrimitiveValue );
396415 }
397416
398- @ UseDataProvider ("typeSamples " )
417+ @ UseDataProvider ("addVectors " )
399418 @ Test
400419 public <K > void should_insert_non_primary_key_column_bound_statement_positional_value (
401420 DataType dataType , K value , K expectedPrimitiveValue ) {
@@ -424,7 +443,7 @@ public <K> void should_insert_non_primary_key_column_bound_statement_positional_
424443 readValue (boundSelect , dataType , value , expectedPrimitiveValue );
425444 }
426445
427- @ UseDataProvider ("typeSamples " )
446+ @ UseDataProvider ("addVectors " )
428447 @ Test
429448 public <K > void should_insert_non_primary_key_column_bound_statement_named_value (
430449 DataType dataType , K value , K expectedPrimitiveValue ) {
0 commit comments