Source:
<code>public void testTrimFiles() throws Exception { Mockito.when(mZookeeperConnector.getCommittedOffsetCount(mTopicPartition)).thenReturn(21L); Mockito.when(mOffsetTracker.setCommittedOffsetCount(mTopicPartition, 21L)).thenReturn(20L); Mockito.when(mOffsetTracker.getLastSeenOffset(mTopicPartition)).thenReturn(21L); HashSet<LogFilePath> logFilePaths = new HashSet<LogFilePath>(); logFilePaths.add(mLogFilePath); Mockito.when(mFileRegistry.getPaths(mTopicPartition)).thenReturn(logFilePaths); PowerMockito.mockStatic(FileSystem.class); SequenceFile.Reader reader = mUploader.getReader(); Mockito.doReturn(LongWritable.class).when(reader).getKeyClass(); Mockito.doReturn(BytesWritable.class).when(reader).getValueClass(); Mockito.when(reader.next(Mockito.any(Writable.class), Mockito.any(Writable.class))).thenAnswer(new Answer<Boolean>() { private int mCallCount = 0; @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { if (mCallCount == 2) { return false; } LongWritable key = (LongWritable) invocation.getArguments()[0]; key.set(20 + mCallCount++); return true; } }); PowerMockito.mockStatic(IdUtil.class); Mockito.when(IdUtil.getLocalMessageDir()).thenReturn("some_message_dir"); SequenceFile.Writer writer = Mockito.mock(SequenceFile.Writer.class); LogFilePath dstLogFilePath = new LogFilePath("/some_parent_dir/some_message_dir", "/some_parent_dir/some_message_dir/some_topic/some_partition/" + "some_other_partition/10_0_00000000000000000021"); <START> CompressionCodec codec = new GzipCodec(); <END> Mockito.when(mFileRegistry.getOrCreateWriter(dstLogFilePath, null)).thenReturn(writer); mUploader.applyPolicy(); Mockito.verify(writer).append(Mockito.any(LongWritable.class), Mockito.any(BytesWritable.class)); Mockito.verify(mFileRegistry).deletePath(mLogFilePath); }</code><technical_language>do need this statement</technical_language>

Target:
public void testTrimFiles() throws Exception { Mockito.when(mZookeeperConnector.getCommittedOffsetCount(mTopicPartition)).thenReturn(21L); Mockito.when(mOffsetTracker.setCommittedOffsetCount(mTopicPartition, 21L)).thenReturn(20L); Mockito.when(mOffsetTracker.getLastSeenOffset(mTopicPartition)).thenReturn(21L); HashSet<LogFilePath> logFilePaths = new HashSet<LogFilePath>(); logFilePaths.add(mLogFilePath); Mockito.when(mFileRegistry.getPaths(mTopicPartition)).thenReturn(logFilePaths); PowerMockito.mockStatic(FileSystem.class); SequenceFile.Reader reader = mUploader.getReader(); Mockito.doReturn(LongWritable.class).when(reader).getKeyClass(); Mockito.doReturn(BytesWritable.class).when(reader).getValueClass(); Mockito.when(reader.next(Mockito.any(Writable.class), Mockito.any(Writable.class))).thenAnswer(new Answer<Boolean>() { private int mCallCount = 0; @Override public Boolean answer(InvocationOnMock invocation) throws Throwable { if (mCallCount == 2) { return false; } LongWritable key = (LongWritable) invocation.getArguments()[0]; key.set(20 + mCallCount++); return true; } }); PowerMockito.mockStatic(IdUtil.class); Mockito.when(IdUtil.getLocalMessageDir()).thenReturn("some_message_dir"); SequenceFile.Writer writer = Mockito.mock(SequenceFile.Writer.class); LogFilePath dstLogFilePath = new LogFilePath("/some_parent_dir/some_message_dir", "/some_parent_dir/some_message_dir/some_topic/some_partition/" + "some_other_partition/10_0_00000000000000000021"); Mockito.when(mFileRegistry.getOrCreateWriter(dstLogFilePath, null)).thenReturn(writer); mUploader.applyPolicy(); Mockito.verify(writer).append(Mockito.any(LongWritable.class), Mockito.any(BytesWritable.class)); Mockito.verify(mFileRegistry).deletePath(mLogFilePath); }