|
| 1 | +package io.weaviate.integration; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.util.Map; |
| 5 | +import java.util.UUID; |
| 6 | + |
| 7 | +import org.assertj.core.api.Assertions; |
| 8 | +import org.junit.BeforeClass; |
| 9 | +import org.junit.Test; |
| 10 | + |
| 11 | +import io.weaviate.ConcurrentTest; |
| 12 | +import io.weaviate.client6.v1.api.WeaviateClient; |
| 13 | +import io.weaviate.client6.v1.api.collections.Property; |
| 14 | +import io.weaviate.client6.v1.api.collections.WeaviateObject; |
| 15 | +import io.weaviate.containers.Container; |
| 16 | +import io.weaviate.containers.Weaviate; |
| 17 | + |
| 18 | +public class BatchITest extends ConcurrentTest { |
| 19 | + private static final WeaviateClient client = Container.WEAVIATE.getClient(); |
| 20 | + |
| 21 | + @BeforeClass |
| 22 | + public static void __() { |
| 23 | + Weaviate.Version.V136.orSkip(); |
| 24 | + } |
| 25 | + |
| 26 | + @Test |
| 27 | + public void test() throws IOException { |
| 28 | + var nsThings = ns("Things"); |
| 29 | + |
| 30 | + var things = client.collections.create( |
| 31 | + nsThings, |
| 32 | + c -> c.properties(Property.text("letter"))); |
| 33 | + |
| 34 | + // Act |
| 35 | + try (var batch = things.batch.start()) { |
| 36 | + for (int i = 0; i < 10_000; i++) { |
| 37 | + String uuid = UUID.randomUUID().toString(); |
| 38 | + batch.add(WeaviateObject.of(builder -> builder |
| 39 | + .uuid(uuid) |
| 40 | + .properties(Map.of("letter", uuid.substring(0, 1))))); |
| 41 | + } |
| 42 | + } catch (InterruptedException e) { |
| 43 | + } |
| 44 | + |
| 45 | + // Assert |
| 46 | + Assertions.assertThat(things.size()).isEqualTo(10_000); |
| 47 | + } |
| 48 | +} |
0 commit comments