11package io .pinecone .integration .dataPlane ;
22
3+ import com .google .common .util .concurrent .ListenableFuture ;
34import io .grpc .StatusRuntimeException ;
45import io .pinecone .clients .Index ;
56import io .pinecone .clients .Pinecone ;
67import io .pinecone .clients .AsyncIndex ;
78import io .pinecone .exceptions .PineconeValidationException ;
89import io .pinecone .helpers .RandomStringBuilder ;
910import io .pinecone .proto .*;
11+ import io .pinecone .unsigned_indices_model .QueryResponseWithUnsignedIndices ;
1012import org .junit .jupiter .api .BeforeAll ;
1113import org .junit .jupiter .api .Test ;
1214import org .openapitools .client .model .IndexModelSpec ;
1618import java .util .Arrays ;
1719import java .util .List ;
1820import java .util .concurrent .ExecutionException ;
21+ import java .util .concurrent .TimeUnit ;
22+ import java .util .concurrent .TimeoutException ;
1923
2024import static io .pinecone .helpers .BuildUpsertRequest .*;
2125import static io .pinecone .helpers .IndexManager .createIndexIfNotExistsDataPlane ;
@@ -76,15 +80,16 @@ public void QueryWithNullSparseIndicesNotNullSparseValuesSyncTest() {
7680 }
7781
7882 @ Test
79- public void queryWithIncorrectVectorDimensionFuture () throws ExecutionException , InterruptedException {
83+ public void queryWithIncorrectVectorDimensionFuture () throws ExecutionException , InterruptedException , TimeoutException {
8084 String namespace = RandomStringBuilder .build ("ns" , 8 );
8185 DescribeIndexStatsResponse describeIndexStatsResponse1 = asyncIndexClient .describeIndexStats (null ).get ();
8286 assertEquals (describeIndexStatsResponse1 .getDimension (), dimension );
8387
8488 // Query with incorrect dimensions
8589 try {
8690 List <Float > vector = Arrays .asList (100F );
87- asyncIndexClient .query (5 , vector , null , null , null , namespace , null , true , true ).get ();
91+ ListenableFuture <QueryResponseWithUnsignedIndices > queryFuture = asyncIndexClient .query (5 , vector , null , null , null , namespace , null , true , true );
92+ queryFuture .get (10 , TimeUnit .SECONDS );
8893
8994 fail ("queryWithIncorrectVectorDimensionFuture should have thrown ExecutionException" );
9095 } catch (ExecutionException expected ) {
@@ -94,20 +99,22 @@ public void queryWithIncorrectVectorDimensionFuture() throws ExecutionException,
9499 }
95100
96101 @ Test
97- public void QueryWithNullSparseIndicesNotNullSparseValuesFutureTest () throws ExecutionException , InterruptedException {
102+ public void QueryWithNullSparseIndicesNotNullSparseValuesFutureTest () throws ExecutionException , InterruptedException , TimeoutException {
98103 String id = RandomStringBuilder .build (3 );
99104
100105 try {
101- asyncIndexClient .update (id ,
106+ ListenableFuture < UpdateResponse > updateFuture = asyncIndexClient .update (id ,
102107 generateVectorValuesByDimension (dimension ),
103108 null ,
104109 null ,
105110 null ,
106- generateVectorValuesByDimension (dimension )).get ();
111+ generateVectorValuesByDimension (dimension ));
112+
113+ updateFuture .get (10 , TimeUnit .SECONDS );
107114
108115 fail ("QueryWithNullSparseIndicesNotNullSparseValuesFutureTest should have thrown PineconeValidationException" );
109116 } catch (PineconeValidationException expected ) {
110- assertEquals (expected .getLocalizedMessage (), "ensure that both sparse indices and values are present" );
117+ assertTrue (expected .getLocalizedMessage (). contains ( "ensure that both sparse indices and values are present" ) );
111118 }
112119 }
113120}
0 commit comments