nus-yam/ex-repair huggingface dataset:
Program: 25712
Project: 25712
Buggy source:
@Test public void saveStudyReportData(){
  ReportData someData=createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str");
  service.saveStudyReport(TEST_STUDY,IDENTIFIER,someData);
  service.saveStudyReport(TEST_STUDY,IDENTIFIER,someData);
  verify(mockReportDataDao,times(2)).saveReportData(reportDataCaptor.capture());
  ReportData retrieved=reportDataCaptor.getValue();
  assertEquals(someData,retrieved);
  assertEquals(STUDY_REPORT_DATA_KEY.getKeyString(),retrieved.getKey());
  assertEquals(LocalDate.parse("String_Node_Str"),retrieved.getDate());
  assertEquals("String_Node_Str",retrieved.getData().get("String_Node_Str").asText());
  assertEquals("String_Node_Str",retrieved.getData().get("String_Node_Str").asText());
  verify(mockReportIndexDao,times(1)).addIndex(new ReportDataKey.Builder().withStudyIdentifier(TEST_STUDY).withReportType(ReportType.STUDY).withIdentifier(IDENTIFIER).build());
}

Fixed version (ground truth):
@Test public void saveStudyReportData(){
  ReportData someData=createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str");
  service.saveStudyReport(TEST_STUDY,IDENTIFIER,someData);
  verify(mockReportDataDao).saveReportData(reportDataCaptor.capture());
  ReportData retrieved=reportDataCaptor.getValue();
  assertEquals(someData,retrieved);
  assertEquals(STUDY_REPORT_DATA_KEY.getKeyString(),retrieved.getKey());
  assertEquals(LocalDate.parse("String_Node_Str"),retrieved.getDate());
  assertEquals("String_Node_Str",retrieved.getData().get("String_Node_Str").asText());
  assertEquals("String_Node_Str",retrieved.getData().get("String_Node_Str").asText());
  verify(mockReportIndexDao).addIndex(new ReportDataKey.Builder().withStudyIdentifier(TEST_STUDY).withReportType(ReportType.STUDY).withIdentifier(IDENTIFIER).build());
}
Program: 25713
Project: 25713
Buggy source:
public Result getStudy(String identifier) throws Exception {
  getAuthenticatedSession(ADMIN);
  Study study=studyService.getStudy(identifier);
  return ok(Study.STUDY_WRITER.writeValueAsString(study));
}

Fixed version (ground truth):
public Result getStudy(String identifier) throws Exception {
  getAuthenticatedSession(ADMIN);
  Study study=studyService.getStudy(identifier,true);
  return ok(Study.STUDY_WRITER.writeValueAsString(study));
}
Program: 25714
Project: 25714
Buggy source:
/** 
 * A similar method as above but specifying study id only for WORKER
 */
