ringles commented on code in PR #7558:
URL: https://github.com/apache/geode/pull/7558#discussion_r847422141


##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/AddByteArraysDeltaUnitTest.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.ADD_BYTE_ARRAYS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisList;
+import org.apache.geode.redis.internal.data.RedisSet;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class AddByteArraysDeltaUnitTest extends AbstractRedisDeltaUnitTest {
+  @Test
+  public void testAddByteArraysDelta_forRedisList() throws Exception {
+    RedisList redisList = makeRedisList();
+    DataInputStream dis = getDataInputStream(redisList.getVersion() + 1);
+
+    redisList.fromDelta(dis);
+
+    assertThat(redisList.llen()).isEqualTo(5);
+    assertThat(redisList.lindex(0)).isEqualTo("firstNew".getBytes());
+    assertThat(redisList.lindex(1)).isEqualTo("secondNew".getBytes());
+    assertThat(redisList.lindex(2)).isEqualTo("zero".getBytes());

Review Comment:
   Versioned.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/SetTimestampDeltaUnitTest.java:
##########
@@ -23,18 +23,19 @@
 import java.io.DataOutputStream;
 
 import org.junit.Test;
+import org.junit.runner.RunWith;
 
-import org.apache.geode.redis.internal.data.delta.ReplaceByteArrayAtOffset;
-
-public class DeltaClassesJUnitTest {
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
 
+@RunWith(GeodeParamsRunner.class)

Review Comment:
   Cleared.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/SetByteArrayAndTimestampDeltaUnitTest.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.SET_BYTE_ARRAY_AND_TIMESTAMP;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class SetByteArrayAndTimestampDeltaUnitTest extends 
AbstractRedisDeltaUnitTest {
+  private final String payload = "something amazing I guess";
+
+  @Test
+  public void testSetByteArrayAndTimestampDelta() throws Exception {
+    DataInputStream dis = getDataInputStream();
+    String original = "0123456789";
+    RedisString redisString = new RedisString(original.getBytes());
+
+    redisString.fromDelta(dis);
+
+    assertThat(new String(redisString.get())).isEqualTo(payload);
+    assertThat(redisString.getExpirationTimestamp()).isEqualTo(2);

Review Comment:
   Done.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/ReplaceByteArrayDoublePairsDeltaUnitTest.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.REPLACE_BYTE_ARRAY_DOUBLE_PAIRS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisSortedSet;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class ReplaceByteArrayDoublePairsDeltaUnitTest extends 
AbstractRedisDeltaUnitTest {
+  private final byte[] deltaBytes = "delta".getBytes();
+
+  @Test
+  public void testReplaceByteArrayDoublePairsDelta() throws Exception {
+    DataInputStream dis = getDataInputStream();
+    RedisSortedSet redisSortedSet = makeRedisSortedSet();
+
+    redisSortedSet.fromDelta(dis);
+
+    assertThat(redisSortedSet.zcard()).isEqualTo(1);
+    assertThat(redisSortedSet.zrank(deltaBytes)).isEqualTo(0L);

Review Comment:
   Done.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/ReplaceByteArrayAtOffsetDeltaUnitTest.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.REPLACE_BYTE_ARRAY_AT_OFFSET;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisList;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class ReplaceByteArrayAtOffsetDeltaUnitTest extends 
AbstractRedisDeltaUnitTest {
+  private final String payload = "something amazing I guess";
+
+  @Test
+  public void testReplaceByteArrayAtOffsetDeltaForRedisString() throws 
Exception {
+    DataInputStream dis = getDataInputStream(3);
+    String original = "0123456789";
+    RedisString redisString = new RedisString(original.getBytes());
+
+    redisString.fromDelta(dis);
+
+    assertThat(new String(redisString.get())).isEqualTo(original.substring(0, 
3) + payload);

Review Comment:
   Updated with distinctions between small and large payloads.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/RemoveByteArraysDeltaUnitTest.java:
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.REMOVE_BYTE_ARRAYS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisHash;
+import org.apache.geode.redis.internal.data.RedisSet;
+import org.apache.geode.redis.internal.data.RedisSortedSet;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class RemoveByteArraysDeltaUnitTest extends AbstractRedisDeltaUnitTest {
+  @Test
+  public void testRemoveByteArraysDeltaForRedisSet() throws Exception {
+    RemoveByteArrays source =
+        new RemoveByteArrays(Arrays.asList("zero".getBytes(), 
"two".getBytes()));
+    DataInputStream dis = getDataInputStream(source);
+    RedisSet redisSet = makeRedisSet();
+
+    redisSet.fromDelta(dis);
+
+    assertThat(redisSet.scard()).isEqualTo(1);
+    assertThat(redisSet.sismember("one".getBytes())).isTrue();
+  }
+
+  @Test
+  public void testRemoveByteArraysDeltaForRedisSortedSet() throws Exception {
+    RemoveByteArrays source =
+        new RemoveByteArrays(Arrays.asList("alpha".getBytes(), 
"gamma".getBytes()));
+    DataInputStream dis = getDataInputStream(source);
+    RedisSortedSet redisSortedSet = makeRedisSortedSet();
+
+    redisSortedSet.fromDelta(dis);
+
+    assertThat(redisSortedSet.zcard()).isEqualTo(1);
+    assertThat(redisSortedSet.zrank("beta".getBytes())).isEqualTo(0L);
+  }
+
+  @Test
+  public void testRemoveByteArraysDeltaForRedisHash() throws Exception {
+    RemoveByteArrays source =
+        new RemoveByteArrays(Collections.singletonList("zero".getBytes()));

Review Comment:
   Expanded.



##########
geode-for-redis/src/test/java/org/apache/geode/redis/internal/data/delta/AddByteArrayPairsDeltaUnitTest.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.redis.internal.data.delta;
+
+import static 
org.apache.geode.redis.internal.data.delta.DeltaType.ADD_BYTE_ARRAY_PAIRS;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import junitparams.Parameters;
+import junitparams.naming.TestCaseName;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.redis.internal.data.RedisData;
+import org.apache.geode.redis.internal.data.RedisHash;
+import org.apache.geode.redis.internal.data.RedisString;
+import org.apache.geode.test.junit.runners.GeodeParamsRunner;
+
+@RunWith(GeodeParamsRunner.class)
+public class AddByteArrayPairsDeltaUnitTest extends AbstractRedisDeltaUnitTest 
{
+  private final byte[] original = "0123456789".getBytes();
+  private final byte[] payload = "something amazing I guess".getBytes();

Review Comment:
   Tweaked.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to