[Demonstration 1]

[Buggy Method]
public synchronized boolean removeAndCheckIfLast(ITestNGMethod m, Object instance) {
    List<ITestNGMethod> l = m_classMap.get(instance);
    if (l != null) {
        l.remove(m);
        // It's the last method of this class if all the methods remaining in the list belong to a
        // different class
        for (ITestNGMethod tm : l) {
            if (tm.getEnabled() && tm.getRealClass().equals(m.getRealClass()))
                return false;
        }
        return true;
    } else {
        throw new AssertionError("l should not be null");
    }
}

[Buggy Hunk]
if (tm.getEnabled() && tm.getRealClass().equals(m.getRealClass())) return false;

[Patch]
if (tm.getEnabled() && tm.getTestClass().equals(m.getTestClass())) return false;

[Demonstration 2]

[Buggy Method]
public void saveUserMetrics() {
    mAdapter.getDeck().saveCards();
    sEditor.putString("ActiveDeckName", mAdapter.getDeck().name);
    sEditor.putString("UserName", HearthTrackerUtils.username);
    final int num = HearthTrackerUtils.sUserDeckNames.size();
    Set<String> deckName = new HashSet<>();
    for (int i = 0; i < num; i++) {
        deckName.add(HearthTrackerUtils.sUserDeckNames.get(i));
    }
    sEditor.putStringSet("UserDeckNames", deckName);
    sEditor.commit();
}

[Buggy Hunk]
sEditor.putString("ActiveDeckName", mAdapter.getDeck().name);

[Patch]
sEditor.putString("ActiveDeckName", mAdapter.getDeck().path);

[Demonstration 3]

[Buggy Method]
public int updateTextReminder(TextReminder tm) {
    SQLiteDatabase db = this.getWritableDatabase();
    ContentValues cv = new ContentValues();
    cv.put(TM_COL_TITLE, tm.getTitle());
    cv.put(TM_COL_MESSAGE, tm.getMessage());
    String recName = (tm.getRecipientName().length() > 0) ? tm.getRecipientName() : null;
    cv.put(TM_COL_SENT_STATUS, tm.getSentStatus());
    cv.put(TM_COL_ACTIVE, tm.getActive());
    cv.put(TM_COL_REC_NAME, recName);
    cv.put(TM_COL_REC_NUM, tm.getRecipientNumber());
    cv.put(TM_COL_DUEDATE, tm.getDueDate());
    // updating row
    return db.update(TM_TABLE, cv, TM_COL_ID + " = " + tm.getId(), null);
}

[Buggy Hunk]
String recName = (tm.getRecipientName().length() > 0) ? tm.getRecipientName() : null;

[Patch]
String recName = tm.getRecipientName();