[Demonstration 1]

[Buggy Method]
private static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException {
    DataSource dataSource = null;
    if (config == null) {
        throw new RuntimeException("Device Management Repository data source configuration " + "is null and thus, is not initialized");
    }
    JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
    if (jndiConfig != null) {
        if (log.isDebugEnabled()) {
            log.debug("Initializing Device Management Repository data source using the JNDI " + "Lookup Definition");
        }
        List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
        if (jndiPropertyList != null) {
            Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
            for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
                jndiProperties.put(prop.getName(), prop.getValue());
            }
            dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
        } else {
            dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
        }
    }
    return dataSource;
}

[Buggy Hunk]
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();

[Patch]
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();

[Demonstration 2]

[Buggy Method]
private NList readFrom(Workbook workbook, int sheetIndex) {
    NList result = new NList();
    Sheet sheet = workbook.getSheetAt(sheetIndex);
    if (sheet == null)
        return result;
    NMap header = getExcelColumnHeader(sheet);
    if (header.size() == 0)
        return result;
    FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
    for (int idxRow = 1, maxRowCnt = sheet.getPhysicalNumberOfRows(); idxRow < maxRowCnt; idxRow++) {
        Row row = sheet.getRow(idxRow);
        NMap data = new NMap();
        for (int idxColumn = 0, maxColumnCnt = row.getPhysicalNumberOfCells(); idxColumn < maxColumnCnt; idxColumn++) {
            Cell cell = row.getCell(idxColumn);
            if (cell == null)
                continue;
            String key = header.getString(idxColumn);
            switch(cell.getCellType()) {
                case Cell.CELL_TYPE_FORMULA:
                    if (StringUtil.isNotEmpty(cell)) {
                        switch(evaluator.evaluateFormulaCell(cell)) {
                            case Cell.CELL_TYPE_NUMERIC:
                                data.put(key, getNumericCellValue(cell));
                                break;
                            case Cell.CELL_TYPE_BOOLEAN:
                                data.put(key, cell.getBooleanCellValue());
                                break;
                            case Cell.CELL_TYPE_STRING:
                                data.put(key, cell.getStringCellValue());
                                break;
                        }
                    } else {
                        data.put(key, cell.getStringCellValue());
                    }
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    data.put(key, getNumericCellValue(cell));
                    break;
                case Cell.CELL_TYPE_BOOLEAN:
                    data.put(key, cell.getBooleanCellValue());
                    break;
                default:
                    data.put(key, cell.getStringCellValue());
            }
        }
        result.addRow(data);
    }
    return result;
}

[Buggy Hunk]
for( int idxColumn = 0, maxColumnCnt = row.getPhysicalNumberOfCells(); idxColumn < maxColumnCnt; idxColumn++ ) {

[Patch]
for( int idxColumn = 0, maxColumnCnt = header.size(); idxColumn < maxColumnCnt; idxColumn++ ) {

[Demonstration 3]

[Buggy Method]
@Test
public void addCommand_validData_correctlyConstructed() throws Exception {
    AddCommand command = new AddCommand(Name.EXAMPLE, Phone.EXAMPLE, true, Email.EXAMPLE, false, Address.EXAMPLE, true, EMPTY_STRING_LIST);
    ReadOnlyPerson p = command.getPerson();
    // TODO: add comparison of tags to person.equals and equality methods to
    // individual fields that compare privacy to simplify this
    assertEquals(Name.EXAMPLE, p.getName().fullName);
    assertEquals(Phone.EXAMPLE, p.getPhone().value);
    assertTrue(p.getPhone().isPrivate());
    assertEquals(Email.EXAMPLE, p.getEmail().value);
    assertFalse(p.getEmail().isPrivate());
    assertEquals(Address.EXAMPLE, p.getAddress().value);
    assertTrue(p.getAddress().isPrivate());
    boolean isTagListEmpty = !p.getTags().iterator().hasNext();
    assertTrue(isTagListEmpty);
}

[Buggy Hunk]
assertEquals(Address.EXAMPLE, p.getAddress().value);

[Patch]
assertEquals(Address.EXAMPLE, p.getAddress().toString());