|
20 | 20 |
|
21 | 21 | package com.arangodb; |
22 | 22 |
|
| 23 | +import static org.hamcrest.CoreMatchers.notNullValue; |
23 | 24 | import static org.hamcrest.Matchers.anyOf; |
24 | 25 | import static org.hamcrest.Matchers.containsString; |
25 | 26 | import static org.hamcrest.Matchers.empty; |
26 | 27 | import static org.hamcrest.Matchers.hasItem; |
27 | 28 | import static org.hamcrest.Matchers.instanceOf; |
28 | 29 | import static org.hamcrest.Matchers.is; |
29 | 30 | import static org.hamcrest.Matchers.not; |
30 | | -import static org.hamcrest.Matchers.notNullValue; |
31 | 31 | import static org.hamcrest.Matchers.nullValue; |
32 | 32 | import static org.hamcrest.Matchers.startsWith; |
33 | 33 | import static org.junit.Assert.assertThat; |
@@ -733,6 +733,72 @@ public void deleteDocumentIfMatchFail() throws InterruptedException, ExecutionEx |
733 | 733 | } |
734 | 734 | } |
735 | 735 |
|
| 736 | + @Test |
| 737 | + public void getIndex() throws InterruptedException, ExecutionException { |
| 738 | + final Collection<String> fields = new ArrayList<>(); |
| 739 | + fields.add("a"); |
| 740 | + final IndexEntity createResult = db.collection(COLLECTION_NAME).createHashIndex(fields, null).get(); |
| 741 | + final CompletableFuture<IndexEntity> f = db.collection(COLLECTION_NAME).getIndex(createResult.getId()); |
| 742 | + assertThat(f, is(notNullValue())); |
| 743 | + f.whenComplete((readResult, ex) -> { |
| 744 | + assertThat(readResult.getId(), is(createResult.getId())); |
| 745 | + assertThat(readResult.getType(), is(createResult.getType())); |
| 746 | + }); |
| 747 | + f.get(); |
| 748 | + } |
| 749 | + |
| 750 | + @Test |
| 751 | + public void getIndexByKey() throws InterruptedException, ExecutionException { |
| 752 | + final Collection<String> fields = new ArrayList<>(); |
| 753 | + fields.add("a"); |
| 754 | + final IndexEntity createResult = db.collection(COLLECTION_NAME).createHashIndex(fields, null).get(); |
| 755 | + final CompletableFuture<IndexEntity> f = db.collection(COLLECTION_NAME) |
| 756 | + .getIndex(createResult.getId().split("/")[1]); |
| 757 | + assertThat(f, is(notNullValue())); |
| 758 | + f.whenComplete((readResult, ex) -> { |
| 759 | + assertThat(readResult.getId(), is(createResult.getId())); |
| 760 | + assertThat(readResult.getType(), is(createResult.getType())); |
| 761 | + }); |
| 762 | + f.get(); |
| 763 | + } |
| 764 | + |
| 765 | + @Test |
| 766 | + public void deleteIndex() throws InterruptedException, ExecutionException { |
| 767 | + final Collection<String> fields = new ArrayList<>(); |
| 768 | + fields.add("a"); |
| 769 | + final IndexEntity createResult = db.collection(COLLECTION_NAME).createHashIndex(fields, null).get(); |
| 770 | + final CompletableFuture<String> f = db.collection(COLLECTION_NAME).deleteIndex(createResult.getId()); |
| 771 | + assertThat(f, is(notNullValue())); |
| 772 | + f.whenComplete((id, ex) -> { |
| 773 | + assertThat(id, is(createResult.getId())); |
| 774 | + try { |
| 775 | + db.getIndex(id); |
| 776 | + fail(); |
| 777 | + } catch (final ArangoDBException e) { |
| 778 | + } |
| 779 | + }); |
| 780 | + f.get(); |
| 781 | + } |
| 782 | + |
| 783 | + @Test |
| 784 | + public void deleteIndexByKey() throws InterruptedException, ExecutionException { |
| 785 | + final Collection<String> fields = new ArrayList<>(); |
| 786 | + fields.add("a"); |
| 787 | + final IndexEntity createResult = db.collection(COLLECTION_NAME).createHashIndex(fields, null).get(); |
| 788 | + final CompletableFuture<String> f = db.collection(COLLECTION_NAME) |
| 789 | + .deleteIndex(createResult.getId().split("/")[1]); |
| 790 | + assertThat(f, is(notNullValue())); |
| 791 | + f.whenComplete((id, ex) -> { |
| 792 | + assertThat(id, is(createResult.getId())); |
| 793 | + try { |
| 794 | + db.getIndex(id); |
| 795 | + fail(); |
| 796 | + } catch (final ArangoDBException e) { |
| 797 | + } |
| 798 | + }); |
| 799 | + f.get(); |
| 800 | + } |
| 801 | + |
736 | 802 | @Test |
737 | 803 | public void createHashIndex() throws InterruptedException, ExecutionException { |
738 | 804 | final Collection<String> fields = new ArrayList<>(); |
|
0 commit comments