|
22 | 22 | import io.weaviate.client.WeaviateAuthClient; |
23 | 23 | import io.weaviate.client.WeaviateClient; |
24 | 24 | import io.weaviate.client.base.Result; |
| 25 | +import io.weaviate.client.v1.aliases.model.Alias; |
25 | 26 | import io.weaviate.client.v1.async.WeaviateAsyncClient; |
26 | 27 | import io.weaviate.client.v1.async.backup.api.BackupCanceler; |
27 | 28 | import io.weaviate.client.v1.async.backup.api.BackupCreateStatusGetter; |
@@ -549,6 +550,57 @@ public void shouldRestoreWithRbacOptions() { |
549 | 550 | } |
550 | 551 | } |
551 | 552 |
|
| 553 | + @Test |
| 554 | + public void testOverwriteAlias_true() throws InterruptedException, ExecutionException, Exception { |
| 555 | + String originalClass = "CollectionOverwriteAlias"; |
| 556 | + String alias = originalClass + "Alias"; |
| 557 | + String differentClass = "Different" + originalClass; |
| 558 | + |
| 559 | + try (final WeaviateAsyncClient async = client.async()) { |
| 560 | + Runnable arrange = runnable(() -> { |
| 561 | + Result<?> res; |
| 562 | + |
| 563 | + res = async.schema().classCreator() |
| 564 | + .withClass(WeaviateClass.builder().className(originalClass).build()) |
| 565 | + .run().get(); |
| 566 | + Assertions.assertThat(res.getError()).isNull(); |
| 567 | + res = async.alias().creator().withClassName(originalClass).withAlias(alias).run().get(); |
| 568 | + Assertions.assertThat(res.getError()).isNull(); |
| 569 | + |
| 570 | + res = async.backup().creator() |
| 571 | + .withBackupId(backupId) |
| 572 | + .withBackend(BackupTestSuite.BACKEND) |
| 573 | + .withIncludeClassNames(originalClass) |
| 574 | + .withWaitForCompletion(true) |
| 575 | + .run().get(); |
| 576 | + Assertions.assertThat(res.getError()).isNull(); |
| 577 | + |
| 578 | + res = async.schema().classDeleter().withClassName(originalClass).run().get(); |
| 579 | + Assertions.assertThat(res.getError()).isNull(); |
| 580 | + res = async.schema().classCreator() |
| 581 | + .withClass(WeaviateClass.builder().className(differentClass).build()) |
| 582 | + .run().get(); |
| 583 | + Assertions.assertThat(res.getError()).isNull(); |
| 584 | + res = async.alias().updater().withAlias(alias).withNewClassName(differentClass).run().get(); |
| 585 | + Assertions.assertThat(res.getError()).isNull(); |
| 586 | + |
| 587 | + return null; // satisfy Callable |
| 588 | + }); |
| 589 | + |
| 590 | + Callable<Result<?>> act = () -> async.backup().restorer() |
| 591 | + .withBackupId(backupId) |
| 592 | + .withBackend(BackupTestSuite.BACKEND) |
| 593 | + .withIncludeClassNames(originalClass) |
| 594 | + .withWaitForCompletion(true) |
| 595 | + .withOverwriteAlias(true) |
| 596 | + .run().get(); |
| 597 | + |
| 598 | + Supplier<Alias> getAlias = supplier(() -> async.alias().getter().withAlias(alias).run().get().getResult()); |
| 599 | + |
| 600 | + BackupTestSuite.testOverwriteAlias_true(arrange, act, getAlias, originalClass); |
| 601 | + } |
| 602 | + } |
| 603 | + |
552 | 604 | @FunctionalInterface |
553 | 605 | interface ThrowingSupplier<T> { |
554 | 606 | T get() throws Exception; |
|
0 commit comments