com.arangodb.entity.BaseDocument Java Examples
The following examples show how to use
com.arangodb.entity.BaseDocument.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomSerdeTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlSerialization() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); HashMap<String, Object> params = new HashMap<>(); params.put("doc", doc); params.put("@collection", COLLECTION_NAME); BaseDocument result = db.query( "INSERT @doc INTO @@collection RETURN NEW", params, BaseDocument.class ).get().first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #2
Source File: ArangoEdgeCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
private BaseEdgeDocument createEdgeValue() throws InterruptedException, ExecutionException { final VertexEntity v1 = db.graph(GRAPH_NAME).vertexCollection(VERTEX_COLLECTION_NAME) .insertVertex(new BaseDocument(), null).get(); final VertexEntity v2 = db.graph(GRAPH_NAME).vertexCollection(VERTEX_COLLECTION_NAME) .insertVertex(new BaseDocument(), null).get(); final BaseEdgeDocument value = new BaseEdgeDocument(); value.setFrom(v1.getId()); value.setTo(v2.getId()); return value; }
Example #3
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void duplicateInsertSameObjectVertex() { final ArangoVertexCollection vertexCollection = vertices; // ######################################################### // Create a new BaseDocument // ######################################################### UUID uuid = UUID.randomUUID(); BaseDocument bd = new BaseDocument(); bd.setKey(uuid.toString()); bd.addAttribute("name", "Paul"); vertexCollection.insertVertex(bd); UUID uuid2 = UUID.randomUUID(); BaseDocument bd2 = new BaseDocument(); bd2.setKey(uuid2.toString()); bd2.addAttribute("name", "Paul"); vertexCollection.insertVertex(bd2); }
Example #4
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void replaceVertex() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexUpdateEntity replaceResult = vertices .replaceVertex(createResult.getKey(), doc, null); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = vertices .getVertex(createResult.getKey(), BaseDocument.class, null); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #5
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexIfMatchFail() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); doc.addAttribute("c", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.updateAttribute("a", "test1"); doc.addAttribute("b", "test"); doc.updateAttribute("c", null); try { final VertexUpdateOptions options = new VertexUpdateOptions().ifMatch("no"); db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).updateVertex(createResult.getKey(), doc, options) .get(); fail(); } catch (final ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); } }
Example #6
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void replaceVertexIfMatch() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexReplaceOptions options = new VertexReplaceOptions().ifMatch(createResult.getRev()); final VertexUpdateEntity replaceResult = vertices .replaceVertex(createResult.getKey(), doc, options); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = vertices .getVertex(createResult.getKey(), BaseDocument.class, null); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #7
Source File: CustomSerdeTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlDeserialization() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); collection.insertDocument(doc, null).get(); final BaseDocument result = db.query( "RETURN DOCUMENT(@docId)", Collections.singletonMap("docId", COLLECTION_NAME + "/" + key), BaseDocument.class ).get().first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #8
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void replaceVertexIfMatchFail() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.getProperties().clear(); doc.addAttribute("b", "test"); try { final VertexReplaceOptions options = new VertexReplaceOptions().ifMatch("no"); vertices.replaceVertex(createResult.getKey(), doc, options); fail(); } catch (final ArangoDBException e) { if (isAtLeastVersion(3, 4)) { // FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK // assertThat(e.getResponseCode(), is(412)); assertThat(e.getErrorNum(), is(1200)); } else { assertThat(e.getResponseCode(), is(412)); assertThat(e.getErrorNum(), is(1903)); } } }
Example #9
Source File: CustomSerdeTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void getDocument() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); collection.insertDocument(doc, null).get(); final BaseDocument result = db.collection(COLLECTION_NAME).getDocument( key, BaseDocument.class, null).get(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #10
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void deleteVertexIfMatchFail() { final BaseDocument doc = new BaseDocument(); final VertexEntity createResult = vertices .insertVertex(doc, null); final VertexDeleteOptions options = new VertexDeleteOptions().ifMatch("no"); try { vertices.deleteVertex(createResult.getKey(), options); fail(); } catch (final ArangoDBException e) { if (isAtLeastVersion(3, 4)) { // FIXME: atm the server replies 409 for HTTP_JSON or HTTP_VPACK // assertThat(e.getResponseCode(), is(412)); assertThat(e.getErrorNum(), is(1200)); } else { assertThat(e.getResponseCode(), is(412)); assertThat(e.getErrorNum(), is(1903)); } } }
Example #11
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void replaceVertex() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexUpdateEntity replaceResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .replaceVertex(createResult.getKey(), doc, null).get(); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #12
Source File: CustomSerdeTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlDeserialization() { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); collection.insertDocument(doc, null); final BaseDocument result = db.query( "RETURN DOCUMENT(@docId)", Collections.singletonMap("docId", COLLECTION_NAME + "/" + key), BaseDocument.class ).first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #13
Source File: CustomSerdeTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void aqlSerialization() { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); HashMap<String, Object> params = new HashMap<>(); params.put("doc", doc); params.put("@collection", COLLECTION_NAME); BaseDocument result = db.query( "INSERT @doc INTO @@collection RETURN NEW", params, BaseDocument.class ).first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #14
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void replaceVertexIfMatch() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexReplaceOptions options = new VertexReplaceOptions().ifMatch(createResult.getRev()); final VertexUpdateEntity replaceResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .replaceVertex(createResult.getKey(), doc, options).get(); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #15
Source File: CustomSerdeTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void aqlSerialization() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); HashMap<String, Object> params = new HashMap<>(); params.put("doc", doc); params.put("@collection", COLLECTION_NAME); BaseDocument result = db.query( "INSERT @doc INTO @@collection RETURN NEW", params, BaseDocument.class ).get().first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #16
Source File: CustomSerdeTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void getDocument() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); collection.insertDocument(doc, null).get(); final BaseDocument result = db.collection(COLLECTION_NAME).getDocument( key, BaseDocument.class, null).get(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #17
Source File: UserAuthTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void readDocumentByAql() { try { arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).insertDocument(new BaseDocument("123")); if ((Permissions.RW.equals(param.dbPermission) || Permissions.RO.equals(param.dbPermission)) && (Permissions.RW.equals(param.colPermission) || Permissions.RO.equals(param.colPermission))) { assertThat(details, arangoDB.db(DB_NAME).query("FOR i IN @@col RETURN i", new MapBuilder().put("@col", COLLECTION_NAME).get(), new AqlQueryOptions(), BaseDocument.class) .asListRemaining().size(), is(1)); } else { assertThat(details, arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class), is(nullValue())); } } finally { try { arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).deleteDocument("123"); } catch (final ArangoDBException e) { } } }
Example #18
Source File: UserAuthTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void readDocumentByKey() { try { arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).insertDocument(new BaseDocument("123")); if ((Permissions.RW.equals(param.dbPermission) || Permissions.RO.equals(param.dbPermission)) && (Permissions.RW.equals(param.colPermission) || Permissions.RO.equals(param.colPermission))) { assertThat(details, arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class), is(notNullValue())); } else { assertThat(details, arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class), is(nullValue())); } } finally { try { arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).deleteDocument("123"); } catch (final ArangoDBException e) { } } }
Example #19
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void replaceVertex() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexUpdateEntity replaceResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .replaceVertex(createResult.getKey(), doc, null).get(); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #20
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void replaceVertexIfMatch() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.getProperties().clear(); doc.addAttribute("b", "test"); final VertexReplaceOptions options = new VertexReplaceOptions().ifMatch(createResult.getRev()); final VertexUpdateEntity replaceResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .replaceVertex(createResult.getKey(), doc, options).get(); assertThat(replaceResult, is(notNullValue())); assertThat(replaceResult.getId(), is(createResult.getId())); assertThat(replaceResult.getRev(), is(not(replaceResult.getOldRev()))); assertThat(replaceResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getRevision(), is(replaceResult.getRev())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); }
Example #21
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void replaceVertexIfMatchFail() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.getProperties().clear(); doc.addAttribute("b", "test"); try { final VertexReplaceOptions options = new VertexReplaceOptions().ifMatch("no"); db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).replaceVertex(createResult.getKey(), doc, options) .get(); fail(); } catch (final ExecutionException e) { assertThat(e.getCause(), instanceOf(ArangoDBException.class)); } }
Example #22
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullFalse() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(false); final VertexUpdateEntity updateResult = vertices .updateVertex(createResult.getKey(), doc, options); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = vertices .getVertex(createResult.getKey(), BaseDocument.class, null); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getId(), is(createResult.getId())); assertThat(readResult.getRevision(), is(notNullValue())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); }
Example #23
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullTrue() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(true); final VertexUpdateEntity updateResult = vertices .updateVertex(createResult.getKey(), doc, options); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = vertices .getVertex(createResult.getKey(), BaseDocument.class, null); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getProperties().keySet().size(), is(1)); assertThat(readResult.getProperties().keySet(), hasItem("a")); }
Example #24
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullTrue() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(true); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, options).get(); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getProperties().keySet().size(), is(1)); assertThat(readResult.getProperties().keySet(), hasItem("a")); }
Example #25
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullFalse() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(false); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, options).get(); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getId(), is(createResult.getId())); assertThat(readResult.getRevision(), is(notNullValue())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); }
Example #26
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullFalse() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(false); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, options).get(); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getId(), is(createResult.getId())); assertThat(readResult.getRevision(), is(notNullValue())); assertThat(readResult.getProperties().keySet(), not(hasItem("a"))); }
Example #27
Source File: DocumentCacheTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void setValues() { final DocumentCache cache = new DocumentCache(); final BaseDocument doc = new BaseDocument(); assertThat(doc.getId(), is(nullValue())); assertThat(doc.getKey(), is(nullValue())); assertThat(doc.getRevision(), is(nullValue())); final Map<DocumentField.Type, String> values = new HashMap<>(); values.put(DocumentField.Type.ID, "testId"); values.put(DocumentField.Type.KEY, "testKey"); values.put(DocumentField.Type.REV, "testRev"); cache.setValues(doc, values); assertThat(doc.getId(), is("testId")); assertThat(doc.getKey(), is("testKey")); assertThat(doc.getRevision(), is("testRev")); }
Example #28
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexKeepNullTrue() throws InterruptedException, ExecutionException { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); final VertexEntity createResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME).insertVertex(doc, null) .get(); doc.updateAttribute("a", null); final VertexUpdateOptions options = new VertexUpdateOptions().keepNull(true); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, options).get(); assertThat(updateResult, is(notNullValue())); assertThat(updateResult.getId(), is(createResult.getId())); assertThat(updateResult.getRev(), is(not(updateResult.getOldRev()))); assertThat(updateResult.getOldRev(), is(createResult.getRev())); final BaseDocument readResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .getVertex(createResult.getKey(), BaseDocument.class, null).get(); assertThat(readResult.getKey(), is(createResult.getKey())); assertThat(readResult.getProperties().keySet().size(), is(1)); assertThat(readResult.getProperties().keySet(), hasItem("a")); }
Example #29
Source File: CustomSerdeTest.java From arangodb-java-driver-async with Apache License 2.0 | 6 votes |
@Test public void aqlDeserialization() throws ExecutionException, InterruptedException { String key = "test-" + UUID.randomUUID().toString(); BaseDocument doc = new BaseDocument(key); doc.addAttribute("arr", Collections.singletonList("hello")); doc.addAttribute("int", 10); collection.insertDocument(doc, null).get(); final BaseDocument result = db.query( "RETURN DOCUMENT(@docId)", Collections.singletonMap("docId", COLLECTION_NAME + "/" + key), BaseDocument.class ).get().first(); assertThat(result.getAttribute("arr"), instanceOf(String.class)); assertThat(result.getAttribute("arr"), is("hello")); assertThat(result.getAttribute("int"), instanceOf(BigInteger.class)); assertThat(result.getAttribute("int"), is(BigInteger.valueOf(10))); }
Example #30
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void insertVertex() { final VertexEntity vertex = vertices .insertVertex(new BaseDocument(), null); assertThat(vertex, is(notNullValue())); final BaseDocument document = collection .getDocument(vertex.getKey(), BaseDocument.class, null); assertThat(document, is(notNullValue())); assertThat(document.getKey(), is(vertex.getKey())); }