Java Code Examples for com.arangodb.entity.BaseDocument#updateAttribute()
The following examples show how to use
com.arangodb.entity.BaseDocument#updateAttribute() .
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: ArangoVertexCollectionTest.java From arangodb-java-driver-async 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 2
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 3
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 4
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 6 votes |
@Test public void updateVertexIfMatchFail() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); doc.addAttribute("c", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.updateAttribute("a", "test1"); doc.addAttribute("b", "test"); doc.updateAttribute("c", null); try { final VertexUpdateOptions options = new VertexUpdateOptions().ifMatch("no"); vertices.updateVertex(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 5
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 6
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 7
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 8
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 9
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 10
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void updateVertex() 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); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, null).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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }
Example 11
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver-async with Apache License 2.0 | 5 votes |
@Test public void updateVertexIfMatch() 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); final VertexUpdateOptions options = new VertexUpdateOptions().ifMatch(createResult.getRev()); 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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }
Example 12
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void updateVertex() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); doc.addAttribute("c", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.updateAttribute("a", "test1"); doc.addAttribute("b", "test"); doc.updateAttribute("c", null); final VertexUpdateEntity updateResult = vertices .updateVertex(createResult.getKey(), doc, null); 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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }
Example 13
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void updateVertexIfMatch() { final BaseDocument doc = new BaseDocument(); doc.addAttribute("a", "test"); doc.addAttribute("c", "test"); final VertexEntity createResult = vertices .insertVertex(doc, null); doc.updateAttribute("a", "test1"); doc.addAttribute("b", "test"); doc.updateAttribute("c", null); final VertexUpdateOptions options = new VertexUpdateOptions().ifMatch(createResult.getRev()); 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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }
Example 14
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void updateVertex() 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); final VertexUpdateEntity updateResult = db.graph(GRAPH_NAME).vertexCollection(COLLECTION_NAME) .updateVertex(createResult.getKey(), doc, null).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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }
Example 15
Source File: ArangoVertexCollectionTest.java From arangodb-java-driver with Apache License 2.0 | 5 votes |
@Test public void updateVertexIfMatch() 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); final VertexUpdateOptions options = new VertexUpdateOptions().ifMatch(createResult.getRev()); 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.getAttribute("a"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("a")), is("test1")); assertThat(readResult.getAttribute("b"), is(notNullValue())); assertThat(String.valueOf(readResult.getAttribute("b")), is("test")); assertThat(readResult.getRevision(), is(updateResult.getRev())); assertThat(readResult.getProperties().keySet(), hasItem("c")); }