[Demonstration 1]

[Buggy Method]
private static Column resolveColumnWithQualifier(LogicalPlan plan, LogicalPlan.QueryBlock block, ColumnReferenceExpr columnRef) throws PlanningException {
    final String qualifier;
    String canonicalName;
    final String qualifiedName;
    Pair<String, String> normalized = lookupQualifierAndCanonicalName(block, columnRef);
    qualifier = normalized.getFirst();
    canonicalName = normalized.getSecond();
    qualifiedName = CatalogUtil.buildFQName(qualifier, columnRef.getName());
    Column found = resolveFromRelsWithinBlock(plan, block, columnRef);
    if (found == null) {
        throw new NoSuchColumnException(columnRef.getCanonicalName());
    }
    // If code reach here, a column is found.
    // But, it may be aliased from bottom logical node.
    // If the column is aliased, the found name may not be used in upper node.
    // Here, we try to check if column reference is already aliased.
    // If so, it replaces the name with aliased name.
    LogicalNode currentNode = block.getCurrentNode();
    // The condition (currentNode.getInSchema().contains(column)) means
    // the column can be used at the current node. So, we don't need to find aliase name.
    Schema currentNodeSchema = null;
    if (currentNode != null) {
        if (currentNode instanceof RelationNode) {
            currentNodeSchema = ((RelationNode) currentNode).getLogicalSchema();
        } else {
            currentNodeSchema = currentNode.getInSchema();
        }
    }
    if (currentNode != null && !currentNodeSchema.contains(found) && currentNode.getType() != NodeType.TABLE_SUBQUERY) {
        List<Column> candidates = TUtil.newList();
        if (block.getNamedExprsManager().isAliased(qualifiedName)) {
            String alias = block.getNamedExprsManager().getAlias(canonicalName);
            found = resolve(plan, block, new ColumnReferenceExpr(alias), NameResolvingMode.LEGACY);
            if (found != null) {
                candidates.add(found);
            }
        }
        if (!candidates.isEmpty()) {
            return ensureUniqueColumn(candidates);
        }
    }
    return found;
}

[Buggy Hunk]
String alias = block.getNamedExprsManager().getAlias(canonicalName);

[Patch]
String alias = block.getNamedExprsManager().getAlias(qualifiedName);

[Demonstration 2]

[Buggy Method]
private void saveItemAndReturn() {
    // TODO Handle input telling users to enter title and location if not entered
    // Prepare new values
    // Get title
    String newTitle = titleView.getText().toString();
    String newLocation = locationView.getText().toString();
    // Only save IF title/location/photo has changed
    if (!title.equals(newTitle) || !location.equals(newLocation) || newPhoto != null) {
        File newFile = Utils.getOutputMediaFile(newTitle, Utils.MEDIA_TYPE_IMAGE);
        ContentValues newValues = new ContentValues();
        newValues.put(ItemProvider.COLUMN_TITLE, newTitle);
        newValues.put(ItemProvider.COLUMN_LOCATION, newLocation);
        newValues.put(ItemProvider.COLUMN_IMAGE, newFile.getPath());
        newValues.put(ItemProvider.COLUMN_CATEGORY, getIntent().getIntExtra("Category", 0));
        newValues.put(ItemProvider.COLUMN_CATEGORY_TITLE, getIntent().getStringExtra("Category Title"));
        // Add new item to database if it doesn't exist, else update existing item
        if (title != null && !title.equals("Unnamed item")) {
            getContentResolver().update(ItemProvider.CONTENT_URI, newValues, ItemProvider.COLUMN_TITLE + "=?", new String[] { title });
        } else {
            getContentResolver().insert(ItemProvider.CONTENT_URI, newValues);
        }
    }
    finish();
}

[Buggy Hunk]
if(!title.equals(newTitle) || !location.equals(newLocation) || newPhoto != null) {

[Patch]
if(!newTitle.equals(title) || !newLocation.equals(location) || newPhoto != null) {

[Demonstration 3]

[Buggy Method]
@Test(description = "Remove Subscription By Application Id")
public void testRemoveSubscriptionByAppId() throws Exception {
    defaultAppListIndex = numberOfApis - 2;
    //get default application Id
    HttpResponse getAllAppResponse = apiStore.getAllApplications();
    assertEquals(getAllAppResponse.getResponseCode(), Response.Status.OK.getStatusCode(), "Error in Get All Apps Response");
    JSONObject getAllAppJsonObject = new JSONObject(getAllAppResponse.getData());
    assertFalse(getAllAppJsonObject.getBoolean("error"), "Error in get Applications Response");
    JSONArray getAllAppsJsonArray = getAllAppJsonObject.getJSONArray("applications");
    for (int arrayIndex = 0; arrayIndex < getAllAppsJsonArray.length(); arrayIndex++) {
        if (getAllAppsJsonArray.getJSONObject(arrayIndex).getString("name").equals(applicationName)) {
            String defaultAppId = getAllAppsJsonArray.getJSONObject(arrayIndex).getString("id");
            //remove subscription by application Id
            HttpResponse removeSubscriptionByIdResponse = apiStore.removeAPISubscription(apiNameList.get(defaultAppListIndex), version, providerName, defaultAppId);
            assertEquals(removeSubscriptionByIdResponse.getResponseCode(), Response.Status.OK.getStatusCode(), "Invalid Response Code");
            JSONObject removeSubscriptionByIdJsonObject = new JSONObject(removeSubscriptionByIdResponse.getData());
            assertFalse(removeSubscriptionByIdJsonObject.getBoolean("error"), "Error in Removal Subscription By Application Id");
        }
    }
}

[Buggy Hunk]
if(getAllAppsJsonArray.getJSONObject(arrayIndex).getString("name").equals(applicationName)){

[Patch]
if(getAllAppsJsonArray.getJSONObject(arrayIndex).getString("name").equals(newApplicationName)){