### Question:
StateTransferManager { ImmutableList<TransferSegment> toSegments(List<TransferSegmentRange> transferRanges) { return transferRanges.stream().map(TransferSegmentRange::toTransferSegment) .collect(ImmutableList.toImmutableList()); }  ImmutableList<TransferSegment> handleTransfer(List<TransferSegmentRange> beforeTransferRanges);  }### Answer:
@Test void testToSegmentsSingle() { StateTransferManager manager = getDefaultInstance(); TransferSegmentRange range = getSingleRange(0L, 1000L, CONSISTENT_READ, false, Optional.of(ImmutableList.of("test1", "test2")), TransferSegmentStatus.builder().build()); ImmutableList<TransferSegmentRange> ranges = ImmutableList.of(range); ImmutableList<TransferSegment> transferSegments = manager.toSegments(ranges); ImmutableList<TransferSegment> expected = ImmutableList.of(getTransferSegment(0L, 1000L, TransferSegmentStatus.builder().build(), ImmutableList.of("test1", "test2"))); assertThat(transferSegments).isEqualTo(expected); }
@Test void testToSegmentsSplit() { StateTransferManager manager = getDefaultInstance(); TransferSegmentRange range1 = getSingleRange(0L, 1000L, CONSISTENT_READ, true, Optional.of(ImmutableList.of("test1", "test2")), TransferSegmentStatus.builder().build()); TransferSegmentRange range2 = getSingleRange(1001L, 2000L, StateTransferType.PROTOCOL_READ, true, Optional.empty(), TransferSegmentStatus.builder().build()); TransferSegmentRange splitRange = getSplitRange((TransferSegmentRangeSingle) range1, (TransferSegmentRangeSingle) range2); ImmutableList<TransferSegmentRange> ranges = ImmutableList.of(splitRange); ImmutableList<TransferSegment> transferSegments = manager.toSegments(ranges); ImmutableList<TransferSegment> expected = ImmutableList.of(getTransferSegment(0L, 2000L, TransferSegmentStatus.builder().build(), ImmutableList.of("test1", "test2"))); assertThat(transferSegments).isEqualTo(expected); }