88
99import io .weaviate .ConcurrentTest ;
1010import io .weaviate .client6 .v1 .api .WeaviateClient ;
11+ import io .weaviate .client6 .v1 .api .collections .CollectionConfig ;
12+ import io .weaviate .client6 .v1 .api .collections .InvertedIndex ;
1113import io .weaviate .client6 .v1 .api .collections .Property ;
14+ import io .weaviate .client6 .v1 .api .collections .Replication ;
1215import io .weaviate .client6 .v1 .api .collections .VectorIndex ;
13- import io .weaviate .client6 .v1 .api .collections .WeaviateCollection ;
1416import io .weaviate .client6 .v1 .api .collections .vectorindex .Hnsw ;
1517import io .weaviate .client6 .v1 .api .collections .vectorizers .NoneVectorizer ;
1618import io .weaviate .containers .Container ;
@@ -29,8 +31,8 @@ public void testCreateGetDelete() throws IOException {
2931 var thingsCollection = client .collections .getConfig (collectionName );
3032
3133 Assertions .assertThat (thingsCollection ).get ()
32- .hasFieldOrPropertyWithValue ("name " , collectionName )
33- .extracting (WeaviateCollection ::vectors , InstanceOfAssertFactories .map (String .class , VectorIndex .class ))
34+ .hasFieldOrPropertyWithValue ("collectionName " , collectionName )
35+ .extracting (CollectionConfig ::vectors , InstanceOfAssertFactories .map (String .class , VectorIndex .class ))
3436 .as ("default vector" ).extractingByKey ("default" )
3537 .satisfies (defaultVector -> {
3638 Assertions .assertThat (defaultVector ).extracting (VectorIndex ::vectorizer )
@@ -61,7 +63,7 @@ public void testCrossReferences() throws IOException {
6163 .as ("after create Things" ).get ()
6264 .satisfies (c -> {
6365 Assertions .assertThat (c .references ())
64- .as ("ownedBy" ).filteredOn (p -> p .name ().equals ("ownedBy" )).first ()
66+ .as ("ownedBy" ).filteredOn (p -> p .propertyName ().equals ("ownedBy" )).first ()
6567 .extracting (p -> p .dataTypes (), InstanceOfAssertFactories .LIST )
6668 .containsOnly (nsOwners );
6769 });
@@ -81,7 +83,7 @@ public void testCrossReferences() throws IOException {
8183 .as ("after add property" ).get ()
8284 .satisfies (c -> {
8385 Assertions .assertThat (c .references ())
84- .as ("soldIn" ).filteredOn (p -> p .name ().equals ("soldIn" )).first ()
86+ .as ("soldIn" ).filteredOn (p -> p .propertyName ().equals ("soldIn" )).first ()
8587 .extracting (p -> p .dataTypes (), InstanceOfAssertFactories .LIST )
8688 .containsOnly (nsOnlineStores , nsMarkets );
8789 });
@@ -105,7 +107,7 @@ public void testListDeleteAll() throws IOException {
105107 var all = client .collections .list ();
106108 Assertions .assertThat (all )
107109 .hasSizeGreaterThanOrEqualTo (3 )
108- .extracting (WeaviateCollection :: name )
110+ .extracting (CollectionConfig :: collectionName )
109111 .contains (nsA , nsB , nsC );
110112
111113 client .collections .deleteAll ();
@@ -114,4 +116,47 @@ public void testListDeleteAll() throws IOException {
114116 Assertions .assertThat (all .isEmpty ());
115117
116118 }
119+
120+ @ Test
121+ public void testUpdateCollection () throws IOException {
122+ var nsBoxes = ns ("Boxes" );
123+ var nsThings = ns ("Things" );
124+
125+ client .collections .create (nsBoxes );
126+
127+ client .collections .create (nsThings ,
128+ collection -> collection
129+ .description ("Things stored in boxes" )
130+ .properties (
131+ Property .text ("name" ),
132+ Property .integer ("width" ,
133+ w -> w .description ("how wide this thing is" )))
134+ .invertedIndex (idx -> idx .cleanupIntervalSeconds (10 ))
135+ .replication (repl -> repl .asyncEnabled (true )));
136+
137+ var things = client .collections .use (nsThings );
138+
139+ // Act
140+ things .config .update (nsThings , collection -> collection
141+ .description ("Things stored on shelves" )
142+ .propertyDescription ("width" , "not height" )
143+ .invertedIndex (idx -> idx .cleanupIntervalSeconds (30 ))
144+ .replication (repl -> repl .asyncEnabled (false )));
145+
146+ // Assert
147+ var updated = things .config .get ();
148+ Assertions .assertThat (updated ).get ()
149+ .returns ("Things stored on shelves" , CollectionConfig ::description )
150+ .satisfies (collection -> {
151+ Assertions .assertThat (collection )
152+ .extracting (CollectionConfig ::properties , InstanceOfAssertFactories .list (Property .class ))
153+ .extracting (Property ::description ).contains ("not height" );
154+
155+ Assertions .assertThat (collection )
156+ .extracting (CollectionConfig ::invertedIndex ).returns (30 , InvertedIndex ::cleanupIntervalSeconds );
157+
158+ Assertions .assertThat (collection )
159+ .extracting (CollectionConfig ::replication ).returns (false , Replication ::asyncEnabled );
160+ });
161+ }
117162}
0 commit comments