Program: 25828
Project: 25828
Buggy source:
/** 
 * Backfill user consent from Stormpath.
 */
private int stormpathUserConsent(Study study){
  int count=0;
  Application application=StormpathFactory.createStormpathApplication(stormpathClient);
  AccountList accounts=application.getAccounts();
  for (  Account account : accounts) {
    final CustomData customData=account.getCustomData();
    final String studyKey=study.getKey();
    final String consentedKey=studyKey + BridgeConstants.CUSTOM_DATA_CONSENT_SUFFIX;
    final Object consentedObj=customData.get(consentedKey);
    final String healthIdKey=studyKey + BridgeConstants.CUSTOM_DATA_HEALTH_CODE_SUFFIX;
    final Object healthIdObj=customData.get(healthIdKey);
    if (consentedObj != null && healthIdObj != null) {
      boolean consented=(Boolean)consentedObj;
      if (consented) {
        String healthId=healthCodeEncryptor.decrypt((String)healthIdObj);
        String healthCode=healthCodeService.getHealthCode(healthId);
        StudyConsent studyConsent=studyConsentDao.getConsent(studyKey);
        if (!userConsentDao.hasConsented(healthCode,studyConsent)) {
          String userName=account.getUsername();
          ConsentSignature researchConsent=new ConsentSignature(userName,"String_Node_Str");
          userConsentDao.giveConsent(healthCode,studyConsent,researchConsent);
          count++;
        }
      }
    }
  }
  return count;
}

Fixed version (ground truth):
/** 
 * Backfill user consent from Stormpath.
 */
private int stormpathUserConsent(Study study){
  int count=0;
  Application application=StormpathFactory.createStormpathApplication(stormpathClient);
  AccountList accounts=application.getAccounts();
  for (  Account account : accounts) {
    final CustomData customData=account.getCustomData();
    final String studyKey=study.getKey();
    final String consentedKey=studyKey + BridgeConstants.CUSTOM_DATA_CONSENT_SUFFIX;
    final Object consentedObj=customData.get(consentedKey);
    final String healthIdKey=studyKey + BridgeConstants.CUSTOM_DATA_HEALTH_CODE_SUFFIX;
    final Object healthIdObj=customData.get(healthIdKey);
    if (consentedObj != null && healthIdObj != null) {
      boolean consented="String_Node_Str".equals(((String)consentedObj).toLowerCase());
      if (consented) {
        String healthId=healthCodeEncryptor.decrypt((String)healthIdObj);
        String healthCode=healthCodeService.getHealthCode(healthId);
        StudyConsent studyConsent=studyConsentDao.getConsent(studyKey);
        if (studyConsent == null) {
          studyConsent=new StudyConsent(){
            @Override public String getStudyKey(){
              return studyKey;
            }
            @Override public long getCreatedOn(){
              return 1406325157000L;
            }
            @Override public boolean getActive(){
              return true;
            }
            @Override public String getPath(){
              return "String_Node_Str";
            }
            @Override public int getMinAge(){
              return 17;
            }
          }
;
        }
        if (!userConsentDao.hasConsented(healthCode,studyConsent)) {
          String userName=account.getUsername();
          ConsentSignature researchConsent=new ConsentSignature(userName,"String_Node_Str");
          userConsentDao.giveConsent(healthCode,studyConsent,researchConsent);
          count++;
        }
      }
    }
  }
  return count;
}