Skip to content

Commit 8e8b977

Browse files
author
Mark
committed
importDocument tests added
1 parent fc35758 commit 8e8b977

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/test/java/com/arangodb/ArangoDriverImportTest.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,43 @@ public void test_import_from_to_Prefix() throws ArangoException, IOException {
305305
}
306306
}
307307

308+
@Test
309+
public void test_import_from_to_Prefix_with_errors_details() throws ArangoException, IOException {
310+
ImportOptionsJson options = new ImportOptionsJson();
311+
{
312+
Collection<BaseDocument> docs = new ArrayList<BaseDocument>();
313+
for (int i = 0; i < 100; i++) {
314+
BaseDocument doc = new BaseDocument();
315+
doc.setDocumentKey(String.valueOf(i));
316+
docs.add(doc);
317+
}
318+
{
319+
final ImportResultEntity result = driver.importDocuments(UT_IMPORT_TEST, docs, options);
320+
assertThat(result.getStatusCode(), is(201));
321+
assertThat(result.isError(), is(false));
322+
assertThat(result.getCreated(), is(docs.size()));
323+
}
324+
}
325+
{
326+
Collection<Map<String, Object>> edgeDocs = new ArrayList<Map<String, Object>>();
327+
for (int i = 0; i < 100; i++) {
328+
final HashMap<String, Object> doc = new HashMap<String, Object>();
329+
doc.put(BaseDocument.KEY, String.valueOf(i));
330+
// doc.put(BaseDocument.FROM, String.valueOf(i));
331+
doc.put(BaseDocument.TO, String.valueOf(i));
332+
edgeDocs.add(doc);
333+
}
334+
options.setFromPrefix(UT_IMPORT_TEST);
335+
options.setToPrefix(UT_IMPORT_TEST);
336+
options.setDetails(true);
337+
final ImportResultEntity result = driver.importDocuments(UT_IMPORT_TEST_EDGE, edgeDocs, options);
338+
assertThat(result.getStatusCode(), is(201));
339+
assertThat(result.isError(), is(false));
340+
assertThat(result.getErrors(), is(edgeDocs.size()));
341+
assertThat(result.getDetails().size(), is(edgeDocs.size()));
342+
}
343+
}
344+
308345
@Test
309346
public void test_import_rawList() throws ArangoException {
310347
String values = "[{\"_key\":\"a\"},{\"_key\":\"b\"}]";

0 commit comments

Comments
 (0)