Location location = new Location(new Namespace(mapBucketType, bucketName), key);
BinaryValue setValue = BinaryValue.create("value");
BinaryValue mapKey = BinaryValue.create("set");
DtUpdateOperation update =
new DtUpdateOperation.Builder(location)
.withOp(new MapOp().update(mapKey, new SetOp().add(setValue)))
.build();
cluster.execute(update);
update.get();
map = fetchMap(mapBucketType, bucketName, key);
assertEquals(1, map.view().size());
assertNotNull(map.view().get(mapKey));
assertEquals(1, map.view().get(mapKey).size());
assertTrue(map.view().get(mapKey).get(0).isSet());
RiakSet set = map.view().get(mapKey).get(0).getAsSet();
assertTrue(set.view().contains(setValue));
mapKey = BinaryValue.create("counter");
update = new DtUpdateOperation.Builder(location)
.withOp(new MapOp().update(mapKey, new CounterOp(1)))
.build();
cluster.execute(update);
update.get();
map = fetchMap(mapBucketType, bucketName, key);
assertEquals(2, map.view().size());
assertNotNull(map.view().get(mapKey));
assertEquals(1, map.view().get(mapKey).size());
assertTrue(map.view().get(mapKey).get(0).isCounter());
RiakCounter counter = map.view().get(mapKey).get(0).getAsCounter();
assertEquals((Long) 1L, counter.view());
mapKey = BinaryValue.create("flag");
update =
new DtUpdateOperation.Builder(location)
.withOp(new MapOp().update(mapKey, new FlagOp(true)))
.build();
cluster.execute(update);
update.get();
map = fetchMap(mapBucketType, bucketName, key);
assertEquals(3, map.view().size());
assertNotNull(map.view().get(mapKey));
assertEquals(1, map.view().get(mapKey).size());
assertTrue(map.view().get(mapKey).get(0).isFlag());
RiakFlag flag = map.view().get(mapKey).get(0).getAsFlag();
assertTrue(flag.getEnabled());
mapKey = BinaryValue.create("register");
update = new DtUpdateOperation.Builder(location)
.withOp(new MapOp().update(mapKey, new RegisterOp(mapKey)))
.build();
cluster.execute(update);
update.get();
map = fetchMap(mapBucketType, bucketName, key);
assertEquals(4, map.view().size());
assertNotNull(map.view().get(mapKey));
assertEquals(1, map.view().get(mapKey).size());
RiakRegister register = map.view().get(mapKey).get(0).getAsRegister();
assertEquals(mapKey, register.getValue());
mapKey = BinaryValue.create("map");
update = new DtUpdateOperation.Builder(location)
.withOp(new MapOp().update(mapKey, new MapOp().update(mapKey, new FlagOp(false))))
.build();
cluster.execute(update);
update.get();
map = fetchMap(mapBucketType, bucketName, key);
Map<BinaryValue, List<RiakDatatype>> mapView = map.view();
assertEquals(5, mapView.size());