[Demonstration 1]

[Buggy Method]
public Iterator<E> getShortest(int from, int to) {
    for (E edge : edges) {
        if (edge.getSource() == from) {
            List<E> path = new ArrayList<>();
            path.add(edge);
            queue.add(new QueueElement(edge, path));
        }
    }
    visited.add(from);
    while (!queue.isEmpty()) {
        QueueElement next = queue.poll();
        final int dest = next.getDest();
        if (!visited.contains(dest)) {
            if (next.getDest() == to) {
                return next.getPath().iterator();
            } else {
                visited.add(dest);
                for (E edge : edges) {
                    if (!visited.contains(edge.getDest())) {
                        List<E> oldPath = (List<E>) next.getPath();
                        oldPath.add(edge);
                        queue.add(new QueueElement(edge, oldPath));
                    }
                }
            }
        }
    }
    return null;
}

[Buggy Hunk]
if (!visited.contains(edge.getDest())){

[Patch]
if (!visited.contains(edge.getDest()) && edge.getSource() == dest){

[Demonstration 2]

[Buggy Method]
@BeforeMethod
public void setup() throws Throwable {
    host = TestHost.create(mock(HostClient.class), mock(ZookeeperHostMonitor.class));
    service = spy(new ImageSeederService());
    hostClientFactory = mock(HostClientFactory.class);
    cloudStoreHelper = new CloudStoreHelper();
    // Build input.
    newImageSeeder = buildValidStartupState();
    newImageSeeder.isSelfProgressionDisabled = false;
}

[Buggy Hunk]
host = TestHost.create(mock(HostClient.class), mock(ZookeeperHostMonitor.class));

[Patch]
host = TestHost.create(mock(HostClient.class), null);

[Demonstration 3]

[Buggy Method]
@Before
public void before() {
    MockitoAnnotations.initMocks(this);
    mockView = Mockito.mock(EntityActionControllerView.class);
    mockPreflightController = Mockito.mock(PreflightController.class);
    mockSynapseClient = Mockito.mock(SynapseClientAsync.class);
    mockGlobalApplicationState = Mockito.mock(GlobalApplicationState.class);
    mockPlaceChanger = Mockito.mock(PlaceChanger.class);
    mockRenameEntityModalWidget = Mockito.mock(RenameEntityModalWidget.class);
    mockEditFileMetadataModalWidget = Mockito.mock(EditFileMetadataModalWidget.class);
    mockEditProjectMetadataModalWidget = Mockito.mock(EditProjectMetadataModalWidget.class);
    mockAuthenticationController = Mockito.mock(AuthenticationController.class);
    mockMarkdownEditorWidget = Mockito.mock(WikiMarkdownEditor.class);
    mockAccessControlListModalWidget = Mockito.mock(AccessControlListModalWidget.class);
    mockProvenanceEditorWidget = Mockito.mock(ProvenanceEditorWidget.class);
    mockActionMenu = Mockito.mock(ActionMenuWidget.class);
    mockEntityUpdatedHandler = Mockito.mock(EntityUpdatedHandler.class);
    mockEntityFinder = Mockito.mock(EntityFinder.class);
    mockSubmitter = Mockito.mock(EvaluationSubmitter.class);
    mockUploader = Mockito.mock(UploadDialogWidget.class);
    mockStorageLocationWidget = Mockito.mock(StorageLocationWidget.class);
    when(mockAuthenticationController.isLoggedIn()).thenReturn(true);
    when(mockAuthenticationController.getCurrentUserPrincipalId()).thenReturn(currentUserId);
    when(mockGlobalApplicationState.getPlaceChanger()).thenReturn(mockPlaceChanger);
    // The controller under test.
    controller = new EntityActionControllerImpl(mockView, mockPreflightController, mockSynapseClient, mockGlobalApplicationState, mockAuthenticationController, mockAccessControlListModalWidget, mockRenameEntityModalWidget, mockEditFileMetadataModalWidget, mockEditProjectMetadataModalWidget, mockEntityFinder, mockSubmitter, mockUploader, mockMarkdownEditorWidget, mockProvenanceEditorWidget, mockStorageLocationWidget, mockEvalEditor, mockCookies, mockChallengeClient, mockSelectTeamModal, mockApproveUserAccessModal);
    parentId = "syn456";
    entityId = "syn123";
    Entity table = new TableEntity();
    table.setId(entityId);
    table.setParentId(parentId);
    permissions = new UserEntityPermissions();
    permissions.setCanChangePermissions(true);
    permissions.setCanDelete(true);
    permissions.setCanPublicRead(true);
    permissions.setCanUpload(true);
    permissions.setCanAddChild(true);
    permissions.setCanEdit(true);
    permissions.setCanCertifiedUserEdit(true);
    permissions.setCanChangeSettings(true);
    entityBundle = new EntityBundle();
    entityBundle.setEntity(table);
    entityBundle.setPermissions(permissions);
    entityBundle.setDoi(new Doi());
    selected = new Reference();
    selected.setTargetId("syn9876");
    // Setup the mock entity selector to select an entity.
    Mockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            SelectedHandler<Reference> handler = (SelectedHandler<Reference>) invocation.getArguments()[2];
            handler.onSelected(selected);
            return null;
        }
    }).when(mockEntityFinder).configure(any(EntityFilter.class), anyBoolean(), any(SelectedHandler.class));
    mockWikiPageToDelete = Mockito.mock(V2WikiPage.class);
    when(mockWikiPageToDelete.getId()).thenReturn(wikiPageId);
    when(mockWikiPageToDelete.getParentWikiId()).thenReturn(parentWikiPageId);
    when(mockWikiPageToDelete.getTitle()).thenReturn(wikiPageTitle);
    AsyncMockStubber.callSuccessWith(mockWikiPageToDelete).when(mockSynapseClient).getV2WikiPage(any(WikiPageKey.class), any(AsyncCallback.class));
}

[Buggy Hunk]
mockEvalEditor, mockCookies, mockChallengeClient, mockSelectTeamModal, mockApproveUserAccessModal);

[Patch]
mockEvalEditor, mockCookies, mockChallengeClient, mockSelectTeamModal);