yifan-c commented on code in PR #171:
URL: https://github.com/apache/cassandra-sidecar/pull/171#discussion_r1957055445
##########
server/src/test/java/org/apache/cassandra/sidecar/db/RestoreSliceTest.java:
##########
@@ -83,52 +80,46 @@ void testCreateFromRow()
assertThat(sliceFromRow).isEqualTo(slice);
}
+ @Test
+ void testCreateFromPayload()
+ {
+ CreateSliceRequestPayload payload = new
CreateSliceRequestPayload("slice-id", 0, "bucket", "key", "checksum",
+
BigInteger.ONE, // first token
+
BigInteger.TEN, // end token
+
123L, // uncompressed size
+
100L); // compressed size
+ RestoreSlice slice =
RestoreSlice.builder().createSliceRequestPayload(payload).build();
+ assertThat(slice.sliceId()).isEqualTo("slice-id");
+ assertThat(slice.bucketId()).isEqualTo((short) 0);
+ assertThat(slice.bucket()).isEqualTo("bucket");
+ assertThat(slice.key()).isEqualTo("key");
+ assertThat(slice.checksum()).isEqualTo("checksum");
+ assertThat(slice.startToken())
+ .describedAs("Start token is exclusive end in the range")
+ .isEqualTo(BigInteger.ZERO);
+ assertThat(slice.endToken()).isEqualTo(BigInteger.TEN);
+ assertThat(slice.uncompressedSize()).isEqualTo(123L);
+ assertThat(slice.compressedSize()).isEqualTo(100L);
+ }
+
@Test
void testNoSplit()
{
RestoreSlice slice = createTestingSlice(UUIDs.timeBased(), "slice-id",
0L, 10L);
- List<RestoreSlice> result = slice.splitMaybe(null);
- assertThat(result).hasSize(1);
- assertThat(result.get(0)).isSameAs(slice);
-
- TokenRangeReplicasResponse topology =
mock(TokenRangeReplicasResponse.class);
-
when(topology.writeReplicas()).thenReturn(Collections.singletonList(new
ReplicaInfo("-10", "10", null)));
- // range in topology fully encloses the slice
- result = slice.splitMaybe(topology);
- assertThat(result).hasSize(1);
- assertThat(result.get(0)).isSameAs(slice);
+ RestoreSlice result = slice.trimMaybe(new TokenRange(-10L, 10L));
+ assertThat(result)
+ .describedAs("No trim is done when fully enclosed by the local token
range")
+ .isSameAs(slice);
}
@Test
void testSplitNoOverlap()
{
RestoreSlice slice = createTestingSlice(UUIDs.timeBased(), "slice-id",
0L, 10L);
- TokenRangeReplicasResponse topology =
mock(TokenRangeReplicasResponse.class);
-
when(topology.writeReplicas()).thenReturn(Collections.singletonList(new
ReplicaInfo("100", "110", null)));
// (0, 10] does not overlap with (100, 110]
- assertThatThrownBy(() -> slice.splitMaybe(topology))
+ assertThatThrownBy(() -> slice.trimMaybe(new TokenRange(100L, 110L)))
Review Comment:
done
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]