33import com .microsoft .semantickernel .data .jdbc .JDBCVectorStore ;
44import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreOptions ;
55import com .microsoft .semantickernel .data .jdbc .JDBCVectorStoreRecordCollectionOptions ;
6+ import com .microsoft .semantickernel .data .jdbc .oracle .OracleVectorStoreQueryProvider .StringTypeMapping ;
67import com .microsoft .semantickernel .data .vectorsearch .VectorSearchFilter ;
78import com .microsoft .semantickernel .data .vectorsearch .VectorSearchResults ;
89import com .microsoft .semantickernel .data .vectorstorage .VectorStoreRecordCollection ;
1112import com .microsoft .semantickernel .data .vectorstorage .annotations .VectorStoreRecordVector ;
1213import com .microsoft .semantickernel .data .vectorstorage .definition .DistanceFunction ;
1314import com .microsoft .semantickernel .data .vectorstorage .definition .IndexKind ;
15+ import com .microsoft .semantickernel .data .vectorstorage .definition .VectorStoreRecordDefinition ;
16+ import com .microsoft .semantickernel .data .vectorstorage .definition .VectorStoreRecordKeyField ;
1417import com .microsoft .semantickernel .data .vectorstorage .options .GetRecordOptions ;
1518import com .microsoft .semantickernel .data .vectorstorage .options .VectorSearchOptions ;
1619import com .microsoft .semantickernel .exceptions .SKException ;
20+
1721import org .junit .jupiter .api .Test ;
1822import java .sql .Connection ;
1923import java .sql .PreparedStatement ;
2024import java .sql .ResultSet ;
2125import java .sql .SQLException ;
26+ import java .util .ArrayList ;
2227import java .util .Arrays ;
2328import java .util .Collection ;
29+ import java .util .Collections ;
2430import java .util .List ;
31+ import java .util .stream .Collectors ;
2532
2633import static org .junit .jupiter .api .Assertions .assertEquals ;
2734import static org .junit .jupiter .api .Assertions .assertIterableEquals ;
@@ -184,7 +191,7 @@ void testVectorDimensionMismatch() {
184191 }
185192
186193 @ Test
187- void testNull () {
194+ void testNullFieldValue () {
188195 VectorStoreRecordCollection <String , DummyRecord > collection =
189196 createCollection ("test_null" , DummyRecord .class , null );
190197
@@ -210,7 +217,59 @@ void testNull() {
210217
211218 @ Test
212219 void testSkipAndTop () {
220+ VectorStoreRecordCollection <String , DummyRecord > collection =
221+ createCollection (
222+ "test_skip_and_top" ,
223+ DummyRecord .class ,
224+ null );
225+
226+ List <DummyRecord > l1 = new ArrayList <>();
227+ for (int i = 1 ; i <= 10 ; i ++) {
228+ l1 .add (new DummyRecord ("id" + i , i , (double ) i , floatVec (i )));
229+ }
230+ collection .upsertBatchAsync (l1 , null ).block ();
231+
232+ VectorSearchResults <DummyRecord > results = collection .searchAsync (
233+ Collections .nCopies (8 ,0f ),
234+ VectorSearchOptions .builder ()
235+ .withIncludeVectors (true )
236+ .withSkip (5 )
237+ .withTop (3 )
238+ .build ()
239+ ).block ();
240+
241+ assertEquals (3 , results .getResults ().size ());
242+ List <String > ids = results .getResults ().stream ().map (r -> r .getRecord ().getId ()).collect (
243+ Collectors .toList ());
244+ assertEquals (Arrays .asList ("id6" ,"id7" ,"id8" ), ids );
245+
246+ collection .deleteCollectionAsync ().block ();
247+ }
248+
249+ // corner case for OracleVectorStoreRecordMapper
250+ @ Test
251+ void testMapRecordToStorageModel_throws () {
252+ VectorStoreRecordKeyField keyField = VectorStoreRecordKeyField .builder ()
253+ .withName ("id" )
254+ .withStorageName ("id" )
255+ .withFieldType (String .class )
256+ .build ();
257+
258+ VectorStoreRecordDefinition definition =
259+ VectorStoreRecordDefinition .fromFields (
260+ Arrays .asList (keyField )
261+ );
262+
263+ OracleVectorStoreRecordMapper <DummyRecord > mapper =
264+ OracleVectorStoreRecordMapper .<DummyRecord > builder ()
265+ .withRecordClass (DummyRecord .class )
266+ .withVectorStoreRecordDefinition (definition )
267+ .build ();
213268
269+ UnsupportedOperationException ex = assertThrows (
270+ UnsupportedOperationException .class ,
271+ () -> mapper .mapRecordToStorageModel (new DummyRecord ()));
272+ assertEquals ("Not implemented" , ex .getMessage ());
214273 }
215274
216275 private <T > VectorStoreRecordCollection <String , T > createCollection (
0 commit comments