|
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; |
@@ -123,6 +124,75 @@ public void createCollection() throws InterruptedException, ExecutionException { |
123 | 124 | } |
124 | 125 | } |
125 | 126 |
|
| 127 | + @Test |
| 128 | + public void createCollectionWithReplicationFactor() throws InterruptedException, ExecutionException { |
| 129 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 130 | + return; |
| 131 | + } |
| 132 | + try { |
| 133 | + final CollectionEntity result = db |
| 134 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().replicationFactor(2)).get(); |
| 135 | + assertThat(result, is(notNullValue())); |
| 136 | + assertThat(result.getId(), is(notNullValue())); |
| 137 | + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getReplicationFactor(), is(2)); |
| 138 | + } finally { |
| 139 | + db.collection(COLLECTION_NAME).drop(); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + @Test |
| 144 | + public void createCollectionWithNumberOfShards() throws InterruptedException, ExecutionException { |
| 145 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 146 | + return; |
| 147 | + } |
| 148 | + try { |
| 149 | + final CollectionEntity result = db |
| 150 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2)).get(); |
| 151 | + assertThat(result, is(notNullValue())); |
| 152 | + assertThat(result.getId(), is(notNullValue())); |
| 153 | + assertThat(db.collection(COLLECTION_NAME).getProperties().get().getNumberOfShards(), is(2)); |
| 154 | + } finally { |
| 155 | + db.collection(COLLECTION_NAME).drop(); |
| 156 | + } |
| 157 | + } |
| 158 | + |
| 159 | + @Test |
| 160 | + public void createCollectionWithNumberOfShardsAndShardKey() throws InterruptedException, ExecutionException { |
| 161 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 162 | + return; |
| 163 | + } |
| 164 | + try { |
| 165 | + final CollectionEntity result = db |
| 166 | + .createCollection(COLLECTION_NAME, new CollectionCreateOptions().numberOfShards(2).shardKeys("a")) |
| 167 | + .get(); |
| 168 | + assertThat(result, is(notNullValue())); |
| 169 | + assertThat(result.getId(), is(notNullValue())); |
| 170 | + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); |
| 171 | + assertThat(properties.getNumberOfShards(), is(2)); |
| 172 | + assertThat(properties.getShardKeys().size(), is(1)); |
| 173 | + } finally { |
| 174 | + db.collection(COLLECTION_NAME).drop(); |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + @Test |
| 179 | + public void createCollectionWithNumberOfShardsAndShardKeys() throws InterruptedException, ExecutionException { |
| 180 | + if (arangoDB.getRole().get() == ServerRole.SINGLE) { |
| 181 | + return; |
| 182 | + } |
| 183 | + try { |
| 184 | + final CollectionEntity result = db.createCollection(COLLECTION_NAME, |
| 185 | + new CollectionCreateOptions().numberOfShards(2).shardKeys("a", "b")).get(); |
| 186 | + assertThat(result, is(notNullValue())); |
| 187 | + assertThat(result.getId(), is(notNullValue())); |
| 188 | + final CollectionPropertiesEntity properties = db.collection(COLLECTION_NAME).getProperties().get(); |
| 189 | + assertThat(properties.getNumberOfShards(), is(2)); |
| 190 | + assertThat(properties.getShardKeys().size(), is(2)); |
| 191 | + } finally { |
| 192 | + db.collection(COLLECTION_NAME).drop(); |
| 193 | + } |
| 194 | + } |
| 195 | + |
126 | 196 | @Test |
127 | 197 | public void deleteCollection() throws InterruptedException, ExecutionException { |
128 | 198 | db.createCollection(COLLECTION_NAME, null).get(); |
|
0 commit comments