|
53 | 53 | import com.arangodb.entity.BaseDocument; |
54 | 54 | import com.arangodb.entity.BaseEdgeDocument; |
55 | 55 | import com.arangodb.entity.CollectionEntity; |
| 56 | +import com.arangodb.entity.CollectionPropertiesEntity; |
56 | 57 | import com.arangodb.entity.CollectionType; |
57 | 58 | import com.arangodb.entity.DatabaseEntity; |
58 | 59 | import com.arangodb.entity.GraphEntity; |
|
62 | 63 | import com.arangodb.entity.QueryCachePropertiesEntity.CacheMode; |
63 | 64 | import com.arangodb.entity.QueryEntity; |
64 | 65 | import com.arangodb.entity.QueryTrackingPropertiesEntity; |
| 66 | +import com.arangodb.entity.ServerRole; |
65 | 67 | import com.arangodb.entity.TraversalEntity; |
66 | 68 | import com.arangodb.model.AqlFunctionDeleteOptions; |
67 | 69 | import com.arangodb.model.AqlQueryOptions; |
@@ -116,6 +118,75 @@ public void createCollection() throws InterruptedException, ExecutionException { |
116 | 118 | } |
117 | 119 | } |
118 | 120 |
|
| 121 | + @Test |
| 122 | + public void createCollectionWithReplicationFactor() throws InterruptedException, ExecutionException { |
| 123 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 124 | + return; |
| 125 | + } |
| 126 | + try { |
| 127 | + final CollectionEntity result = db |
| 128 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2)).get(); |
| 129 | + assertThat(result, is(notNullValue())); |
| 130 | + assertThat(result.getId(), is(notNullValue())); |
| 131 | + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor(), is(2)); |
| 132 | + } finally { |
| 133 | + db.collection(COLLECTION_NAME).drop(); |
| 134 | + } |
| 135 | + } |
| 136 | + |
| 137 | + @Test |
| 138 | + public void createCollectionWithNumberOfShards() throws InterruptedException, ExecutionException { |
| 139 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 140 | + return; |
| 141 | + } |
| 142 | + try { |
| 143 | + final CollectionEntity result = db |
| 144 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2)).get(); |
| 145 | + assertThat(result, is(notNullValue())); |
| 146 | + assertThat(result.getId(), is(notNullValue())); |
| 147 | + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getNumberOfShards(), is(2)); |
| 148 | + } finally { |
| 149 | + db.collection(COLLECTION_NAME).drop(); |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + @Test |
| 154 | + public void createCollectionWithNumberOfShardsAndShardKey() throws InterruptedException, ExecutionException { |
| 155 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 156 | + return; |
| 157 | + } |
| 158 | + try { |
| 159 | + final CollectionEntity result = db |
| 160 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2).shardKeys("a")) |
| 161 | + .get(); |
| 162 | + assertThat(result, is(notNullValue())); |
| 163 | + assertThat(result.getId(), is(notNullValue())); |
| 164 | + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); |
| 165 | + assertThat(properties.getNumberOfShards(), is(2)); |
| 166 | + assertThat(properties.getShardKeys().size(), is(1)); |
| 167 | + } finally { |
| 168 | + db.collection(COLLECTION_NAME).drop(); |
| 169 | + } |
| 170 | + } |
| 171 | + |
| 172 | + @Test |
| 173 | + public void createCollectionWithNumberOfShardsAndShardKeys() throws InterruptedException, ExecutionException { |
| 174 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 175 | + return; |
| 176 | + } |
| 177 | + try { |
| 178 | + final CollectionEntity result = db.createCollection(COLLECTION_NAME, |
| 179 | + new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b")).get(); |
| 180 | + assertThat(result, is(notNullValue())); |
| 181 | + assertThat(result.getId(), is(notNullValue())); |
| 182 | + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); |
| 183 | + assertThat(properties.getNumberOfShards(), is(2)); |
| 184 | + assertThat(properties.getShardKeys().size(), is(2)); |
| 185 | + } finally { |
| 186 | + db.collection(COLLECTION_NAME).drop(); |
| 187 | + } |
| 188 | + } |
| 189 | + |
119 | 190 | @Test |
120 | 191 | public void deleteCollection() throws InterruptedException, ExecutionException { |
121 | 192 | db.createCollection(COLLECTION_NAME, null).get(); |
|
0 commit comments