### Question:
RedundancyCalculator { public ImmutableList<TransferSegment> getTrimmedNotRestoredSegments(Layout layout, long trimMark) { return layout.getSegments() .stream() .filter(segment -> segment.getEnd() <= trimMark && !segmentContainsServer(segment, getServer())) .map(segment -> { TransferSegmentStatus transferred = TransferSegmentStatus .builder() .segmentState(TRANSFERRED) .build(); return TransferSegment .builder() .startAddress(segment.getStart()) .endAddress(segment.getEnd() - 1L) .status(transferred) .logUnitServers(ImmutableList.copyOf(segment.getAllLogServers())) .build(); }) .collect(ImmutableList.toImmutableList()); }  Layout updateLayoutAfterRedundancyRestoration(
            List<TransferSegment> segments, Layout initLayout); static boolean canRestoreRedundancy(Layout layout, String server); static boolean canMergeSegments(Layout layout); static boolean canRestoreRedundancyOrMergeSegments(Layout layout, String server); ImmutableList<TransferSegment> createStateList(Layout layout, long trimMark); ImmutableList<TransferSegment> getTrimmedNotRestoredSegments(Layout layout, long trimMark); ImmutableList<TransferSegmentRange> prepareTransferWorkload(
            ImmutableList<TransferSegment> transferSegmentList,
            Optional<Long> committedTail);  }### Answer:
@Test public void testGetTrimmedNotRestoredSegments() { Layout.ReplicationMode replicationMode = CHAIN_REPLICATION; LayoutStripe layoutStripe1 = new LayoutStripe(ImmutableList.of("A")); LayoutSegment segment1 = new LayoutSegment(replicationMode, 0L, 100L, ImmutableList.of(layoutStripe1)); LayoutStripe layoutStripe2 = new LayoutStripe(ImmutableList.of("B", "C")); LayoutSegment segment2 = new LayoutSegment(replicationMode, 100L, 150L, ImmutableList.of(layoutStripe2)); List<String> allServers = ImmutableList.of("A", "B", "C"); Layout layout = new Layout(allServers, allServers, ImmutableList.of(segment1, segment2), ImmutableList.of(), 1L, UUID.randomUUID()); long trimMark = 101L; ImmutableList<TransferSegment> trimmedNotRestoredSegmentsForA = new RedundancyCalculator("A") .getTrimmedNotRestoredSegments(layout, trimMark); assertThat(trimmedNotRestoredSegmentsForA).isEmpty(); ImmutableList<TransferSegment> trimmedNotRestoredSegmentsForB = new RedundancyCalculator("B") .getTrimmedNotRestoredSegments(layout, trimMark); ImmutableList<TransferSegment> trimmedNotRestoredSegmentsForC = new RedundancyCalculator("C") .getTrimmedNotRestoredSegments(layout, trimMark); TransferSegmentStatus transferredStatus = TransferSegmentStatus.builder().segmentState(TRANSFERRED).build(); ImmutableList<TransferSegment> expectedList = ImmutableList.of(TransferSegment.builder() .startAddress(0L) .endAddress(99L) .logUnitServers(ImmutableList.copyOf(segment1.getAllLogServers())) .status(transferredStatus).build()); assertThat(trimmedNotRestoredSegmentsForB).isEqualTo(expectedList); assertThat(trimmedNotRestoredSegmentsForC).isEqualTo(expectedList); }