DonalEvans commented on a change in pull request #6760:
URL: https://github.com/apache/geode/pull/6760#discussion_r690693874
##########
File path:
geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/data/RedisSetTest.java
##########
@@ -128,57 +129,81 @@ public void equals_returnsTrue_givenDifferentEmptySets() {
}
@Test
- public void sadd_stores_delta_that_is_stable() throws IOException {
+ public void sadd_stores_delta_that_is_stable() {
Region<RedisKey, RedisData> region = uncheckedCast(mock(Region.class));
+ when(region.put(any(), any())).thenAnswer(invocation -> {
+ RedisSet value = invocation.getArgument(1, RedisSet.class);
+ assertThat(value.hasDelta()).isTrue();
+ HeapDataOutputStream out = new HeapDataOutputStream(100);
+ value.toDelta(out);
+ ByteArrayDataInput in = new ByteArrayDataInput(out.toByteArray());
+ RedisSet set2 = createRedisSet(1, 2);
+ assertThat(set2).isNotEqualTo(value);
+ set2.fromDelta(in);
+ assertThat(set2).isEqualTo(value);
+ return null;
+ });
Review comment:
This `Answer` could be extracted to a method in the three places it's
used here.
##########
File path:
geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/data/RedisHashTest.java
##########
@@ -123,62 +124,86 @@ public void
equals_returnsTrue_givenDifferentEmptyHashes() {
/************* HSET *************/
@SuppressWarnings("unchecked")
@Test
- public void hset_stores_delta_that_is_stable() throws IOException {
+ public void hset_stores_delta_that_is_stable() {
Region<RedisKey, RedisData> region = Mockito.mock(Region.class);
+ when(region.put(any(), any())).thenAnswer(invocation -> {
+ RedisHash value = invocation.getArgument(1, RedisHash.class);
+ assertThat(value.hasDelta()).isTrue();
+ HeapDataOutputStream out = new HeapDataOutputStream(100);
+ value.toDelta(out);
+ ByteArrayDataInput in = new ByteArrayDataInput(out.toByteArray());
+ RedisHash o2 = createRedisHash("k1", "v1", "k2", "v2");
+ assertThat(o2).isNotEqualTo(value);
+ o2.fromDelta(in);
+ assertThat(o2).isEqualTo(value);
+ return null;
+ });
Review comment:
This `Answer` is duplicated in three different places. Could it be
extracted to a method?
##########
File path:
geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/data/RedisSortedSetTest.java
##########
@@ -139,46 +140,52 @@ public void
equals_returnsTrue_givenDifferentEmptySortedSets() {
}
@Test
- public void zadd_stores_delta_that_is_stable() throws IOException {
+ public void zadd_stores_delta_that_is_stable() {
Region<RedisKey, RedisData> region = uncheckedCast(mock(Region.class));
+ when(region.put(any(), any())).thenAnswer(invocation -> {
+ RedisSortedSet value = invocation.getArgument(1, RedisSortedSet.class);
+ assertThat(value.hasDelta()).isTrue();
+ HeapDataOutputStream out = new HeapDataOutputStream(100);
+ value.toDelta(out);
+ ByteArrayDataInput in = new ByteArrayDataInput(out.toByteArray());
+ RedisSortedSet sortedSet2 = createRedisSortedSet("3.14159", "v1",
"2.71828", "v2");
+ assertThat(sortedSet2).isNotEqualTo(value);
+ sortedSet2.fromDelta(in);
+ assertThat(sortedSet2).isEqualTo(value);
+ return null;
+ });
Review comment:
This can be extracted to a method to avoid duplication.
--
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]