Skip to content

Commit

Permalink
Fix bug in getRingRangeString(), add unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles-Garnsey committed Sep 25, 2023
1 parent 40cef22 commit b2bccfb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.util.List;
import java.util.stream.Collectors;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.PUT;
Expand Down Expand Up @@ -124,12 +125,7 @@ private String getParallelismName(RepairParallelism parallelism) {

private String getRingRangeString(List<RingRange> associatedTokens) {
if (associatedTokens != null && !associatedTokens.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (RingRange ringRange : associatedTokens) {
sb.append(toRangeString(ringRange)).append(",");
}
// remove trailing comma
return sb.substring(0, sb.length() - 2);
return associatedTokens.stream().map(this::toRangeString).collect(Collectors.joining(","));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.datastax.mgmtapi.resources.v2.models.RepairParallelism;
import com.datastax.mgmtapi.resources.v2.models.RepairRequest;
import com.datastax.mgmtapi.resources.v2.models.RepairRequestResponse;
import com.datastax.mgmtapi.resources.v2.models.RingRange;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Row;
import java.io.File;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void testRepairResourcesSuccess() throws Exception {
Collections.singletonList("table1"),
false,
true,
Collections.EMPTY_LIST,
Collections.singletonList(new RingRange("-100", "100")),
RepairParallelism.DATACENTER_AWARE,
Collections.EMPTY_LIST,
1);
Expand All @@ -67,7 +68,7 @@ public void testRepairResourcesSuccess() throws Exception {
eq(true),
eq(RepairParallelism.DATACENTER_AWARE.getName()),
eq(Collections.EMPTY_LIST),
eq(null),
eq("-100:100"),
eq(Integer.valueOf(1)));
}

Expand Down

0 comments on commit b2bccfb

Please sign in to comment.