[Demonstration 1]

[Buggy Method]
@Before
public void setUp() throws Exception {
    configuration = mock(Configuration.class);
    CorePlugin corePlugin = mock(CorePlugin.class);
    requestMonitorPlugin = mock(RequestMonitorPlugin.class);
    when(configuration.getConfig(CorePlugin.class)).thenReturn(corePlugin);
    when(configuration.getConfig(RequestMonitorPlugin.class)).thenReturn(requestMonitorPlugin);
    when(requestMonitorPlugin.getOnlyReportNRequestsPerMinuteToElasticsearch()).thenReturn(1000000d);
    when(requestMonitorPlugin.getOnlyReportRequestsWithNameToElasticsearch()).thenReturn(Collections.singleton("Report Me"));
    when(corePlugin.getElasticsearchUrl()).thenReturn("http://localhost:9200");
    when(corePlugin.getElasticsearchUrls()).thenReturn(Collections.singletonList("http://localhost:9200"));
    when(corePlugin.getElasticsearchClient()).thenReturn(elasticsearchClient = mock(ElasticsearchClient.class));
    registry = new Metric2Registry();
    when(corePlugin.getMetricRegistry()).thenReturn(registry);
    requestTraceLogger = mock(Logger.class);
}

[Buggy Hunk]
CorePlugin corePlugin = mock(CorePlugin.class);

[Patch]
corePlugin = mock(CorePlugin.class);