|
28 | 28 | import java.util.List;
|
29 | 29 | import java.util.Map;
|
30 | 30 |
|
| 31 | +import org.junit.Assert; |
31 | 32 | import org.junit.Before;
|
32 | 33 | import org.junit.Test;
|
33 | 34 |
|
34 | 35 | import com.arangodb.entity.BaseDocument;
|
35 | 36 | import com.arangodb.entity.CollectionOptions;
|
36 | 37 | import com.arangodb.entity.CollectionType;
|
37 | 38 | import com.arangodb.entity.ImportResultEntity;
|
| 39 | +import com.arangodb.entity.IndexEntity; |
| 40 | +import com.arangodb.entity.IndexType; |
38 | 41 | import com.arangodb.util.ImportOptions;
|
39 | 42 | import com.arangodb.util.ImportOptions.OnDuplicate;
|
40 | 43 | import com.arangodb.util.ImportOptionsJson;
|
@@ -342,6 +345,28 @@ public void test_import_from_to_Prefix_with_errors_details() throws ArangoExcept
|
342 | 345 | }
|
343 | 346 | }
|
344 | 347 |
|
| 348 | + @Test |
| 349 | + public void test_import_index_with_errors_details() throws ArangoException { |
| 350 | + final IndexEntity index = driver.createIndex(UT_IMPORT_TEST, IndexType.HASH, true, "pk_id"); |
| 351 | + Assert.assertFalse(index.isError()); |
| 352 | + |
| 353 | + Collection<BaseDocument> docs = new ArrayList<BaseDocument>(); |
| 354 | + for (int i = 0; i < 2; i++) { |
| 355 | + BaseDocument doc = new BaseDocument(); |
| 356 | + doc.addAttribute("pk_id", "test"); |
| 357 | + docs.add(doc); |
| 358 | + } |
| 359 | + ImportOptionsJson importOptions = new ImportOptionsJson(); |
| 360 | + importOptions.setDetails(true); |
| 361 | + final ImportResultEntity result = driver.importDocuments(UT_IMPORT_TEST, docs, importOptions); |
| 362 | + Assert.assertFalse(result.isError()); |
| 363 | + Assert.assertEquals(1, result.getCreated()); |
| 364 | + Assert.assertEquals(1, result.getErrors()); |
| 365 | + Assert.assertEquals(1, result.getDetails().size()); |
| 366 | + String expectedErrorDetail = "at position 1: creating document failed with error 'unique constraint violated'"; |
| 367 | + Assert.assertTrue(result.getDetails().get(0).startsWith(expectedErrorDetail)); |
| 368 | + } |
| 369 | + |
345 | 370 | @Test
|
346 | 371 | public void test_import_rawList() throws ArangoException {
|
347 | 372 | String values = "[{\"_key\":\"a\"},{\"_key\":\"b\"}]";
|
|
0 commit comments