diff --git a/notes.txt b/notes.txt
new file mode 100644
index 000000000..6052af898
--- /dev/null
+++ b/notes.txt
@@ -0,0 +1,16 @@
+mvn clean
+mvn -Pjar-with-dependencies assembly:single
+
+mvn -Pitest,default -Dcom.basho.riak.host=192.168.33.11 -Dcom.basho.riak.pbcport=8087 verify
+mvn -Pitest -Dcom.basho.riak.host=192.168.33.11 -Dcom.basho.riak.pbcport=8087 verify
+mvn -Pdefault -Dcom.basho.riak.host=192.168.33.11 -Dcom.basho.riak.pbcport=8087 verify
+
+mvn -Pitest,default -Dcom.basho.riak.host=192.168.33.11 -Dcom.basho.riak.pbcport=8087 -DskipTests verify
+
+
+
+
+
+
+sudo riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
+sudo riak-admin bucket-type create plain ''
diff --git a/pom.xml b/pom.xml
index 74d39e7c4..a8a30d6e3 100755
--- a/pom.xml
+++ b/pom.xml
@@ -205,6 +205,7 @@
maven-javadoc-plugin
-Xdoclint:none
+ --allow-script-in-comments
com.basho.riak.protobuf.util
@@ -369,7 +370,7 @@
org.codehaus.mojo
animal-sniffer-maven-plugin
- 1.15
+ 1.20
org.codehaus.mojo.signature
@@ -469,5 +470,10 @@
commons-codec
1.10
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
diff --git a/src/main/java/com/basho/riak/client/api/commands/datatypes/SetUpdate.java b/src/main/java/com/basho/riak/client/api/commands/datatypes/SetUpdate.java
index 5fc064ed2..6357e35c6 100644
--- a/src/main/java/com/basho/riak/client/api/commands/datatypes/SetUpdate.java
+++ b/src/main/java/com/basho/riak/client/api/commands/datatypes/SetUpdate.java
@@ -42,6 +42,20 @@ public SetUpdate()
{
}
+ @Override
+ public SetUpdate add(BinaryValue value)
+ {
+ super.add(value);
+ return this;
+ }
+
+ @Override
+ public SetUpdate add(String value)
+ {
+ super.add(value);
+ return this;
+ }
+
/**
* Remove the provided value from the set in Riak.
* @param value the value to be removed.
diff --git a/src/test/java/com/basho/riak/client/api/commands/itest/ITestDatatype.java b/src/test/java/com/basho/riak/client/api/commands/itest/ITestDatatype.java
index 2b887da0f..83f9d92bf 100644
--- a/src/test/java/com/basho/riak/client/api/commands/itest/ITestDatatype.java
+++ b/src/test/java/com/basho/riak/client/api/commands/itest/ITestDatatype.java
@@ -12,10 +12,7 @@
import org.junit.Test;
import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ExecutionException;
import static org.junit.Assert.*;
@@ -32,7 +29,8 @@ public class ITestDatatype extends ITestAutoCleanupBase
private final Namespace carts = new Namespace(mapBucketType, bucketName);
private final Namespace uniqueUsersCount = new Namespace(hllBucketType, BinaryValue.create("uniqueUsersCount"));
- private final Namespace uniqueUsers = new Namespace(gsetBucketType, BinaryValue.create("uniqueUsers"));
+ private final Namespace uniqueUsersSet = new Namespace(setBucketType, BinaryValue.create("uniqueUsersSet"));
+ private final Namespace uniqueUsersGSet = new Namespace(gsetBucketType, BinaryValue.create("uniqueUsersGSet"));
private final RiakClient client = new RiakClient(cluster);
@@ -192,10 +190,11 @@ public void testNotFoundHyperLogLog() throws ExecutionException, InterruptedExce
}
@Test
- public void testGSet() throws ExecutionException , InterruptedException
- {
- Assume.assumeTrue(testGSetDataType);
- final Location location = new Location(uniqueUsers, "site-2017-01-01-" + new Random().nextLong());
+ public void testSet() throws ExecutionException, InterruptedException {
+ Assume.assumeTrue(testSetDataType);
+ resetAndEmptyBucket(uniqueUsersSet);
+
+ final Location location = new Location(uniqueUsersSet, "users-" + new Random().nextLong());
FetchSet fetchSet = new FetchSet.Builder(location).build();
final FetchSet.Response initialFetchResponse = client.execute(fetchSet);
@@ -203,26 +202,81 @@ public void testGSet() throws ExecutionException , InterruptedException
final RiakSet initialSet = initialFetchResponse.getDatatype();
assertTrue(initialSet.view().isEmpty());
- GSetUpdate gsu = new GSetUpdate().add("user1").add("user2").add("user3");
- UpdateSet us = new UpdateSet.Builder(location, gsu).withReturnDatatype(true).build();
-
- final UpdateSet.Response updateResponse = client.execute(us);
- final Set updatedSet = updateResponse.getDatatype().view();
+ SetUpdate su = new SetUpdate()
+ .add("user1")
+ .add("user2")
+ .add("user3");
+ UpdateSet update = new UpdateSet.Builder(location, su).build();
+ client.execute(update);
+ final FetchSet.Response newItemsResponse = client.execute(fetchSet);
+ Set updatedSet = newItemsResponse.getDatatype().view();
assertFalse(updatedSet.isEmpty());
assertTrue(updatedSet.contains(BinaryValue.create("user1")));
assertTrue(updatedSet.contains(BinaryValue.create("user2")));
assertTrue(updatedSet.contains(BinaryValue.create("user3")));
- assertFalse(updateResponse.hasContext());
+ assertFalse(updatedSet.contains(BinaryValue.create("user4")));
+
+ final FetchSet.Response removeItemResponse = client.execute(fetchSet);
+ Context ctx = removeItemResponse.getContext();
+ SetUpdate suRemoveItem = new SetUpdate().remove("user2");
+ UpdateSet updateRemove = new UpdateSet.Builder(location, suRemoveItem).withContext(ctx).build();
+ client.execute(updateRemove);
+
+ final FetchSet.Response removedResponse = client.execute(fetchSet);
+ Set removedItemSet = removedResponse.getDatatype().view();
+ assertFalse(removedItemSet.isEmpty());
+ assertTrue(removedItemSet.contains(BinaryValue.create("user1")));
+ assertFalse(removedItemSet.contains(BinaryValue.create("user2")));
+ assertTrue(removedItemSet.contains(BinaryValue.create("user3")));
+ assertFalse(removedItemSet.contains(BinaryValue.create("user4")));
+ }
+
+ @Test
+ public void testGSet() throws ExecutionException, InterruptedException {
+ Assume.assumeTrue(testGSetDataType);
+ resetAndEmptyBucket(uniqueUsersGSet);
+
+ final Location location = new Location(uniqueUsersGSet, "users-" + new Random().nextLong());
+
+ FetchSet fetchSet = new FetchSet.Builder(location).build();
+ final FetchSet.Response initialFetchResponse = client.execute(fetchSet);
+
+ final RiakSet initialSet = initialFetchResponse.getDatatype();
+ assertTrue(initialSet.view().isEmpty());
- final FetchSet.Response loadedFetchResponse = client.execute(fetchSet);
+ GSetUpdate gsu = new GSetUpdate()
+ .add("user1")
+ .add("user2")
+ .add("user3");
+ UpdateSet us = new UpdateSet.Builder(location, gsu).build();
+ client.execute(us);
- final Set loadedSet = loadedFetchResponse.getDatatype().view();
+ final FetchSet.Response newItemResponse = client.execute(fetchSet);
+ final Set updatedSet = newItemResponse.getDatatype().view();
+ assertFalse(updatedSet.isEmpty());
+ assertTrue(updatedSet.contains(BinaryValue.create("user1")));
+ assertTrue(updatedSet.contains(BinaryValue.create("user2")));
+ assertTrue(updatedSet.contains(BinaryValue.create("user3")));
+ assertFalse(updatedSet.contains(BinaryValue.create("user4")));
+
+ final FetchSet.Response removeItemResponse = client.execute(fetchSet);
+ Context ctx = removeItemResponse.getContext();
+ try {
+ SetUpdate suRemoveItem = new SetUpdate().remove("user2");
+ UpdateSet updateRemove = new UpdateSet.Builder(location, suRemoveItem).withContext(ctx).build();
+ client.execute(updateRemove);
+ fail("Expected exception was not thrown.");
+ } catch (IllegalArgumentException e) {
+ // We are expecting the error. If the error occurs, the test is good.
+ }
- assertFalse(loadedSet.isEmpty());
- assertTrue(loadedSet.contains(BinaryValue.create("user1")));
- assertTrue(loadedSet.contains(BinaryValue.create("user2")));
- assertTrue(loadedSet.contains(BinaryValue.create("user3")));
- assertFalse(loadedFetchResponse.hasContext());
+ final FetchSet.Response removedResponse = client.execute(fetchSet);
+ Set removedItemSet = removedResponse.getDatatype().view();
+ assertFalse(removedItemSet.isEmpty());
+ assertTrue(removedItemSet.contains(BinaryValue.create("user1")));
+ assertTrue(removedItemSet.contains(BinaryValue.create("user2")));
+ assertTrue(removedItemSet.contains(BinaryValue.create("user3")));
+ assertFalse(removedItemSet.contains(BinaryValue.create("user4")));
}
}
diff --git a/src/test/java/com/basho/riak/client/core/operations/itest/ITestBase.java b/src/test/java/com/basho/riak/client/core/operations/itest/ITestBase.java
index 264216794..95bf66e37 100644
--- a/src/test/java/com/basho/riak/client/core/operations/itest/ITestBase.java
+++ b/src/test/java/com/basho/riak/client/core/operations/itest/ITestBase.java
@@ -62,6 +62,7 @@ public abstract class ITestBase
protected static boolean testBucketType;
protected static boolean testCrdt;
protected static boolean testHllDataType;
+ protected static boolean testSetDataType;
protected static boolean testGSetDataType;
protected static boolean testTimeSeries;
protected static boolean testCoveragePlan;
@@ -193,6 +194,7 @@ public static void setUp()
cluster.start();
testHllDataType = testCrdt && checkExistanceOfBucketType(hllBucketType);
+ testSetDataType = testCrdt && checkExistanceOfBucketType(setBucketType);
testGSetDataType = testCrdt && checkExistanceOfBucketType(gsetBucketType);
}