public Result saveStudyReportForSpecifiedStudy(String studyId,String identifier) throws Exception {
  getAuthenticatedSession(WORKER);
  ReportData reportData=parseJson(request(),ReportData.class);
  reportData.setKey(null);
  Study study=studyService.getStudy(studyId);
  reportService.saveStudyReport(study.getStudyIdentifier(),identifier,reportData);
  return createdResult("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * A similar method as above but specifying study id only for WORKER
 */
public Result saveStudyReportForSpecifiedStudy(String studyIdString,String identifier) throws Exception {
  getAuthenticatedSession(WORKER);
  ReportData reportData=parseJson(request(),ReportData.class);
  reportData.setKey(null);
  StudyIdentifier studyId=new StudyIdentifierImpl(studyIdString);
  reportService.saveStudyReport(studyId,identifier,reportData);
  return createdResult("String_Node_Str");
}
Program: 25715
Project: 25715
Buggy source:
/** 
 * another version of getUploads for workers to specify any studyid to get uploads
 * @param startTimeString
 * @param endTimeString
 * @return
 */
public Result getUploadsForStudy(String studyId,String startTimeString,String endTimeString) throws EntityNotFoundException {
  getAuthenticatedSession(WORKER);
  DateTime startTime=DateUtils.getDateTimeOrDefault(startTimeString,null);
  DateTime endTime=DateUtils.getDateTimeOrDefault(endTimeString,null);
  Study study=studyService.getStudy(studyId);
  DateTimeRangeResourceList<? extends UploadView> uploads=uploadService.getStudyUploads(study.getStudyIdentifier(),startTime,endTime);
  return okResult(uploads);
}

Fixed version (ground truth):
/** 
 * another version of getUploads for workers to specify any studyid to get uploads
 * @param startTimeString
 * @param endTimeString
 * @return
 */
public Result getUploadsForStudy(String studyIdString,String startTimeString,String endTimeString) throws EntityNotFoundException {
  getAuthenticatedSession(WORKER);
  DateTime startTime=DateUtils.getDateTimeOrDefault(startTimeString,null);
  DateTime endTime=DateUtils.getDateTimeOrDefault(endTimeString,null);
  StudyIdentifier studyId=new StudyIdentifierImpl(studyIdString);
  DateTimeRangeResourceList<? extends UploadView> uploads=uploadService.getStudyUploads(studyId,startTime,endTime);
  return okResult(uploads);
}
Program: 25717
Project: 25717
Buggy source:
@Before public void before(){
  mockCache=mock(CacheProvider.class);
  studyService.setCacheProvider(mockCache);
  studyService.setSynapseClient(synapseClient);
}

Fixed version (ground truth):
@Before public void before() throws SynapseException {
  mockCache=mock(CacheProvider.class);
  studyService.setCacheProvider(mockCache);
  studyService.setSynapseClient(synapseClient);
  if (project != null) {
    synapseClient.deleteEntityById(project.getId());
  }
  if (team != null) {
    synapseClient.deleteTeam(team.getId());
  }
}
Program: 25720
Project: 25720
Buggy source:
public Result createSynapse(String userId) throws Exception {
  UserSession session=getAuthenticatedSession(DEVELOPER,RESEARCHER,ADMIN);
  Study study=studyService.getStudy(session.getStudyIdentifier());
  Long userIdNum=Long.parseLong(userId);
  studyService.createSynapseProjectTeam(userIdNum,study);
  return okResult(new SynapseProjectTeamCreationHolder(study.getSynapseProjectId(),study.getSynapseDataAccessTeamId()));
}

Fixed version (ground truth):
public Result createSynapse(String userId) throws Exception {
  UserSession session=getAuthenticatedSession(DEVELOPER);
  Study study=studyService.getStudy(session.getStudyIdentifier());
  Long userIdNum=Long.parseLong(userId);
  studyService.createSynapseProjectTeam(userIdNum,study);
  return createdResult(new SynapseProjectIdTeamIdHolder(study.getSynapseProjectId(),study.getSynapseDataAccessTeamId()));
}
Program: 25721
Project: 25721
Buggy source:
public Study createSynapseProjectTeam(Long userId,Study study) throws SynapseException {
  Team team=new Team();
  team.setName(randomAlphanumeric(5) + "String_Node_Str");
  Project project=new Project();
  project.setName(randomAlphanumeric(5) + "String_Node_Str");
  Team newTeam=synapseClient.createTeam(team);
  Project newProject=synapseClient.createEntity(project);
  org.sagebionetworks.repo.model.AccessControlList acl=synapseClient.getACL(newProject.getId());
  ResourceAccess toSet=new ResourceAccess();
  toSet.setPrincipalId(Long.parseLong(EXPORTER_SYNAPSE_USER_ID));
  toSet.setAccessType(ModelConstants.ENITY_ADMIN_ACCESS_PERMISSIONS);
  acl.getResourceAccess().add(toSet);
  ResourceAccess toSetUser=new ResourceAccess();
  toSetUser.setPrincipalId(userId);
  toSetUser.setAccessType(ModelConstants.ENITY_ADMIN_ACCESS_PERMISSIONS);
  acl.getResourceAccess().add(toSetUser);
  synapseClient.updateACL(acl);
  MembershipInvtnSubmission teamMemberInvitation=new MembershipInvtnSubmission();
  teamMemberInvitation.setInviteeId(userId.toString());
  teamMemberInvitation.setTeamId(newTeam.getId());
  synapseClient.createMembershipInvitation(teamMemberInvitation,null,null);
  synapseClient.setTeamMemberPermissions(newTeam.getId(),userId.toString(),true);
  String newTeamId=newTeam.getId();
  String newProjectId=newProject.getId();
  study.setSynapseProjectId(newProjectId);
  study.setSynapseDataAccessTeamId(Long.parseLong(newTeamId));
  updateStudy(study,false);
  return study;
}

Fixed version (ground truth):
public Study createSynapseProjectTeam(Long userId,Study study) throws SynapseException {
  Team team=new Team();
  team.setName(study.getName() + "String_Node_Str");
  Project project=new Project();
  project.setName(study.getName() + "String_Node_Str");
  Team newTeam=synapseClient.createTeam(team);
  Project newProject=synapseClient.createEntity(project);
  org.sagebionetworks.repo.model.AccessControlList acl=synapseClient.getACL(newProject.getId());
  ResourceAccess toSet=new ResourceAccess();
  toSet.setPrincipalId(Long.parseLong(EXPORTER_SYNAPSE_USER_ID));
  toSet.setAccessType(ModelConstants.ENITY_ADMIN_ACCESS_PERMISSIONS);
  acl.getResourceAccess().add(toSet);
  ResourceAccess toSetUser=new ResourceAccess();
  toSetUser.setPrincipalId(userId);
  toSetUser.setAccessType(ModelConstants.ENITY_ADMIN_ACCESS_PERMISSIONS);
  acl.getResourceAccess().add(toSetUser);
  synapseClient.updateACL(acl);
  MembershipInvtnSubmission teamMemberInvitation=new MembershipInvtnSubmission();
  teamMemberInvitation.setInviteeId(userId.toString());
  teamMemberInvitation.setTeamId(newTeam.getId());
  synapseClient.createMembershipInvitation(teamMemberInvitation,null,null);
  synapseClient.setTeamMemberPermissions(newTeam.getId(),userId.toString(),true);
  String newTeamId=newTeam.getId();
  String newProjectId=newProject.getId();
  study.setSynapseProjectId(newProjectId);
  study.setSynapseDataAccessTeamId(Long.parseLong(newTeamId));
  updateStudy(study,false);
  return study;
}
Program: 25722
Project: 25722
Buggy source:
/** 
 * Gets validation status and messages for the given upload ID. 
 */
public Result getValidationStatus(String uploadId) throws JsonProcessingException {
  UserSession session=getAuthenticatedAndConsentedSession();
  UploadValidationStatus validationStatus=uploadService.getUploadValidationStatus(uploadId);
  if (!session.getHealthCode().equals(validationStatus.getRecord().getHealthCode())) {
    throw new UnauthorizedException();
  }
  return ok(HealthDataRecord.PUBLIC_RECORD_WRITER.writeValueAsString(validationStatus));
}

Fixed version (ground truth):
/** 
 * Gets validation status and messages for the given upload ID. 
 */
public Result getValidationStatus(String uploadId) throws JsonProcessingException {
  UserSession session=getAuthenticatedAndConsentedSession();
  Upload upload=uploadService.getUpload(uploadId);
  if (!session.getHealthCode().equals(upload.getHealthCode())) {
    throw new UnauthorizedException();
  }
  UploadValidationStatus validationStatus=uploadService.getUploadValidationStatus(uploadId);
  return ok(HealthDataRecord.PUBLIC_RECORD_WRITER.writeValueAsString(validationStatus));
}
Program: 25723
Project: 25723
Buggy source:
@Before public void before(){
  controller.setUploadService(uploadService);
  controller.setHealthCodeDao(healthCodeDao);
  DynamoUpload2 upload=new DynamoUpload2();
  upload.setHealthCode("String_Node_Str");
  upload.setUploadId("String_Node_Str");
  doReturn(upload).when(uploadService).getUpload("String_Node_Str");
  doReturn(metrics).when(controller).getMetrics();
  doReturn("String_Node_Str").when(workerSession).getHealthCode();
  doReturn(new StudyIdentifierImpl("String_Node_Str")).when(workerSession).getStudyIdentifier();
  doReturn(true).when(workerSession).isInRole(Roles.WORKER);
  doReturn("String_Node_Str").when(consentedUserSession).getHealthCode();
  doReturn(new StudyIdentifierImpl("String_Node_Str")).when(consentedUserSession).getStudyIdentifier();
  doReturn(false).when(consentedUserSession).isInRole(Roles.WORKER);
  doReturn("String_Node_Str").when(healthCodeDao).getStudyIdentifier("String_Node_Str");
  doReturn("String_Node_Str").when(healthCodeDao).getStudyIdentifier("String_Node_Str");
}

Fixed version (ground truth):
@Before public void before(){
  controller.setUploadService(uploadService);
  controller.setHealthCodeDao(healthCodeDao);
  DynamoUpload2 upload=new DynamoUpload2();
  upload.setHealthCode("String_Node_Str");
  upload.setUploadId("String_Node_Str");
  doReturn(upload).when(uploadService).getUpload("String_Node_Str");
  doReturn(metrics).when(controller).getMetrics();
  doReturn("String_Node_Str").when(workerSession).getHealthCode();
  doReturn(new StudyIdentifierImpl("String_Node_Str")).when(workerSession).getStudyIdentifier();
  doReturn(true).when(workerSession).isInRole(Roles.WORKER);
  doReturn("String_Node_Str").when(consentedUserSession).getHealthCode();
  doReturn(new StudyIdentifierImpl("String_Node_Str")).when(consentedUserSession).getStudyIdentifier();
  doReturn(false).when(consentedUserSession).isInRole(Roles.WORKER);
  doReturn("String_Node_Str").when(otherUserSession).getHealthCode();
  doReturn("String_Node_Str").when(healthCodeDao).getStudyIdentifier("String_Node_Str");
  doReturn("String_Node_Str").when(healthCodeDao).getStudyIdentifier("String_Node_Str");
}
Program: 25724
Project: 25724
Buggy source:
/** 
 * Retrieve external IDs that match the ID and/or assignment filters. These records are returned in pages of pageSize  records. Each page is identified by the offsetKey of the last record of the immediately prior page. If that value is  null, there is not a further page of IDs to retrieve. More interestingly, you can retrieve the next available ID by asking for pageSize=1, assignmentFilter=FALSE.
 * @param studyId study of caller
 * @param offsetKey if it exists, the key that must be passed to the next call of getExternalIds() to move the cursor forward one  more page.
 * @param pageSize the number of records to return
 * @param idFilter a case-sensitive string that must be found in an external identifier to return it in the results
 * @param assignmentFilter an optional boolean (can be null). If TRUE, all records returned will be assigned. More usefully, if FALSE, will return unassigned external identifiers. 
 */
PagedResourceList<String> getExternalIds(StudyIdentifier studyId,String offsetKey,int pageSize,String idFilter,Boolean assignmentFilter);

Fixed version (ground truth):
/** 
 * Retrieve external IDs that match the ID and/or assignment filters. These records are returned in pages of pageSize  records. Each page is identified by the offsetKey of the last record of the immediately prior page. If that value is  null, there is not a further page of IDs to retrieve. More interestingly, you can retrieve the next available ID by asking for pageSize=1, assignmentFilter=FALSE.
 * @param studyId study of caller
 * @param offsetKey if it exists, the key that must be passed to the next call of getExternalIds() to move the cursor forward one  more page.
 * @param pageSize the number of records to return
 * @param idFilter a case-sensitive string that must be found in an external identifier to return it in the results
 * @param assignmentFilter an optional boolean (can be null). If TRUE, all records returned will be assigned. More usefully, if FALSE, will return unassigned external identifiers. 
 */
PagedResourceList<ExternalIdentifierInfo> getExternalIds(StudyIdentifier studyId,String offsetKey,int pageSize,String idFilter,Boolean assignmentFilter);
Program: 25725
Project: 25725
Buggy source:
@Override public void addExternalIds(StudyIdentifier studyId,List<String> externalIds){
  checkNotNull(studyId);
  checkNotNull(externalIds);
  if (externalIds.size() > addLimit) {
    throw new BadRequestException("String_Node_Str" + externalIds.size() + "String_Node_Str"+ addLimit);
  }
  for (  String id : externalIds) {
    if (StringUtils.isBlank(id)) {
      throw new BadRequestException("String_Node_Str");
    }
  }
  if (!externalIds.isEmpty()) {
    List<DynamoExternalIdentifier> idsToSave=externalIds.stream().map(id -> {
      return new DynamoExternalIdentifier(studyId,id);
    }
).filter(externalId -> {
      return mapper.load(externalId) == null;
    }
).collect(Collectors.toList());
    if (!idsToSave.isEmpty()) {
      List<FailedBatch> failures=mapper.batchSave(idsToSave);
      BridgeUtils.ifFailuresThrowException(failures);
    }
  }
}

Fixed version (ground truth):
@Override public void addExternalIds(StudyIdentifier studyId,List<String> externalIds){
  checkNotNull(studyId);
  checkNotNull(externalIds);
  if (externalIds.size() > addLimit) {
    throw new BadRequestException("String_Node_Str" + externalIds.size() + "String_Node_Str"+ addLimit);
  }
  List<DynamoExternalIdentifier> idsToSave=externalIds.stream().map(id -> {
    return new DynamoExternalIdentifier(studyId,id);
  }
).filter(externalId -> {
    return mapper.load(externalId) == null;
  }
).collect(Collectors.toList());
  if (!idsToSave.isEmpty()) {
    List<FailedBatch> failures=mapper.batchSave(idsToSave);
    BridgeUtils.ifFailuresThrowException(failures);
  }
}
Program: 25726
Project: 25726
Buggy source:
@Override public PagedResourceList<String> getExternalIds(StudyIdentifier studyId,String offsetKey,int pageSize,String idFilter,Boolean assignmentFilter){
  checkNotNull(studyId);
  if (pageSize < 1 || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  PaginatedQueryList<DynamoExternalIdentifier> list=mapper.query(DynamoExternalIdentifier.class,createGetQuery(studyId,offsetKey,pageSize,idFilter,assignmentFilter));
  int total=mapper.count(DynamoExternalIdentifier.class,createCountQuery(studyId,idFilter,assignmentFilter));
  List<String> identifiers=Lists.newArrayListWithCapacity(pageSize);
  Iterator<? extends ExternalIdentifier> iterator=list.iterator();
  while (iterator.hasNext() && identifiers.size() < pageSize) {
    identifiers.add(iterator.next().getIdentifier());
  }
  String lastKey=(iterator.hasNext()) ? last(identifiers) : null;
  PagedResourceList<String> resourceList=new PagedResourceList<String>(identifiers,null,pageSize,total).withLastKey(lastKey).withFilter(ID_FILTER,idFilter);
  if (assignmentFilter != null) {
    resourceList=resourceList.withFilter(ASSIGNMENT_FILTER,assignmentFilter.toString());
  }
  return resourceList;
}

Fixed version (ground truth):
@Override public PagedResourceList<ExternalIdentifierInfo> getExternalIds(StudyIdentifier studyId,String offsetKey,int pageSize,String idFilter,Boolean assignmentFilter){
  checkNotNull(studyId);
  if (pageSize < 1 || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  if (offsetKey != null && idFilter != null && idFilter.indexOf(offsetKey) != 0) {
    offsetKey=null;
  }
  PaginatedQueryList<DynamoExternalIdentifier> list=mapper.query(DynamoExternalIdentifier.class,createGetQuery(studyId,offsetKey,pageSize,idFilter,assignmentFilter));
  int total=mapper.count(DynamoExternalIdentifier.class,createCountQuery(studyId,idFilter,assignmentFilter));
  List<ExternalIdentifierInfo> identifiers=Lists.newArrayListWithCapacity(pageSize);
  Iterator<? extends ExternalIdentifier> iterator=list.iterator();
  while (iterator.hasNext() && identifiers.size() < pageSize) {
    ExternalIdentifier id=iterator.next();
    identifiers.add(createInfo(id,lockDuration));
  }
  String nextPageOffsetKey=(iterator.hasNext()) ? last(identifiers).getIdentifier() : null;
  PagedResourceList<ExternalIdentifierInfo> resourceList=new PagedResourceList<ExternalIdentifierInfo>(identifiers,null,pageSize,total).withOffsetKey(nextPageOffsetKey).withFilter(ID_FILTER,idFilter);
  if (assignmentFilter != null) {
    resourceList=resourceList.withFilter(ASSIGNMENT_FILTER,assignmentFilter.toString());
  }
  return resourceList;
}
Program: 25727
Project: 25727
Buggy source:
public Result getExternalIds(String offsetKey,String pageSizeString,String idFilter,String assignmentFilterString){
  UserSession session=getAuthenticatedSession(DEVELOPER);
  Study study=studyService.getStudy(session.getStudyIdentifier());
  Integer pageSize=(pageSizeString != null) ? Integer.parseInt(pageSizeString,10) : null;
  Boolean assignmentFilter=(assignmentFilterString != null) ? Boolean.valueOf(assignmentFilterString) : null;
  PagedResourceList<String> page=externalIdService.getExternalIds(study,offsetKey,pageSize,idFilter,assignmentFilter);
  return okResult(page);
}

Fixed version (ground truth):
public Result getExternalIds(String offsetKey,String pageSizeString,String idFilter,String assignmentFilterString){
  UserSession session=getAuthenticatedSession(DEVELOPER);
  Study study=studyService.getStudy(session.getStudyIdentifier());
  Integer pageSize=(pageSizeString != null) ? Integer.parseInt(pageSizeString,10) : null;
  Boolean assignmentFilter=(assignmentFilterString != null) ? Boolean.valueOf(assignmentFilterString) : null;
  PagedResourceList<ExternalIdentifierInfo> page=externalIdService.getExternalIds(study,offsetKey,pageSize,idFilter,assignmentFilter);
  return okResult(page);
}
Program: 25728
Project: 25728
Buggy source:
public void addExternalIds(Study study,List<String> externalIdentifiers){
  checkNotNull(study);
  checkNotNull(externalIdentifiers);
  externalIdDao.addExternalIds(study.getStudyIdentifier(),externalIdentifiers);
}

Fixed version (ground truth):
public void addExternalIds(Study study,List<String> externalIdentifiers){
  checkNotNull(study);
  checkNotNull(externalIdentifiers);
  Validate.entityThrowingException(validator,new ExternalIdsValidator.ExternalIdList(externalIdentifiers));
  externalIdDao.addExternalIds(study.getStudyIdentifier(),externalIdentifiers);
}
Program: 25729
Project: 25729
Buggy source:
public PagedResourceList<String> getExternalIds(Study study,String offsetKey,Integer pageSize,String idFilter,Boolean assignmentFilter){
  checkNotNull(study);
  if (pageSize == null) {
    pageSize=BridgeConstants.API_DEFAULT_PAGE_SIZE;
  }
  return externalIdDao.getExternalIds(study.getStudyIdentifier(),offsetKey,pageSize,idFilter,assignmentFilter);
}

Fixed version (ground truth):
public PagedResourceList<ExternalIdentifierInfo> getExternalIds(Study study,String offsetKey,Integer pageSize,String idFilter,Boolean assignmentFilter){
  checkNotNull(study);
  if (pageSize == null) {
    pageSize=BridgeConstants.API_DEFAULT_PAGE_SIZE;
  }
  return externalIdDao.getExternalIds(study.getStudyIdentifier(),offsetKey,pageSize,idFilter,assignmentFilter);
}
Program: 25730
Project: 25730
Buggy source:
private UserSession getSessionFromAccount(Study study,CriteriaContext context,Account account){
  final UserSession session=getSession(account);
  session.setAuthenticated(true);
  session.setEnvironment(config.getEnvironment());
  session.setStudyIdentifier(study.getStudyIdentifier());
  final User user=new User(account);
  user.setStudyKey(study.getIdentifier());
  final String healthCode=getHealthCode(study,account);
  user.setHealthCode(healthCode);
  ParticipantOptionsLookup lookup=optionsService.getOptions(healthCode);
  user.setSharingScope(lookup.getEnum(SHARING_SCOPE,SharingScope.class));
  user.setDataGroups(lookup.getStringSet(DATA_GROUPS));
  user.setLanguages(lookup.getOrderedStringSet(LANGUAGES));
  if (user.getLanguages().isEmpty() && !context.getLanguages().isEmpty()) {
    user.setLanguages(context.getLanguages());
    optionsService.setOrderedStringSet(study,healthCode,LANGUAGES,context.getLanguages());
  }
  CriteriaContext newContext=new CriteriaContext.Builder().withContext(context).withLanguages(user.getLanguages()).withHealthCode(user.getHealthCode()).withUserDataGroups(user.getDataGroups()).build();
  user.setConsentStatuses(consentService.getConsentStatuses(newContext));
  session.setUser(user);
  return session;
}

Fixed version (ground truth):
private UserSession getSessionFromAccount(Study study,CriteriaContext context,Account account){
  final UserSession session=getSession(account);
  session.setAuthenticated(true);
  session.setEnvironment(config.getEnvironment());
  session.setStudyIdentifier(study.getStudyIdentifier());
  final User user=new User(account);
  user.setStudyKey(study.getIdentifier());
  final String healthCode=getHealthCode(study,account);
  user.setHealthCode(healthCode);
  ParticipantOptionsLookup lookup=optionsService.getOptions(healthCode);
  user.setSharingScope(lookup.getEnum(SHARING_SCOPE,SharingScope.class));
  user.setDataGroups(lookup.getStringSet(DATA_GROUPS));
  user.setLanguages(lookup.getOrderedStringSet(LANGUAGES));
  if (user.getLanguages().isEmpty() && !context.getLanguages().isEmpty()) {
    user.setLanguages(context.getLanguages());
    optionsService.setOrderedStringSet(study,healthCode,LANGUAGES,context.getLanguages());
  }
  CriteriaContext newContext=new CriteriaContext.Builder().withContext(context).withLanguages(user.getLanguages()).withHealthCode(user.getHealthCode()).withUserDataGroups(user.getDataGroups()).build();
  user.setConsentStatuses(consentService.getConsentStatuses(newContext));
  session.setUser(user);
  repairConsents(account,session,newContext);
  return session;
}
Program: 25731
Project: 25731
Buggy source:
public UserSession signIn(Study study,CriteriaContext context,SignIn signIn) throws EntityNotFoundException {
  checkNotNull(study,"String_Node_Str");
  checkNotNull(signIn,"String_Node_Str");
  Validate.entityThrowingException(signInValidator,signIn);
  final String signInLock=study.getIdentifier() + RedisKey.SEPARATOR + signIn.getEmail();
  String lockId=null;
  try {
    lockId=lockDao.acquireLock(SignIn.class,signInLock,LOCK_EXPIRE_IN_SECONDS);
    Account account=accountDao.authenticate(study,signIn);
    UserSession session=getSessionFromAccount(study,context,account);
    repairConsents(account,session,context);
    cacheProvider.setUserSession(session);
    return session;
  }
  finally {
    if (lockId != null) {
      lockDao.releaseLock(SignIn.class,signInLock,lockId);
    }
  }
}

Fixed version (ground truth):
public UserSession signIn(Study study,CriteriaContext context,SignIn signIn) throws EntityNotFoundException {
  checkNotNull(study,"String_Node_Str");
  checkNotNull(signIn,"String_Node_Str");
  Validate.entityThrowingException(signInValidator,signIn);
  final String signInLock=study.getIdentifier() + RedisKey.SEPARATOR + signIn.getEmail();
  String lockId=null;
  try {
    lockId=lockDao.acquireLock(SignIn.class,signInLock,LOCK_EXPIRE_IN_SECONDS);
    Account account=accountDao.authenticate(study,signIn);
    UserSession session=getSessionFromAccount(study,context,account);
    cacheProvider.setUserSession(session);
    return session;
  }
  finally {
    if (lockId != null) {
      lockDao.releaseLock(SignIn.class,signInLock,lockId);
    }
  }
}
Program: 25733
Project: 25733
Buggy source:
@Test public void testWrite() throws Exception {
  MpowerVisualizationController controller=spy(new MpowerVisualizationController());
  doReturn(new UserSession()).when(controller).getAuthenticatedSession(Roles.WORKER);
  MpowerVisualizationService mockSvc=mock(MpowerVisualizationService.class);
  controller.setMpowerVisualizationService(mockSvc);
  String requestJsonText="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  Http.Context.current.set(TestUtils.mockPlayContextWithJson(requestJsonText));
  Result result=controller.writeVisualization();
  assertEquals(201,result.status());
  ArgumentCaptor<MpowerVisualization> vizCaptor=ArgumentCaptor.forClass(MpowerVisualization.class);
  verify(mockSvc).writeVisualization(vizCaptor.capture());
  MpowerVisualization viz=vizCaptor.getValue();
  assertEquals("String_Node_Str",viz.getVisualization().textValue());
  verify(controller).getAuthenticatedSession(Roles.WORKER);
}

Fixed version (ground truth):
@Test public void testWrite() throws Exception {
  MpowerVisualizationController controller=spy(new MpowerVisualizationController());
  doReturn(new UserSession()).when(controller).getAuthenticatedSession(Roles.WORKER);
  MpowerVisualizationService mockSvc=mock(MpowerVisualizationService.class);
  controller.setMpowerVisualizationService(mockSvc);
  String requestJsonText="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  TestUtils.mockPlayContextWithJson(requestJsonText);
  Result result=controller.writeVisualization();
  assertEquals(201,result.status());
  ArgumentCaptor<MpowerVisualization> vizCaptor=ArgumentCaptor.forClass(MpowerVisualization.class);
  verify(mockSvc).writeVisualization(vizCaptor.capture());
  MpowerVisualization viz=vizCaptor.getValue();
  assertEquals("String_Node_Str",viz.getVisualization().textValue());
  verify(controller).getAuthenticatedSession(Roles.WORKER);
}
Program: 25734
Project: 25734
Buggy source:
@Override public Account authenticate(Study study,SignIn signIn){
  checkNotNull(study);
  checkNotNull(signIn);
  checkArgument(isNotBlank(signIn.getUsername()));
  checkArgument(isNotBlank(signIn.getPassword()));
  try {
    Directory directory=client.getResource(study.getStormpathHref(),Directory.class);
    List<SubpopulationGuid> subpopGuids=getSubpopulationGuids(study);
    UsernamePasswordRequest request=new UsernamePasswordRequest(signIn.getUsername(),signIn.getPassword(),directory);
    AuthenticationResult result=application.authenticateAccount(request);
    if (result.getAccount() != null) {
      return new StormpathAccount(study.getStudyIdentifier(),subpopGuids,result.getAccount(),encryptors);
    }
  }
 catch (  ResourceException e) {
    rethrowResourceException(e,null);
  }
  throw new BridgeServiceException("String_Node_Str");
}

Fixed version (ground truth):
@Override public Account authenticate(Study study,SignIn signIn){
  checkNotNull(study);
  checkNotNull(signIn);
  checkArgument(isNotBlank(signIn.getUsername()));
  checkArgument(isNotBlank(signIn.getPassword()));
  try {
    Directory directory=client.getResource(study.getStormpathHref(),Directory.class);
    List<SubpopulationGuid> subpopGuids=getSubpopulationGuids(study);
    AuthenticationRequest<?,?> request=UsernamePasswordRequest.builder().setUsernameOrEmail(signIn.getUsername()).setPassword(signIn.getPassword()).inAccountStore(directory).build();
    AuthenticationResult result=application.authenticateAccount(request);
    if (result.getAccount() != null) {
      return new StormpathAccount(study.getStudyIdentifier(),subpopGuids,result.getAccount(),encryptors);
    }
  }
 catch (  ResourceException e) {
    rethrowResourceException(e,null);
  }
  throw new BridgeServiceException("String_Node_Str");
}
Program: 25735
Project: 25735
Buggy source:
@Override public void deleteDirectoryForStudy(Study study){
  checkNotNull(study,Validate.CANNOT_BE_NULL,"String_Node_Str");
  Application app=getApplication();
  checkNotNull(app);
  Directory existing=getDirectoryForStudy(study);
  AccountStoreMapping mapping=getApplicationMapping(existing.getHref(),app);
  if (mapping != null) {
    mapping.delete();
  }
 else {
    logger.warn("String_Node_Str" + app.getName() + "String_Node_Str"+ existing.getHref());
  }
  Directory directory=client.getResource(existing.getHref(),Directory.class);
  if (directory != null) {
    directory.delete();
  }
 else {
    logger.warn("String_Node_Str" + existing.getHref());
  }
}

Fixed version (ground truth):
@Override public void deleteDirectoryForStudy(Study study){
  checkNotNull(study,Validate.CANNOT_BE_NULL,"String_Node_Str");
  Application app=getApplication();
  checkNotNull(app);
  Directory existing=getDirectoryForStudy(study);
  ApplicationAccountStoreMapping mapping=getApplicationMapping(existing.getHref(),app);
  if (mapping != null) {
    mapping.delete();
  }
 else {
    logger.warn("String_Node_Str" + app.getName() + "String_Node_Str"+ existing.getHref());
  }
  Directory directory=client.getResource(existing.getHref(),Directory.class);
  if (directory != null) {
    directory.delete();
  }
 else {
    logger.warn("String_Node_Str" + existing.getHref());
  }
}
Program: 25736
Project: 25736
Buggy source:
private void adjustVerifyEmailPolicies(Study study,Directory directory){
  AccountCreationPolicy policy=directory.getAccountCreationPolicy();
  ModeledEmailTemplate template=policy.getAccountVerificationEmailTemplates().iterator().next();
  updateTemplate(study,template,study.getVerifyEmailTemplate(),"String_Node_Str");
  policy.setVerificationEmailStatus(EmailStatus.ENABLED);
  policy.setVerificationSuccessEmailStatus(EmailStatus.DISABLED);
  policy.setWelcomeEmailStatus(EmailStatus.DISABLED);
  policy.save();
}

Fixed version (ground truth):
private void adjustVerifyEmailPolicies(Study study,Directory directory){
  AccountCreationPolicy policy=directory.getAccountCreationPolicy();
  for (  ModeledEmailTemplate template : policy.getAccountVerificationEmailTemplates()) {
    updateTemplate(study,template,study.getVerifyEmailTemplate(),"String_Node_Str");
  }
  policy.setVerificationEmailStatus(EmailStatus.ENABLED);
  policy.setVerificationSuccessEmailStatus(EmailStatus.DISABLED);
  policy.setWelcomeEmailStatus(EmailStatus.DISABLED);
  policy.save();
}
Program: 25737
Project: 25737
Buggy source:
private static AccountStoreMapping getApplicationMapping(String href,Application app){
  for (  AccountStoreMapping mapping : app.getAccountStoreMappings(asmCriteria)) {
    if (mapping.getAccountStore().getHref().equals(href)) {
      return mapping;
    }
  }
  return null;
}

Fixed version (ground truth):
private static ApplicationAccountStoreMapping getApplicationMapping(String href,Application app){
  for (  ApplicationAccountStoreMapping mapping : app.getApplicationAccountStoreMappings(asmCriteria)) {
    if (mapping.getAccountStore().getHref().equals(href)) {
      return mapping;
    }
  }
  return null;
}
Program: 25738
Project: 25738
Buggy source:
@Override public String createDirectoryForStudy(Study study){
  checkNotNull(study);
  checkArgument(isNotBlank(study.getIdentifier()),Validate.CANNOT_BE_BLANK,"String_Node_Str");
  Application app=getApplication();
  checkNotNull(app);
  String dirName=createDirectoryName(study.getIdentifier());
  Directory directory=getDirectoryForStudy(study);
  if (directory == null) {
    directory=client.instantiate(Directory.class);
    directory.setName(dirName);
    directory=client.createDirectory(directory);
  }
  adjustPasswordPolicies(study,directory);
  adjustVerifyEmailPolicies(study,directory);
  AccountStoreMapping mapping=getApplicationMapping(directory.getHref(),app);
  if (mapping == null) {
    mapping=client.instantiate(AccountStoreMapping.class);
    mapping.setAccountStore(directory);
    mapping.setApplication(app);
    mapping.setDefaultAccountStore(Boolean.FALSE);
    mapping.setDefaultGroupStore(Boolean.FALSE);
    mapping.setListIndex(10);
    app.createAccountStoreMapping(mapping);
  }
  for (  Roles role : Roles.values()) {
    Group group=getGroup(directory,role);
    if (group == null) {
      group=client.instantiate(Group.class);
      group.setName(role.name().toLowerCase());
      directory.createGroup(group);
    }
  }
  return directory.getHref();
}

Fixed version (ground truth):
@Override public String createDirectoryForStudy(Study study){
  checkNotNull(study);
  checkArgument(isNotBlank(study.getIdentifier()),Validate.CANNOT_BE_BLANK,"String_Node_Str");
  Application app=getApplication();
  checkNotNull(app);
  String dirName=createDirectoryName(study.getIdentifier());
  Directory directory=getDirectoryForStudy(study);
  if (directory == null) {
    directory=client.instantiate(Directory.class);
    directory.setName(dirName);
    directory=client.createDirectory(directory);
  }
  adjustPasswordPolicies(study,directory);
  adjustVerifyEmailPolicies(study,directory);
  ApplicationAccountStoreMapping mapping=getApplicationMapping(directory.getHref(),app);
  if (mapping == null) {
    mapping=client.instantiate(ApplicationAccountStoreMapping.class);
    mapping.setAccountStore(directory);
    mapping.setApplication(app);
    mapping.setDefaultAccountStore(Boolean.FALSE);
    mapping.setDefaultGroupStore(Boolean.FALSE);
    mapping.setListIndex(10);
    app.createAccountStoreMapping(mapping);
  }
  for (  Roles role : Roles.values()) {
    Group group=getGroup(directory,role);
    if (group == null) {
      group=client.instantiate(Group.class);
      group.setName(role.name().toLowerCase());
      directory.createGroup(group);
    }
  }
  return directory.getHref();
}
Program: 25739
Project: 25739
Buggy source:
private void adjustPasswordPolicies(Study study,Directory directory){
  PasswordPolicy passwordPolicy=directory.getPasswordPolicy();
  ModeledEmailTemplate template=passwordPolicy.getResetEmailTemplates().iterator().next();
  updateTemplate(study,template,study.getResetPasswordTemplate(),"String_Node_Str");
  PasswordStrength strength=passwordPolicy.getStrength();
  strength.setMaxLength(org.sagebionetworks.bridge.models.studies.PasswordPolicy.FIXED_MAX_LENGTH);
  strength.setMinDiacritic(0);
  strength.setMinLength(study.getPasswordPolicy().getMinLength());
  strength.setMinNumeric(study.getPasswordPolicy().isNumericRequired() ? 1 : 0);
  strength.setMinSymbol(study.getPasswordPolicy().isSymbolRequired() ? 1 : 0);
  strength.setMinLowerCase(study.getPasswordPolicy().isLowerCaseRequired() ? 1 : 0);
  strength.setMinUpperCase(study.getPasswordPolicy().isUpperCaseRequired() ? 1 : 0);
  strength.save();
  passwordPolicy.setResetEmailStatus(EmailStatus.ENABLED);
  passwordPolicy.setResetSuccessEmailStatus(EmailStatus.DISABLED);
  passwordPolicy.save();
}

Fixed version (ground truth):
private void adjustPasswordPolicies(Study study,Directory directory){
  PasswordPolicy passwordPolicy=directory.getPasswordPolicy();
  for (  ModeledEmailTemplate template : passwordPolicy.getResetEmailTemplates()) {
    updateTemplate(study,template,study.getResetPasswordTemplate(),"String_Node_Str");
  }
  PasswordStrength strength=passwordPolicy.getStrength();
  strength.setMaxLength(org.sagebionetworks.bridge.models.studies.PasswordPolicy.FIXED_MAX_LENGTH);
  strength.setMinDiacritic(0);
  strength.setMinLength(study.getPasswordPolicy().getMinLength());
  strength.setMinNumeric(study.getPasswordPolicy().isNumericRequired() ? 1 : 0);
  strength.setMinSymbol(study.getPasswordPolicy().isSymbolRequired() ? 1 : 0);
  strength.setMinLowerCase(study.getPasswordPolicy().isLowerCaseRequired() ? 1 : 0);
  strength.setMinUpperCase(study.getPasswordPolicy().isUpperCaseRequired() ? 1 : 0);
  strength.save();
  passwordPolicy.setResetEmailStatus(EmailStatus.ENABLED);
  passwordPolicy.setResetSuccessEmailStatus(EmailStatus.DISABLED);
  passwordPolicy.save();
}
Program: 25740
Project: 25740
Buggy source:
private void validateRules(Errors errors,List<SurveyQuestion> questions){
  Set<String> alreadySeenIdentifiers=Sets.newHashSet();
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
    alreadySeenIdentifiers.add(question.getIdentifier());
  }
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (!alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
  }
}

Fixed version (ground truth):
private void validateRules(Errors errors,List<SurveyElement> elements){
  Set<String> alreadySeenIdentifiers=Sets.newHashSet();
  for (int i=0; i < elements.size(); i++) {
    SurveyElement element=elements.get(i);
    if (element instanceof SurveyQuestion) {
      for (      SurveyRule rule : ((SurveyQuestion)element).getConstraints().getRules()) {
        if (alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
          errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
          rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
          errors.popNestedPath();
        }
      }
    }
    alreadySeenIdentifiers.add(element.getIdentifier());
  }
  for (int i=0; i < elements.size(); i++) {
    SurveyElement element=elements.get(i);
    if (element instanceof SurveyQuestion) {
      for (      SurveyRule rule : ((SurveyQuestion)element).getConstraints().getRules()) {
        if (!alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
          errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
          rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
          errors.popNestedPath();
        }
      }
    }
  }
}
Program: 25741
Project: 25741
Buggy source:
@Override public void validate(Object object,Errors errors){
  Survey survey=(Survey)object;
  if (StringUtils.isBlank(survey.getName())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getIdentifier())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getStudyIdentifier())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getGuid())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  Set<String> foundIdentifiers=Sets.newHashSet();
  for (int i=0; i < survey.getElements().size(); i++) {
    SurveyElement element=survey.getElements().get(i);
    errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
    if (SURVEY_QUESTION_TYPE.equals(element.getType())) {
      doValidateQuestion((SurveyQuestion)element,errors);
    }
 else     if (SURVEY_INFO_SCREEN_TYPE.equals(element.getType())) {
      doValidateInfoScreen((SurveyInfoScreen)element,errors);
    }
    if (foundIdentifiers.contains(element.getIdentifier())) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    foundIdentifiers.add(element.getIdentifier());
    errors.popNestedPath();
  }
  if (!errors.hasErrors()) {
    List<SurveyQuestion> questions=survey.getUnmodifiableQuestionList();
    validateRules(errors,questions);
  }
}

Fixed version (ground truth):
@Override public void validate(Object object,Errors errors){
  Survey survey=(Survey)object;
  if (StringUtils.isBlank(survey.getName())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getIdentifier())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getStudyIdentifier())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  if (StringUtils.isBlank(survey.getGuid())) {
    errors.rejectValue("String_Node_Str","String_Node_Str");
  }
  Set<String> foundIdentifiers=Sets.newHashSet();
  for (int i=0; i < survey.getElements().size(); i++) {
    SurveyElement element=survey.getElements().get(i);
    errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
    if (SURVEY_QUESTION_TYPE.equals(element.getType())) {
      doValidateQuestion((SurveyQuestion)element,errors);
    }
 else     if (SURVEY_INFO_SCREEN_TYPE.equals(element.getType())) {
      doValidateInfoScreen((SurveyInfoScreen)element,errors);
    }
    if (foundIdentifiers.contains(element.getIdentifier())) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    foundIdentifiers.add(element.getIdentifier());
    errors.popNestedPath();
  }
  if (!errors.hasErrors()) {
    validateRules(errors,survey.getElements());
  }
}
Program: 25742
Project: 25742
Buggy source:
/** 
 * Copies all fields from the specified record into the builder. This is useful for updating records. 
 */
