[Demonstration 1]

[Buggy Method]
public void reindexCollections(ReindexationParams params) {
    if (logManager != null && params.getReindexationMode().isFullRewrite()) {
        logManager.regroupAndMoveInVault();
        logManager.moveTLOGToBackup();
        RecordDao recordDao = modelLayerFactory.getDataLayerFactory().newRecordDao();
        try {
            RecordDTO recordDTO = recordDao.get("the_private_key");
            try {
                recordDao.execute(new TransactionDTO(RecordsFlushing.LATER()).withNewRecords(asList(recordDTO)).withFullRewrite(true));
            } catch (OptimisticLocking optimisticLocking) {
                throw new RuntimeException(optimisticLocking);
            }
        } catch (NoSuchRecordWithId noSuchRecordWithId) {
            //OK
        }
        recordDao.expungeDeletes();
    }
    for (String collection : modelLayerFactory.getCollectionsListManager().getCollectionsExcludingSystem()) {
        reindexCollection(collection, params);
    }
    if (logManager != null && params.getReindexationMode().isFullRewrite()) {
        logManager.regroupAndMoveInVault();
        logManager.deleteLastTLOGBackup();
    }
}

[Buggy Hunk]
for (String collection : modelLayerFactory.getCollectionsListManager().getCollectionsExcludingSystem()) {

[Patch]
for (String collection : modelLayerFactory.getCollectionsListManager().getCollections()) {

[Demonstration 2]

[Buggy Method]
@Override
public void processRow(GeneticVariant variant) {
    variant.getTranscript_consequences().stream().map(tc -> new GeneToGeneticVariantOutput(tc)).forEach(output -> write(output));
}

[Buggy Hunk]
.forEach(output -> write(output));

[Patch]
.forEach(output -> set.add(output));

[Demonstration 3]

[Buggy Method]
@Before
public void setUpTest() {
    // Mock device service
    expect(mockDeviceService.getDevice(deviceId1)).andReturn(device1);
    expect(mockDeviceService.getDevice(deviceId2)).andReturn(device2);
    expect(mockDeviceService.getDevices()).andReturn(ImmutableSet.of(device1, device2));
    // Mock Core Service
    expect(mockCoreService.getAppId(anyShort())).andReturn(NetTestTools.APP_ID).anyTimes();
    expect(mockCoreService.getAppId(anyString())).andReturn(NetTestTools.APP_ID).anyTimes();
    expect(mockCoreService.registerApplication(anyString())).andReturn(APP_ID).anyTimes();
    replay(mockCoreService);
    // Register the services needed for the test
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory = new TestServiceDirectory().add(FlowRuleService.class, mockFlowService).add(DeviceService.class, mockDeviceService).add(CodecService.class, codecService).add(CoreService.class, mockCoreService).add(ApplicationService.class, mockApplicationService);
    BaseResource.setServiceDirectory(testDirectory);
}

[Buggy Hunk]
expect(mockCoreService.registerApplication(anyString()))

[Patch]
expect(mockCoreService.registerApplication(FlowRuleCodec.REST_APP_ID))