Source:
@Test public void store_fetch_modify() { final RiakClient c = new RiakClient(RIAK_URL); final String VALUE1 = "value1"; final String VALUE2 = "value2"; final RiakLink LINK = new RiakLink("bucket", "key", "tag"); final String USERMETA_KEY = "usermeta"; final String USERMETA_VALUE = "value"; final String BUCKET = UUID.randomUUID().toString() + "_store_fetch_modify"; final String KEY = "key"; RiakBucketInfo bucketInfo = new RiakBucketInfo(); bucketInfo.setAllowMult(true); bucketInfo.setNVal(3); assertSuccess(c.setBucketSchema(BUCKET, bucketInfo)); assertSuccess(c.delete(BUCKET, KEY, WRITE_3_REPLICAS())); FetchResponse fetchresp = c.fetch(BUCKET, KEY); assertEquals(404, fetchresp.getStatusCode()); RiakObject o = new RiakObject(BUCKET, KEY, utf8StringToBytes(VALUE1)); StoreResponse storeresp = c.store(o, WRITE_3_REPLICAS()); assertSuccess(storeresp); fetchresp = c.fetch(BUCKET, KEY); assertSuccess(fetchresp); assertTrue(fetchresp.hasObject()); System.out.println(fetchresp.getStatusCode() + " " + fetchresp.getBodyAsString()); assertEquals(VALUE1, fetchresp.getObject().getValue()); assertFalse(fetchresp.getObject().hasLinks()); assertFalse(fetchresp.getObject().hasUsermeta()); o = fetchresp.getObject(); o.setValue(VALUE2); o.addLink(LINK); o.addUsermetaItem(USERMETA_KEY, USERMETA_VALUE); storeresp = c.store(o, WRITE_3_REPLICAS()); assertSuccess(storeresp); fetchresp = c.fetch(BUCKET, KEY); assertSuccess(fetchresp); assertTrue(fetchresp.hasObject()); assertFalse(fetchresp.hasSiblings()); assertEquals(VALUE2, fetchresp.getObject().getValue()); assertEquals(1, fetchresp.getObject().numLinks()); assertTrue(fetchresp.getObject().hasLink(LINK)); assertEquals(USERMETA_VALUE, fetchresp.getObject().getUsermetaItem(USERMETA_KEY)); }

Target:
@Test public void store_fetch_modify() { final RiakClient c = new RiakClient(RIAK_URL); final String VALUE1 = "value1"; final String VALUE2 = "value2"; final RiakLink LINK = new RiakLink("bucket", "key", "tag"); final String USERMETA_KEY = "usermeta"; final String USERMETA_VALUE = "value"; final String BUCKET = UUID.randomUUID().toString() + "_store_fetch_modify"; final String KEY = "key"; RiakBucketInfo bucketInfo = new RiakBucketInfo(); bucketInfo.setAllowMult(true); bucketInfo.setNVal(3); assertSuccess(c.setBucketSchema(BUCKET, bucketInfo)); assertSuccess(c.delete(BUCKET, KEY, WRITE_3_REPLICAS())); FetchResponse fetchresp = c.fetch(BUCKET, KEY); assertEquals(404, fetchresp.getStatusCode()); RiakObject o = new RiakObject(BUCKET, KEY, utf8StringToBytes(VALUE1)); StoreResponse storeresp = c.store(o, WRITE_3_REPLICAS()); assertSuccess(storeresp); fetchresp = c.fetch(BUCKET, KEY); assertSuccess(fetchresp); assertTrue(fetchresp.hasObject()); assertEquals(VALUE1, fetchresp.getObject().getValue()); assertFalse(fetchresp.getObject().hasLinks()); assertFalse(fetchresp.getObject().hasUsermeta()); o = fetchresp.getObject(); o.setValue(VALUE2); o.addLink(LINK); o.addUsermetaItem(USERMETA_KEY, USERMETA_VALUE); storeresp = c.store(o, WRITE_3_REPLICAS()); assertSuccess(storeresp); fetchresp = c.fetch(BUCKET, KEY); assertSuccess(fetchresp); assertTrue(fetchresp.hasObject()); assertFalse(fetchresp.hasSiblings()); assertEquals(VALUE2, fetchresp.getObject().getValue()); assertEquals(1, fetchresp.getObject().numLinks()); assertTrue(fetchresp.getObject().hasLink(LINK)); assertEquals(USERMETA_VALUE, fetchresp.getObject().getUsermetaItem(USERMETA_KEY)); }