public HealthDataRecordBuilder copyOf(HealthDataRecord record){
  createdOn=record.getCreatedOn();
  data=record.getData();
  healthCode=record.getHealthCode();
  id=record.getId();
  metadata=record.getMetadata();
  schemaId=record.getSchemaId();
  schemaRevision=record.getSchemaRevision();
  studyId=record.getStudyId();
  uploadDate=record.getUploadDate();
  uploadId=record.getUploadId();
  userSharingScope=record.getUserSharingScope();
  version=record.getVersion();
  return this;
}

Fixed version (ground truth):
/** 
 * Copies all fields from the specified record into the builder. This is useful for updating records. 
 */
public HealthDataRecordBuilder copyOf(HealthDataRecord record){
  createdOn=record.getCreatedOn();
  data=record.getData();
  healthCode=record.getHealthCode();
  id=record.getId();
  metadata=record.getMetadata();
  schemaId=record.getSchemaId();
  schemaRevision=record.getSchemaRevision();
  studyId=record.getStudyId();
  uploadDate=record.getUploadDate();
  uploadId=record.getUploadId();
  userExternalId=record.getUserExternalId();
  userSharingScope=record.getUserSharingScope();
  version=record.getVersion();
  return this;
}
Program: 25745
Project: 25745
Buggy source:
private static HealthDataRecordBuilder createValidRecordBuilder(JsonNode dataNode){
  return new DynamoHealthDataRecord.Builder().withCreatedOn(DateTime.now().getMillis()).withData(dataNode).withHealthCode("String_Node_Str").withMetadata(BridgeObjectMapper.get().createObjectNode()).withSchemaId("String_Node_Str").withSchemaRevision(1).withStudyId("String_Node_Str").withUploadDate(LocalDate.now()).withUserSharingScope(ParticipantOption.SharingScope.SPONSORS_AND_PARTNERS);
}

