66import io .weaviate .client .v1 .data .model .WeaviateObject ;
77import io .weaviate .client .v1 .misc .model .BQConfig ;
88import io .weaviate .client .v1 .misc .model .SQConfig ;
9+ import io .weaviate .client .v1 .misc .model .RQConfig ;
910import io .weaviate .client .v1 .misc .model .VectorIndexConfig ;
1011import io .weaviate .client .v1 .schema .model .Property ;
1112import io .weaviate .client .v1 .schema .model .WeaviateClass ;
2021public class ClientBatchGrpcCreateTestSuite {
2122
2223 public static void shouldCreateBatch (WeaviateClient client ,
23- Function <WeaviateClass , Result <Boolean >> createClass ,
24- Function <WeaviateObject [], Result <ObjectGetResponse []>> batchCreate ,
25- Function <WeaviateObject , Result <List <WeaviateObject >>> fetchObject ,
26- Function <String , Result <Boolean >> deleteClass ) {
24+ Function <WeaviateClass , Result <Boolean >> createClass ,
25+ Function <WeaviateObject [], Result <ObjectGetResponse []>> batchCreate ,
26+ Function <WeaviateObject , Result <List <WeaviateObject >>> fetchObject ,
27+ Function <String , Result <Boolean >> deleteClass ) {
2728
2829 testSuite t = new testSuite (client , createClass , batchCreate , fetchObject , deleteClass );
2930
@@ -36,6 +37,7 @@ public static void shouldCreateBatch(WeaviateClient client,
3637 t .testCreateBatchWithMultiReferenceWithNested ();
3738 t .testCreateBatchWithFlatVectorIndex ();
3839 t .testCreateBatchWithHNSWSQVectorIndex ();
40+ t .testCreateBatchWithHNSWRQVectorIndex ();
3941 }
4042
4143 private static class testSuite {
@@ -47,8 +49,9 @@ private static class testSuite {
4749 private final Function <String , Result <Boolean >> deleteClass ;
4850
4951 public testSuite (WeaviateClient client , Function <WeaviateClass , Result <Boolean >> createClass ,
50- Function <WeaviateObject [], Result <ObjectGetResponse []>> batchCreate , Function <WeaviateObject , Result <List <WeaviateObject >>> fetchObject ,
51- Function <String , Result <Boolean >> deleteClass ) {
52+ Function <WeaviateObject [], Result <ObjectGetResponse []>> batchCreate ,
53+ Function <WeaviateObject , Result <List <WeaviateObject >>> fetchObject ,
54+ Function <String , Result <Boolean >> deleteClass ) {
5255 this .client = client ;
5356 this .createClass = createClass ;
5457 this .batchCreate = batchCreate ;
@@ -57,7 +60,8 @@ public testSuite(WeaviateClient client, Function<WeaviateClass, Result<Boolean>>
5760 }
5861
5962 public void testCreateBatchWithReferenceWithoutNested () {
60- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
63+ WeaviateTestGenerics .AllPropertiesSchema testData =
64+ new WeaviateTestGenerics .AllPropertiesSchema ();
6165 // create ref class and populate objects
6266 testData .createRefClassesWithObjects (client );
6367 // create all properties class
@@ -70,7 +74,8 @@ public void testCreateBatchWithReferenceWithoutNested() {
7074 }
7175
7276 public void testCreateBatchWithMultiReferenceWithoutNested () {
73- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
77+ WeaviateTestGenerics .AllPropertiesSchema testData =
78+ new WeaviateTestGenerics .AllPropertiesSchema ();
7479 // create ref class and populate objects
7580 testData .createRefClassesWithObjects (client );
7681 // create all properties class
@@ -83,7 +88,8 @@ public void testCreateBatchWithMultiReferenceWithoutNested() {
8388 }
8489
8590 public void testCreateBatchWithReferenceWithNested () {
86- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
91+ WeaviateTestGenerics .AllPropertiesSchema testData =
92+ new WeaviateTestGenerics .AllPropertiesSchema ();
8793 // create ref class and populate objects
8894 testData .createRefClassesWithObjects (client );
8995 // create all properties class
@@ -96,7 +102,8 @@ public void testCreateBatchWithReferenceWithNested() {
96102 }
97103
98104 public void testCreateBatchWithMultiReferenceWithNested () {
99- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
105+ WeaviateTestGenerics .AllPropertiesSchema testData =
106+ new WeaviateTestGenerics .AllPropertiesSchema ();
100107 // create ref class and populate objects
101108 testData .createRefClassesWithObjects (client );
102109 // create all properties class
@@ -109,24 +116,29 @@ public void testCreateBatchWithMultiReferenceWithNested() {
109116 }
110117
111118 public void testCreateBatch (String vectorIndexType , VectorIndexConfig vectorIndexConfig ) {
112- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
119+ WeaviateTestGenerics .AllPropertiesSchema testData =
120+ new WeaviateTestGenerics .AllPropertiesSchema ();
113121 String className = testData .CLASS_NAME ;
114122 List <Property > properties = testData .properties ();
115123 WeaviateObject [] objects = testData .objects ();
116124 testCreateBatch (className , properties , objects , vectorIndexType , vectorIndexConfig );
117125 }
118126
119127 public void testCreateBatchWithFlatVectorIndex () {
120- VectorIndexConfig vectorIndexConfig = VectorIndexConfig .builder ()
121- .bq (BQConfig .builder ().enabled (true ).build ())
122- .build ();
128+ VectorIndexConfig vectorIndexConfig =
129+ VectorIndexConfig .builder ().bq (BQConfig .builder ().enabled (true ).build ()).build ();
123130 testCreateBatch ("flat" , vectorIndexConfig );
124131 }
125132
126133 public void testCreateBatchWithHNSWSQVectorIndex () {
127- VectorIndexConfig vectorIndexConfig = VectorIndexConfig .builder ()
128- .sq (SQConfig .builder ().enabled (true ).build ())
129- .build ();
134+ VectorIndexConfig vectorIndexConfig =
135+ VectorIndexConfig .builder ().sq (SQConfig .builder ().enabled (true ).build ()).build ();
136+ testCreateBatch ("hnsw" , vectorIndexConfig );
137+ }
138+
139+ public void testCreateBatchWithHNSWRQVectorIndex () {
140+ VectorIndexConfig vectorIndexConfig =
141+ VectorIndexConfig .builder ().rq (RQConfig .builder ().enabled (true ).build ()).build ();
130142 testCreateBatch ("hnsw" , vectorIndexConfig );
131143 }
132144
@@ -135,66 +147,62 @@ public void testCreateBatch() {
135147 }
136148
137149 public void testCreateBatchWithNested () {
138- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
150+ WeaviateTestGenerics .AllPropertiesSchema testData =
151+ new WeaviateTestGenerics .AllPropertiesSchema ();
139152 String className = testData .CLASS_NAME ;
140153 List <Property > properties = testData .propertiesWithNestedObject ();
141154 WeaviateObject [] objects = testData .objectsWithNestedObject ();
142155 testCreateBatch (className , properties , objects );
143156 }
144157
145158 public void testCreateBatchWithNestedAndNestArrayObject () {
146- WeaviateTestGenerics .AllPropertiesSchema testData = new WeaviateTestGenerics .AllPropertiesSchema ();
159+ WeaviateTestGenerics .AllPropertiesSchema testData =
160+ new WeaviateTestGenerics .AllPropertiesSchema ();
147161 String className = testData .CLASS_NAME ;
148162 List <Property > properties = testData .propertiesWithNestedObjectAndNestedArrayObject ();
149163 WeaviateObject [] objects = testData .objectsWithNestedObjectAndNestedArrayObject ();
150164 testCreateBatch (className , properties , objects );
151165 }
152166
153- public void testCreateBatch (String className , List <Property > properties , WeaviateObject [] objects ) {
167+ public void testCreateBatch (String className , List <Property > properties ,
168+ WeaviateObject [] objects ) {
154169 testCreateBatch (className , properties , objects , null , null );
155170 }
156171
157- public void testCreateBatch (String className , List <Property > properties , WeaviateObject [] objects ,
158- String vectorIndexType , VectorIndexConfig vectorIndexConfig ) {
172+ public void testCreateBatch (String className , List <Property > properties ,
173+ WeaviateObject [] objects , String vectorIndexType , VectorIndexConfig vectorIndexConfig ) {
159174 // create schema
160- WeaviateClass .WeaviateClassBuilder weaviateClassBuilder = WeaviateClass .builder ()
161- .className (className )
162- .properties (properties );
175+ WeaviateClass .WeaviateClassBuilder weaviateClassBuilder =
176+ WeaviateClass .builder ().className (className ).properties (properties );
163177 if (StringUtils .isNotBlank (vectorIndexType ) && vectorIndexConfig != null ) {
164178 weaviateClassBuilder .vectorIndexType (vectorIndexType ).vectorIndexConfig (vectorIndexConfig );
165179 }
166180 Result <Boolean > createResult = this .createClass .apply (weaviateClassBuilder .build ());
167- assertThat (createResult ).isNotNull ()
168- .returns (false , Result ::hasErrors )
169- .returns (true , Result ::getResult );
181+ assertThat (createResult ).isNotNull ().returns (false , Result ::hasErrors ).returns (true ,
182+ Result ::getResult );
170183
171184 Result <ObjectGetResponse []> result = this .batchCreate .apply (objects );
172- assertThat (result ).isNotNull ()
173- .returns (false , Result ::hasErrors )
174- .extracting (Result ::getResult ).asInstanceOf (ARRAY )
175- .hasSize (objects .length );
185+ assertThat (result ).isNotNull ().returns (false , Result ::hasErrors ).extracting (Result ::getResult )
186+ .asInstanceOf (ARRAY ).hasSize (objects .length );
176187
177188 for (WeaviateObject obj : objects ) {
178189 Result <List <WeaviateObject >> resultObj = fetchObject .apply (obj );
179- assertThat (resultObj ).isNotNull ()
180- .returns (false , Result ::hasErrors )
181- .extracting (Result ::getResult ).isNotNull ()
182- .extracting (r -> r .get (0 )).isNotNull ()
183- .satisfies (o -> {
184- assertThat (o .getId ()).isEqualTo (obj .getId ());
185- assertThat (o .getVector ()).isNotEmpty ();
186- assertThat (o .getProperties ()).isNotNull ()
187- .extracting (Map ::size ).isEqualTo (obj .getProperties ().size ());
188- obj .getProperties ().keySet ().forEach (propName -> {
189- assertThat (o .getProperties ().get (propName )).isNotNull ();
190+ assertThat (resultObj ).isNotNull ().returns (false , Result ::hasErrors )
191+ .extracting (Result ::getResult ).isNotNull ().extracting (r -> r .get (0 )).isNotNull ()
192+ .satisfies (o -> {
193+ assertThat (o .getId ()).isEqualTo (obj .getId ());
194+ assertThat (o .getVector ()).isNotEmpty ();
195+ assertThat (o .getProperties ()).isNotNull ().extracting (Map ::size )
196+ .isEqualTo (obj .getProperties ().size ());
197+ obj .getProperties ().keySet ().forEach (propName -> {
198+ assertThat (o .getProperties ().get (propName )).isNotNull ();
199+ });
190200 });
191- });
192201 }
193202 // clean up
194203 Result <Boolean > delete = this .deleteClass .apply (className );
195- assertThat (delete ).isNotNull ()
196- .returns (false , Result ::hasErrors )
197- .extracting (Result ::getResult ).isEqualTo (Boolean .TRUE );
204+ assertThat (delete ).isNotNull ().returns (false , Result ::hasErrors ).extracting (Result ::getResult )
205+ .isEqualTo (Boolean .TRUE );
198206 }
199207 }
200208}
0 commit comments