[Demonstration 1]

[Buggy Method]
private void callMapFragmentWithHealthInfo(String item_name, int cat_id, ArrayList<HealthServiceProviderItemNew> healthServiceProviderItems) {
    MapFragmentOSM mapFragment = new MapFragmentOSM();
    mapFragment.setLocationName(getPlaceChoice());
    // mapFragment.setMapIndicatorText(item_name);
    mapFragment.setCategoryId(cat_id);
    mapFragment.setLocationNameId(locationNameId);
    mapFragment.setHealthServiceProvider(healthServiceProviderItems);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.map_fragment, mapFragment);
    fragmentTransaction.commit();
}

[Buggy Hunk]
mapFragment.setCategoryId(cat_id);

[Patch]
mapFragment.setCategoryId(2);

[Demonstration 2]

[Buggy Method]
@Test
public void testWrite() throws Exception {
    // Spy controller. Mock session.
    MpowerVisualizationController controller = spy(new MpowerVisualizationController());
    doReturn(new UserSession()).when(controller).getAuthenticatedSession(Roles.WORKER);
    // Mock service.
    MpowerVisualizationService mockSvc = mock(MpowerVisualizationService.class);
    controller.setMpowerVisualizationService(mockSvc);
    // Mock request JSON. For simplicity of test, just use the visualization field and just use a string. JSON
    // serialization is already tested in DynamoMpowerVisualizationTest, and validation is handled at the service
    // layer
    String requestJsonText = "{\n" + "   \"visualization\":\"strictly for controller test\"\n" + "}";
    Http.Context.current.set(TestUtils.mockPlayContextWithJson(requestJsonText));
    // execute
    Result result = controller.writeVisualization();
    assertEquals(201, result.status());
    // Verify call to service, and that the visualization passed in has the dummy string we created.
    ArgumentCaptor<MpowerVisualization> vizCaptor = ArgumentCaptor.forClass(MpowerVisualization.class);
    verify(mockSvc).writeVisualization(vizCaptor.capture());
    MpowerVisualization viz = vizCaptor.getValue();
    assertEquals("strictly for controller test", viz.getVisualization().textValue());
    // Verify we get a Worker session.
    verify(controller).getAuthenticatedSession(Roles.WORKER);
}

[Buggy Hunk]
Http.Context.current.set(TestUtils.mockPlayContextWithJson(requestJsonText));

[Patch]
TestUtils.mockPlayContextWithJson(requestJsonText);

[Demonstration 3]

[Buggy Method]
public static void main(String[] args) throws SQLException {
    Connection conn = DriverManager.getConnection("jdbc:h2:./main");
    () -> {
    }.start();
    Statement stmt = conn.createStatement();
    stmt.execute("CREATE TABLE id IDENTITY, username VARCHAR, address VARCHAR, email VARCHAR");
}

[Buggy Hunk]
().start();

[Patch]
Server.createWebServer().start();