Source:
<code>public void testNotFilterAboveThreshold() throws IOException { RequestLogger delegate = EasyMock.createStrictMock(RequestLogger.class); delegate.logNativeQuery(EasyMock.anyObject()); EasyMock.expectLastCall().times(2); delegate.logSqlQuery(EasyMock.anyObject()); EasyMock.expectLastCall().times(2); FilteredRequestLoggerProvider.FilteredRequestLogger logger = new FilteredRequestLoggerProvider.FilteredRequestLogger( delegate, 1000, 2000, ImmutableList.of() ); RequestLogLine nativeRequestLogLine = EasyMock.createMock(RequestLogLine.class); EasyMock.expect(nativeRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("query/time", 10000))) .once(); EasyMock.expect(nativeRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("query/time", 1000))) .once(); EasyMock.expect(nativeRequestLogLine.getQuery()) <START> .andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), <END> null, null, null, null, null, null, null)) .times(2); RequestLogLine sqlRequestLogLine = EasyMock.createMock(RequestLogLine.class); EasyMock.expect(sqlRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 10000))) .once(); EasyMock.expect(sqlRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 2000))) .once(); EasyMock.expect(sqlRequestLogLine.getQuery()) .andReturn(new SegmentMetadataQuery(new LegacyDataSource("foo"), null, null, null, null, null, null, null)) .times(2); EasyMock.replay(nativeRequestLogLine, sqlRequestLogLine, delegate); logger.logNativeQuery(nativeRequestLogLine); logger.logNativeQuery(nativeRequestLogLine); logger.logSqlQuery(sqlRequestLogLine); logger.logSqlQuery(sqlRequestLogLine); EasyMock.verify(nativeRequestLogLine, sqlRequestLogLine, delegate); }</code><technical_language>Please extract new SegmentMetadataQuery(...) a variable</technical_language>

Target:
public void testNotFilterAboveThreshold() throws IOException { RequestLogger delegate = EasyMock.createStrictMock(RequestLogger.class); delegate.logNativeQuery(EasyMock.anyObject()); EasyMock.expectLastCall().times(2); delegate.logSqlQuery(EasyMock.anyObject()); EasyMock.expectLastCall().times(2); FilteredRequestLoggerProvider.FilteredRequestLogger logger = new FilteredRequestLoggerProvider.FilteredRequestLogger( delegate, 1000, 2000, ImmutableList.of() ); RequestLogLine nativeRequestLogLine = EasyMock.createMock(RequestLogLine.class); EasyMock.expect(nativeRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("query/time", 10000))) .once(); EasyMock.expect(nativeRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("query/time", 1000))) .once(); EasyMock.expect(nativeRequestLogLine.getQuery()) .andReturn(testSegmentMetadataQuery) .times(2); RequestLogLine sqlRequestLogLine = EasyMock.createMock(RequestLogLine.class); EasyMock.expect(sqlRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 10000))) .once(); EasyMock.expect(sqlRequestLogLine.getQueryStats()) .andReturn(new QueryStats(ImmutableMap.of("sqlQuery/time", 2000))) .once(); EasyMock.expect(sqlRequestLogLine.getQuery()) .andReturn(testSegmentMetadataQuery) .times(2); EasyMock.replay(nativeRequestLogLine, sqlRequestLogLine, delegate); logger.logNativeQuery(nativeRequestLogLine); logger.logNativeQuery(nativeRequestLogLine); logger.logSqlQuery(sqlRequestLogLine); logger.logSqlQuery(sqlRequestLogLine); EasyMock.verify(nativeRequestLogLine, sqlRequestLogLine, delegate); }