Fixed version (ground truth):
private static HealthDataRecordBuilder createValidRecordBuilder(JsonNode dataNode){
  return new DynamoHealthDataRecord.Builder().withCreatedOn(ARBITRARY_TIMESTAMP).withData(dataNode).withHealthCode("String_Node_Str").withMetadata(BridgeObjectMapper.get().createObjectNode()).withSchemaId("String_Node_Str").withSchemaRevision(1).withStudyId("String_Node_Str").withUploadDate(LocalDate.parse("String_Node_Str")).withUploadId(TEST_UPLOAD_ID).withUserExternalId("String_Node_Str").withUserSharingScope(ParticipantOption.SharingScope.SPONSORS_AND_PARTNERS).withVersion(42L);
}
Program: 25746
Project: 25746
Buggy source:
public Result verifyEmail(String study){
  Study studyObj=studyService.getStudy(study);
  return ok(views.html.verifyEmail.render(ASSETS_HOST,ASSETS_BUILD,studyObj.getName(),studyObj.getSupportEmail()));
}

Fixed version (ground truth):
public Result verifyEmail(String study){
  Study studyObj=studyService.getStudy(study);
  return ok(views.html.verifyEmail.render(ASSETS_HOST,ASSETS_BUILD,StringEscapeUtils.escapeHtml4("String_Node_Str"),studyObj.getSupportEmail()));
}
Program: 25747
Project: 25747
Buggy source:
private void validateRules(Errors errors,List<SurveyQuestion> questions){
  Set<String> alreadySeenIdentifiers=Sets.newHashSet();
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i);
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
    alreadySeenIdentifiers.add(question.getIdentifier());
  }
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (!alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i);
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
  }
}

Fixed version (ground truth):
private void validateRules(Errors errors,List<SurveyQuestion> questions){
  Set<String> alreadySeenIdentifiers=Sets.newHashSet();
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
    alreadySeenIdentifiers.add(question.getIdentifier());
  }
  for (int i=0; i < questions.size(); i++) {
    SurveyQuestion question=questions.get(i);
    for (    SurveyRule rule : question.getConstraints().getRules()) {
      if (!alreadySeenIdentifiers.contains(rule.getSkipToTarget())) {
        errors.pushNestedPath("String_Node_Str" + i + "String_Node_Str");
        rejectField(errors,"String_Node_Str","String_Node_Str",rule.getSkipToTarget());
        errors.popNestedPath();
      }
    }
  }
}