@Test public void recover() throws Exception { mockStatic(SwiftContext.class); when(SwiftContext.get()).thenReturn(mock(BeanFactory.class)); SegmentService segmentManager = mock(SegmentService.class); when(SwiftContext.get().getBean(SegmentService.class)).thenReturn(segmentManager); Segment realtimeSeg = mock(Segment.class); SegmentKey segKey = mock(SegmentKey.class); when(segmentManager.getSegment(segKey)).thenReturn(realtimeSeg); FileSegmentRecovery recovery = spy(new FileSegmentRecovery()); doReturn(realtimeSeg).when(recovery, "newRealtimeSegment", realtimeSeg); SwiftInserter inserter = mock(SwiftInserter.class); mockStatic(SwiftInserter.class); when(SwiftInserter.ofOverwriteMode(realtimeSeg)).thenReturn(inserter); Segment backupSeg = mock(Segment.class); SwiftMetaData meta = mock(SwiftMetaData.class); when(realtimeSeg.getMetaData()).thenReturn(meta); doReturn(backupSeg).when(recovery, "getBackupSegment", segKey, meta); SegmentBackupResultSet resultSet = mock(SegmentBackupResultSet.class); whenNew(SegmentBackupResultSet.class).withArguments(backupSeg).thenReturn(resultSet); doNothing().doThrow(Exception.class).when(inserter).insertData(resultSet); when(resultSet.getAllShowIndex()).thenReturn(mock(ImmutableBitMap.class)); Whitebox.invokeMethod(recovery, "recover", segKey); verify(inserter).insertData(resultSet); verify(realtimeSeg).putAllShowIndex(resultSet.getAllShowIndex()); Whitebox.invokeMethod(recovery, "recover", segKey); verify(realtimeSeg).putRowCount(0); verify(realtimeSeg).putAllShowIndex(argThat(new ArgumentMatcher<ImmutableBitMap>() { @Override public boolean matches(ImmutableBitMap argument) { return argument.isFull() && argument.isEmpty(); } })); }
@Override public void recover(List<SegmentKey> segmentKeys) { for (SegmentKey segKey : segmentKeys) { recover(segKey); } }
FileSegmentRecovery extends AbstractSegmentRecovery { @Override public void recover(List<SegmentKey> segmentKeys) { for (SegmentKey segKey : segmentKeys) { recover(segKey); } } }
FileSegmentRecovery extends AbstractSegmentRecovery { @Override public void recover(List<SegmentKey> segmentKeys) { for (SegmentKey segKey : segmentKeys) { recover(segKey); } }  }
FileSegmentRecovery extends AbstractSegmentRecovery { @Override public void recover(List<SegmentKey> segmentKeys) { for (SegmentKey segKey : segmentKeys) { recover(segKey); } }  @Override void recover(List<SegmentKey> segmentKeys); }
FileSegmentRecovery extends AbstractSegmentRecovery { @Override public void recover(List<SegmentKey> segmentKeys) { for (SegmentKey segKey : segmentKeys) { recover(segKey); } }  @Override void recover(List<SegmentKey> segmentKeys);  }