nus-yam/ex-repair huggingface dataset:
Program: 25676
Project: 25676
Buggy source:
/** 
 * Request a token to be sent via a link in an email message, that can be used to start a session on the Bridge server.  The installed application should intercept this link in order to complete the transaction within the app, where the  returned session can be captured. If the link is not captured, it retrieves a test page on the Bridge server as  configured by default. That test page will complete the transaction and return a session token.
 */
public void requestEmailSignIn(SignIn signIn){
  requestChannelSignIn(EMAIL,EMAIL_SIGNIN_REQUEST,EMAIL_CACHE_KEY_FUNC,emailSignInRequestInMillis,signIn,true,this::getNextToken,(study,token) -> {
    String url=getEmailSignInURL(signIn.getEmail(),study.getIdentifier(),token);
    String shortUrl=getShortEmailSignInURL(signIn.getEmail(),study.getIdentifier(),token);
    BasicEmailProvider provider=new BasicEmailProvider.Builder().withEmailTemplate(study.getEmailSignInTemplate()).withStudy(study).withRecipientEmail(signIn.getEmail()).withToken(EMAIL_KEY,BridgeUtils.encodeURIComponent(signIn.getEmail())).withToken(TOKEN_KEY,token).withToken(OLD_URL_KEY,url).withToken(OLD_SHORT_URL_KEY,shortUrl).withToken(EMAIL_SIGNIN_URL_KEY,shortUrl).withExpirationPeriod(EMAIL_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS).build();
    sendMailService.sendEmail(provider);
  }
);
}

Fixed version (ground truth):
/** 
 * Request a token to be sent via a link in an email message, that can be used to start a session on the Bridge server.  The installed application should intercept this link in order to complete the transaction within the app, where the  returned session can be captured. If the link is not captured, it retrieves a test page on the Bridge server as  configured by default. That test page will complete the transaction and return a session token.
 */
public void requestEmailSignIn(SignIn signIn){
  requestChannelSignIn(EMAIL,EMAIL_SIGNIN_REQUEST,emailSignInRequestInMillis,signIn,true,this::getNextToken,(study,token) -> {
    String url=getEmailSignInURL(signIn.getEmail(),study.getIdentifier(),token);
    String shortUrl=getShortEmailSignInURL(signIn.getEmail(),study.getIdentifier(),token);
    BasicEmailProvider provider=new BasicEmailProvider.Builder().withEmailTemplate(study.getEmailSignInTemplate()).withStudy(study).withRecipientEmail(signIn.getEmail()).withToken(EMAIL_KEY,BridgeUtils.encodeURIComponent(signIn.getEmail())).withToken(TOKEN_KEY,token).withToken(OLD_URL_KEY,url).withToken(OLD_SHORT_URL_KEY,shortUrl).withToken(EMAIL_SIGNIN_URL_KEY,shortUrl).withExpirationPeriod(EMAIL_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS).build();
    sendMailService.sendEmail(provider);
  }
);
}
Program: 25677
Project: 25677
Buggy source:
private void requestChannelSignIn(ChannelType channelType,Validator validator,Function<SignIn,CacheKey> cacheKeySupplier,AtomicLong atomicLong,SignIn signIn,boolean shouldThrottle,Supplier<String> tokenSupplier,BiConsumer<Study,String> messageSender){
  long startTime=System.currentTimeMillis();
  Validate.entityThrowingException(validator,signIn);
  Study study=studyService.getStudy(signIn.getStudyId());
  if (channelType == EMAIL && !study.isEmailSignInEnabled()) {
    throw new UnauthorizedException("String_Node_Str" + study.getName());
  }
 else   if (channelType == PHONE && !study.isPhoneSignInEnabled()) {
    throw new UnauthorizedException("String_Node_Str" + study.getName());
  }
  Account account=accountDao.getAccount(signIn.getAccountId());
  if (account == null) {
    try {
      TimeUnit.MILLISECONDS.sleep(atomicLong.get());
    }
 catch (    InterruptedException e) {
    }
    return;
  }
  ThrottleRequestType throttleType=channelType == EMAIL ? ThrottleRequestType.EMAIL_SIGNIN : ThrottleRequestType.PHONE_SIGNIN;
  if (shouldThrottle && isRequestThrottled(throttleType,account.getId())) {
    return;
  }
  CacheKey cacheKey=cacheKeySupplier.apply(signIn);
  String token=cacheProvider.getObject(cacheKey,String.class);
  if (token == null) {
    token=tokenSupplier.get();
    cacheProvider.setObject(cacheKey,token,SIGNIN_EXPIRE_IN_SECONDS);
  }
  messageSender.accept(study,token);
  atomicLong.set(System.currentTimeMillis() - startTime);
}

Fixed version (ground truth):
private void requestChannelSignIn(ChannelType channelType,Validator validator,AtomicLong atomicLong,SignIn signIn,boolean shouldThrottle,Supplier<String> tokenSupplier,BiConsumer<Study,String> messageSender){
  long startTime=System.currentTimeMillis();
  Validate.entityThrowingException(validator,signIn);
  Study study=studyService.getStudy(signIn.getStudyId());
  if (channelType == EMAIL && !study.isEmailSignInEnabled()) {
    throw new UnauthorizedException("String_Node_Str" + study.getName());
  }
 else   if (channelType == PHONE && !study.isPhoneSignInEnabled()) {
    throw new UnauthorizedException("String_Node_Str" + study.getName());
  }
  Account account=accountDao.getAccount(signIn.getAccountId());
  if (account == null) {
    try {
      TimeUnit.MILLISECONDS.sleep(atomicLong.get());
    }
 catch (    InterruptedException e) {
    }
    return;
  }
  ThrottleRequestType throttleType=channelType == EMAIL ? ThrottleRequestType.EMAIL_SIGNIN : ThrottleRequestType.PHONE_SIGNIN;
  if (shouldThrottle && isRequestThrottled(throttleType,account.getId())) {
    return;
  }
  CacheKey cacheKey=null;
  if (channelType == EMAIL) {
    cacheKey=CacheKeys.emailSignInRequest(signIn);
  }
 else   if (channelType == PHONE) {
    cacheKey=CacheKeys.phoneSignInRequest(signIn);
  }
  String token=cacheProvider.getObject(cacheKey,String.class);
  if (token == null) {
    token=tokenSupplier.get();
    cacheProvider.setObject(cacheKey,token,SIGNIN_EXPIRE_IN_SECONDS);
  }
  messageSender.accept(study,token);
  atomicLong.set(System.currentTimeMillis() - startTime);
}
Program: 25678
Project: 25678
Buggy source:
private void sendPasswordResetRelatedSMS(Study study,Phone phone,boolean includePhoneSignIn,SmsTemplate template){
  String sptoken=getNextToken();
  CacheKey cacheKey=CacheKeys.passwordResetForPhone(sptoken,study.getIdentifier());
  cacheProvider.setObject(cacheKey,getPhoneString(phone),VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  String url=getShortResetPasswordURL(study,sptoken);
  SmsMessageProvider.Builder builder=new SmsMessageProvider.Builder();
  builder.withSmsTemplate(template);
  builder.withStudy(study);
  builder.withPhone(phone);
  builder.withToken(SPTOKEN_KEY,sptoken);
  builder.withToken(RESET_PASSWORD_URL_KEY,url);
  builder.withExpirationPeriod(RESET_PASSWORD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  if (includePhoneSignIn) {
    SignIn signIn=new SignIn.Builder().withPhone(phone).withStudy(study.getIdentifier()).build();
    requestChannelSignIn(PHONE,PHONE_SIGNIN_REQUEST,PHONE_CACHE_KEY_FUNC,phoneSignInRequestInMillis,signIn,false,this::getNextToken,(theStudy,token) -> {
      String formattedToken=token.substring(0,3) + "String_Node_Str" + token.substring(3,6);
      builder.withToken(TOKEN_KEY,formattedToken);
      builder.withExpirationPeriod(PHONE_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS);
    }
);
  }
  notificationsService.sendSmsMessage(builder.build());
}

Fixed version (ground truth):
private void sendPasswordResetRelatedSMS(Study study,Phone phone,boolean includePhoneSignIn,SmsTemplate template){
  String sptoken=getNextToken();
  CacheKey cacheKey=CacheKeys.passwordResetForPhone(sptoken,study.getIdentifier());
  cacheProvider.setObject(cacheKey,getPhoneString(phone),VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  String url=getShortResetPasswordURL(study,sptoken);
  SmsMessageProvider.Builder builder=new SmsMessageProvider.Builder();
  builder.withSmsTemplate(template);
  builder.withStudy(study);
  builder.withPhone(phone);
  builder.withToken(SPTOKEN_KEY,sptoken);
  builder.withToken(RESET_PASSWORD_URL_KEY,url);
  builder.withExpirationPeriod(RESET_PASSWORD_EXPIRATION_PERIOD,VERIFY_OR_RESET_EXPIRE_IN_SECONDS);
  if (includePhoneSignIn) {
    SignIn signIn=new SignIn.Builder().withPhone(phone).withStudy(study.getIdentifier()).build();
    requestChannelSignIn(PHONE,PHONE_SIGNIN_REQUEST,phoneSignInRequestInMillis,signIn,false,this::getNextToken,(theStudy,token) -> {
      String formattedToken=token.substring(0,3) + "String_Node_Str" + token.substring(3,6);
      builder.withToken(TOKEN_KEY,formattedToken);
      builder.withExpirationPeriod(PHONE_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS);
    }
);
  }
  notificationsService.sendSmsMessage(builder.build());
}
Program: 25679
Project: 25679
Buggy source:
/** 
 * Attempts to validate a sign in request using a token that was stored and then sent  via SMS or an email message. 
 * @return AccountId the accountId of the account if the sign in is successful.
 * @throws AuthenticationFailedException if the token is missing or invalid (not a successful sign in attempt).
 */
public AccountId channelSignIn(ChannelType channelType,CriteriaContext context,SignIn signIn,Validator validator){
  Validate.entityThrowingException(validator,signIn);
  CacheKey cacheKey=null;
  if (channelType == EMAIL) {
    cacheKey=EMAIL_CACHE_KEY_FUNC.apply(signIn);
  }
 else   if (channelType == PHONE) {
    cacheKey=PHONE_CACHE_KEY_FUNC.apply(signIn);
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  String storedToken=cacheProvider.getObject(cacheKey,String.class);
  if (storedToken == null || !storedToken.equals(signIn.getToken())) {
    throw new AuthenticationFailedException();
  }
  cacheProvider.removeObject(cacheKey);
  return signIn.getAccountId();
}

Fixed version (ground truth):
/** 
 * Attempts to validate a sign in request using a token that was stored and then sent  via SMS or an email message. 
 * @return AccountId the accountId of the account if the sign in is successful.
 * @throws AuthenticationFailedException if the token is missing or invalid (not a successful sign in attempt).
 */
public AccountId channelSignIn(ChannelType channelType,CriteriaContext context,SignIn signIn,Validator validator){
  Validate.entityThrowingException(validator,signIn);
  CacheKey cacheKey=null;
  if (channelType == EMAIL) {
    cacheKey=CacheKeys.emailSignInRequest(signIn);
  }
 else   if (channelType == PHONE) {
    cacheKey=CacheKeys.phoneSignInRequest(signIn);
  }
 else {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  String storedToken=cacheProvider.getObject(cacheKey,String.class);
  if (storedToken == null || !storedToken.equals(signIn.getToken())) {
    throw new AuthenticationFailedException();
  }
  cacheProvider.removeObject(cacheKey);
  return signIn.getAccountId();
}
Program: 25680
Project: 25680
Buggy source:
/** 
 * Request a token to be sent via SMS to the user, that can be used to start a session on the Bridge server.
 */
public void requestPhoneSignIn(SignIn signIn){
  requestChannelSignIn(PHONE,PHONE_SIGNIN_REQUEST,PHONE_CACHE_KEY_FUNC,phoneSignInRequestInMillis,signIn,true,this::getNextPhoneToken,(study,token) -> {
    String formattedToken=token.substring(0,3) + "String_Node_Str" + token.substring(3,6);
    SmsMessageProvider provider=new SmsMessageProvider.Builder().withStudy(study).withSmsTemplate(study.getPhoneSignInSmsTemplate()).withPhone(signIn.getPhone()).withExpirationPeriod(PHONE_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS).withToken(TOKEN_KEY,formattedToken).build();
    notificationsService.sendSmsMessage(provider);
  }
);
}

Fixed version (ground truth):
/** 
 * Request a token to be sent via SMS to the user, that can be used to start a session on the Bridge server.
 */
public void requestPhoneSignIn(SignIn signIn){
  requestChannelSignIn(PHONE,PHONE_SIGNIN_REQUEST,phoneSignInRequestInMillis,signIn,true,this::getNextPhoneToken,(study,token) -> {
    String formattedToken=token.substring(0,3) + "String_Node_Str" + token.substring(3,6);
    SmsMessageProvider provider=new SmsMessageProvider.Builder().withStudy(study).withSmsTemplate(study.getPhoneSignInSmsTemplate()).withPhone(signIn.getPhone()).withExpirationPeriod(PHONE_SIGNIN_EXPIRATION_PERIOD,SIGNIN_EXPIRE_IN_SECONDS).withToken(TOKEN_KEY,formattedToken).build();
    notificationsService.sendSmsMessage(provider);
  }
);
}
Program: 25682
Project: 25682
Buggy source:
@Before public void before(){
  DateTimeUtils.setCurrentMillisFixed(NOW.getMillis());
  BridgeConfig mockConfig=mock(BridgeConfig.class);
  when(mockConfig.get("String_Node_Str")).thenReturn(BridgeConfigFactory.getConfig().get("String_Node_Str"));
  when(mockConfig.getEnvironment()).thenReturn(Environment.UAT);
  controller=spy(new AuthenticationController());
  controller.setBridgeConfig(mockConfig);
  controller.setAuthenticationService(authenticationService);
  controller.setCacheProvider(cacheProvider);
  controller.setAccountWorkflowService(accountWorkflowService);
  userSession=new UserSession();
  userSession.setReauthToken(REAUTH_TOKEN);
  userSession.setSessionToken(TEST_SESSION_TOKEN);
  userSession.setParticipant(new StudyParticipant.Builder().withId(TEST_ACCOUNT_ID).build());
  userSession.setInternalSessionToken(TEST_INTERNAL_SESSION_ID);
  userSession.setStudyIdentifier(TEST_STUDY_ID);
  study=new DynamoStudy();
  study.setIdentifier(TEST_STUDY_ID_STRING);
  study.setDataGroups(TestConstants.USER_DATA_GROUPS);
  when(studyService.getStudy(TEST_STUDY_ID_STRING)).thenReturn(study);
  when(studyService.getStudy(TEST_STUDY_ID)).thenReturn(study);
  controller.setStudyService(studyService);
  doReturn(metrics).when(controller).getMetrics();
}

Fixed version (ground truth):
@Before public void before(){
  DateTimeUtils.setCurrentMillisFixed(NOW.getMillis());
  BridgeConfig mockConfig=mock(BridgeConfig.class);
  when(mockConfig.get("String_Node_Str")).thenReturn(WEBSERVICES_URL);
  when(mockConfig.getEnvironment()).thenReturn(Environment.UAT);
  controller=spy(new AuthenticationController());
  controller.setBridgeConfig(mockConfig);
  controller.setAuthenticationService(authenticationService);
  controller.setCacheProvider(cacheProvider);
  controller.setAccountWorkflowService(accountWorkflowService);
  userSession=new UserSession();
  userSession.setReauthToken(REAUTH_TOKEN);
  userSession.setSessionToken(TEST_SESSION_TOKEN);
  userSession.setParticipant(new StudyParticipant.Builder().withId(TEST_ACCOUNT_ID).build());
  userSession.setInternalSessionToken(TEST_INTERNAL_SESSION_ID);
  userSession.setStudyIdentifier(TEST_STUDY_ID);
  study=new DynamoStudy();
  study.setIdentifier(TEST_STUDY_ID_STRING);
  study.setDataGroups(TestConstants.USER_DATA_GROUPS);
  when(studyService.getStudy(TEST_STUDY_ID_STRING)).thenReturn(study);
  when(studyService.getStudy(TEST_STUDY_ID)).thenReturn(study);
  controller.setStudyService(studyService);
  doReturn(metrics).when(controller).getMetrics();
}
Program: 25683
Project: 25683
Buggy source:
private void verifyCommonLoggingForSignIns() throws Exception {
  verifyMetrics();
  verify(response).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,TEST_SESSION_TOKEN,BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",BridgeConfigFactory.getConfig().get("String_Node_Str"),true,true);
  verify(cacheProvider).updateRequestInfo(requestInfoCaptor.capture());
  RequestInfo info=requestInfoCaptor.getValue();
  assertEquals(NOW.getMillis(),info.getSignedInOn().getMillis());
}

Fixed version (ground truth):
private void verifyCommonLoggingForSignIns() throws Exception {
  verifyMetrics();
  verify(response).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,TEST_SESSION_TOKEN,BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",WEBSERVICES_URL,true,true);
  verify(cacheProvider).updateRequestInfo(requestInfoCaptor.capture());
  RequestInfo info=requestInfoCaptor.getValue();
  assertEquals(NOW.getMillis(),info.getSignedInOn().getMillis());
}
Program: 25684
Project: 25684
Buggy source:
@Test public void signInOnLocalDoesNotSetCookieWithSSL() throws Exception {
  String json=TestUtils.createJson("String_Node_Str" + TEST_STUDY_ID_STRING + "String_Node_Str");
  response=mockPlayContextWithJson(json);
  when(controller.bridgeConfig.getEnvironment()).thenReturn(Environment.LOCAL);
  when(controller.bridgeConfig.get("String_Node_Str")).thenReturn("String_Node_Str");
  UserSession session=createSession(null,null);
  when(authenticationService.signIn(any(),any(),any())).thenReturn(session);
  controller.signIn();
  verify(response).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,TEST_SESSION_TOKEN,BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",BridgeConfigFactory.getConfig().get("String_Node_Str"),false,false);
}

Fixed version (ground truth):
@Test public void signInOnLocalDoesNotSetCookieWithSSL() throws Exception {
  String json=TestUtils.createJson("String_Node_Str" + TEST_STUDY_ID_STRING + "String_Node_Str");
  response=mockPlayContextWithJson(json);
  when(controller.bridgeConfig.getEnvironment()).thenReturn(Environment.LOCAL);
  UserSession session=createSession(null,null);
  when(authenticationService.signIn(any(),any(),any())).thenReturn(session);
  controller.signIn();
  verify(response).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,TEST_SESSION_TOKEN,BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",WEBSERVICES_URL,false,false);
}
Program: 25685
Project: 25685
Buggy source:
@Test public void ifClientSendsCookieRetrieveAndResetIt(){
  Http.Cookie mockCookie=mock(Http.Cookie.class);
  doReturn("String_Node_Str").when(mockCookie).value();
  Http.Request mockRequest=mock(Http.Request.class);
  doReturn(mockCookie).when(mockRequest).cookie(BridgeConstants.SESSION_TOKEN_HEADER);
  Http.Context context=mock(Http.Context.class);
  when(context.request()).thenReturn(mockRequest);
  Http.Response mockResponse=mock(Http.Response.class);
  when(context.response()).thenReturn(mockResponse);
  Http.Context.current.set(context);
  BaseController controller=new SchedulePlanController();
  controller.setBridgeConfig(BridgeConfigFactory.getConfig());
  String token=controller.getSessionToken();
  assertEquals("String_Node_Str",token);
  verify(mockResponse).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,"String_Node_Str",BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",BridgeConfigFactory.getConfig().get("String_Node_Str"),false,false);
}

Fixed version (ground truth):
@Test public void ifClientSendsCookieRetrieveAndResetIt(){
  Http.Cookie mockCookie=mock(Http.Cookie.class);
  doReturn("String_Node_Str").when(mockCookie).value();
  Http.Request mockRequest=mock(Http.Request.class);
  doReturn(mockCookie).when(mockRequest).cookie(BridgeConstants.SESSION_TOKEN_HEADER);
  Http.Context context=mock(Http.Context.class);
  when(context.request()).thenReturn(mockRequest);
  Http.Response mockResponse=mock(Http.Response.class);
  when(context.response()).thenReturn(mockResponse);
  Http.Context.current.set(context);
  BridgeConfig mockConfig=mock(BridgeConfig.class);
  when(mockConfig.get("String_Node_Str")).thenReturn(WEBSERVICE_URL);
  when(mockConfig.getEnvironment()).thenReturn(Environment.LOCAL);
  BaseController controller=new SchedulePlanController();
  controller.setBridgeConfig(mockConfig);
  String token=controller.getSessionToken();
  assertEquals("String_Node_Str",token);
  verify(mockResponse).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,"String_Node_Str",BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",WEBSERVICE_URL,false,false);
}
Program: 25686
Project: 25686
Buggy source:
@Test public void requireSslOnCookies(){
  Http.Cookie mockCookie=mock(Http.Cookie.class);
  doReturn("String_Node_Str").when(mockCookie).value();
  Http.Request mockRequest=mock(Http.Request.class);
  doReturn(mockCookie).when(mockRequest).cookie(BridgeConstants.SESSION_TOKEN_HEADER);
  Http.Context context=mock(Http.Context.class);
  when(context.request()).thenReturn(mockRequest);
  Http.Response mockResponse=mock(Http.Response.class);
  when(context.response()).thenReturn(mockResponse);
  Http.Context.current.set(context);
  BaseController controller=new SchedulePlanController();
  BridgeConfig mockConfig=mock(BridgeConfig.class);
  when(mockConfig.get("String_Node_Str")).thenReturn(BridgeConfigFactory.getConfig().get("String_Node_Str"));
  when(mockConfig.getEnvironment()).thenReturn(Environment.PROD);
  controller.setBridgeConfig(mockConfig);
  String token=controller.getSessionToken();
  assertEquals("String_Node_Str",token);
  verify(mockResponse).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,"String_Node_Str",BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",BridgeConfigFactory.getConfig().get("String_Node_Str"),true,true);
}

Fixed version (ground truth):
@Test public void requireSslOnCookies(){
  Http.Cookie mockCookie=mock(Http.Cookie.class);
  doReturn("String_Node_Str").when(mockCookie).value();
  Http.Request mockRequest=mock(Http.Request.class);
  doReturn(mockCookie).when(mockRequest).cookie(BridgeConstants.SESSION_TOKEN_HEADER);
  Http.Context context=mock(Http.Context.class);
  when(context.request()).thenReturn(mockRequest);
  Http.Response mockResponse=mock(Http.Response.class);
  when(context.response()).thenReturn(mockResponse);
  Http.Context.current.set(context);
  BaseController controller=new SchedulePlanController();
  BridgeConfig mockConfig=mock(BridgeConfig.class);
  when(mockConfig.get("String_Node_Str")).thenReturn(WEBSERVICE_URL);
  when(mockConfig.getEnvironment()).thenReturn(Environment.PROD);
  controller.setBridgeConfig(mockConfig);
  String token=controller.getSessionToken();
  assertEquals("String_Node_Str",token);
  verify(mockResponse).setCookie(BridgeConstants.SESSION_TOKEN_HEADER,"String_Node_Str",BridgeConstants.BRIDGE_SESSION_EXPIRE_IN_SECONDS,"String_Node_Str",WEBSERVICE_URL,true,true);
}
Program: 25687
Project: 25687
Buggy source:
public void verifyExternalIdentifier(ExternalIdentifier externalId) throws Exception {
  checkNotNull(externalId);
  if (isBlank(externalId.getIdentifier())) {
    throw new InvalidEntityException(externalId);
  }
  fphsDao.verifyExternalId(externalId);
}

Fixed version (ground truth):
public void verifyExternalIdentifier(ExternalIdentifier externalId) throws Exception {
  checkNotNull(externalId);
  if (isBlank(externalId.getIdentifier())) {
    throw new InvalidEntityException(externalId,"String_Node_Str");
  }
  fphsDao.verifyExternalId(externalId);
}
Program: 25688
Project: 25688
Buggy source:
public void registerExternalIdentifier(StudyIdentifier studyId,String healthCode,ExternalIdentifier externalId) throws Exception {
  checkNotNull(studyId);
  checkNotNull(healthCode);
  checkNotNull(externalId);
  if (isBlank(externalId.getIdentifier())) {
    throw new InvalidEntityException(externalId);
  }
  verifyExternalIdentifier(externalId);
  Set<String> dataGroups=optionsService.getOptions(healthCode).getStringSet(DATA_GROUPS);
  dataGroups.add("String_Node_Str");
  optionsService.setString(studyId,healthCode,EXTERNAL_IDENTIFIER,externalId.getIdentifier());
  optionsService.setStringSet(studyId,healthCode,DATA_GROUPS,dataGroups);
  fphsDao.registerExternalId(externalId);
}

Fixed version (ground truth):
public void registerExternalIdentifier(StudyIdentifier studyId,String healthCode,ExternalIdentifier externalId) throws Exception {
  checkNotNull(studyId);
  checkNotNull(healthCode);
  checkNotNull(externalId);
  if (isBlank(externalId.getIdentifier())) {
    throw new InvalidEntityException(externalId,"String_Node_Str");
  }
  verifyExternalIdentifier(externalId);
  Set<String> dataGroups=optionsService.getOptions(healthCode).getStringSet(DATA_GROUPS);
  dataGroups.add("String_Node_Str");
  optionsService.setString(studyId,healthCode,EXTERNAL_IDENTIFIER,externalId.getIdentifier());
  optionsService.setStringSet(studyId,healthCode,DATA_GROUPS,dataGroups);
  fphsDao.registerExternalId(externalId);
}
Program: 25689
Project: 25689
Buggy source:
@JsonCreator public EmailTemplate(@JsonProperty("String_Node_Str") String subject,@JsonProperty("String_Node_Str") String body,@JsonProperty("String_Node_Str") MimeType mimeType){
  this.subject=subject;
  this.mimeType=mimeType;
  this.body=body;
}

Fixed version (ground truth):
@JsonCreator public EmailTemplate(@JsonProperty("String_Node_Str") String subject,@JsonProperty("String_Node_Str") String body,@JsonProperty("String_Node_Str") MimeType mimeType){
  this.subject=subject;
  this.mimeType=(mimeType == null) ? MimeType.HTML : mimeType;
  this.body=body;
}
Program: 25690
Project: 25690
Buggy source:
@Test public void bridgeServiceExceptionCorrectlyReported() throws Throwable {
  Study study=new DynamoStudy();
  try {
    Validate.entityThrowingException(new StudyValidator(),study);
    fail("String_Node_Str");
  }
 catch (  InvalidEntityException e) {
    MethodInvocation invocation=mock(MethodInvocation.class);
    when(invocation.proceed()).thenThrow(e);
    Result result=(Result)interceptor.invoke(invocation);
    JsonNode node=new ObjectMapper().readTree(contentAsString(result));
    assertEquals(6,node.size());
    assertEquals("String_Node_Str",node.get("String_Node_Str").get("String_Node_Str").get(0).asText());
    assertEquals("String_Node_Str",node.get("String_Node_Str").asText());
    assertNotNull(node.get("String_Node_Str"));
    assertNotNull(node.get("String_Node_Str"));
    assertNotNull(node.get("String_Node_Str"));
    assertStatusCode(400,result,node);
  }
}

Fixed version (ground truth):
@Test public void bridgeServiceExceptionCorrectlyReported() throws Throwable {
  Study study=new DynamoStudy();
  try {
    Validate.entityThrowingException(new StudyValidator(),study);
    fail("String_Node_Str");
  }
 catch (  InvalidEntityException e) {
    MethodInvocation invocation=mock(MethodInvocation.class);
    when(invocation.proceed()).thenThrow(e);
    Result result=(Result)interceptor.invoke(invocation);
    JsonNode node=new ObjectMapper().readTree(contentAsString(result));
    assertEquals(5,node.size());
    assertEquals("String_Node_Str",node.get("String_Node_Str").get("String_Node_Str").get(0).asText());
    assertEquals("String_Node_Str",node.get("String_Node_Str").asText());
    assertNotNull(node.get("String_Node_Str"));
    assertNotNull(node.get("String_Node_Str"));
    assertStatusCode(400,result,node);
  }
}
Program: 25691
Project: 25691
Buggy source:
/** 
 * Get paged results of scheduled activities by an activity GUID.
 */
ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistoryV2(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,String offsetBy,int pageSize);

Fixed version (ground truth):
/** 
 * Get paged results of scheduled activities by an activity GUID.
 */
ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistoryV2(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,DateTimeZone timezone,String offsetBy,int pageSize);
Program: 25693
Project: 25693
Buggy source:
/** 
 * If the client data is being added or removed, or if it is different, then the activity is being  updated.
 */
protected boolean hasUpdatedClientData(ScheduledActivity schActivity,ScheduledActivity dbActivity){
  JsonNode schNode=(schActivity == null) ? null : schActivity.getClientData();
  JsonNode dbNode=(dbActivity == null) ? null : dbActivity.getClientData();
  return !Objects.equals(schNode,dbNode);
}

Fixed version (ground truth):
/** 
 * If the client data is being added or removed, or if it is different, then the activity is being updated.
 */
protected boolean hasUpdatedClientData(ScheduledActivity schActivity,ScheduledActivity dbActivity){
  JsonNode schNode=(schActivity == null) ? null : schActivity.getClientData();
  JsonNode dbNode=(dbActivity == null) ? null : dbActivity.getClientData();
  return !Objects.equals(schNode,dbNode);
}
Program: 25694
Project: 25694
Buggy source:
public ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistory(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,String offsetBy,int pageSize){
  checkArgument(isNotBlank(healthCode));
  checkArgument(isNotBlank(activityGuid));
  if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  if (scheduledOnStart == null && scheduledOnEnd == null) {
    scheduledOnEnd=DateTime.now().plusDays(MAX_EXPIRES_ON_DAYS);
    scheduledOnStart=scheduledOnEnd.minusWeeks(2);
  }
  if (scheduledOnStart == null || scheduledOnEnd == null) {
    throw new BadRequestException(EITHER_BOTH_DATES_OR_NEITHER);
  }
  return activityDao.getActivityHistoryV2(healthCode,activityGuid,scheduledOnStart,scheduledOnEnd,offsetBy,pageSize);
}

Fixed version (ground truth):
public ForwardCursorPagedResourceList<ScheduledActivity> getActivityHistory(String healthCode,String activityGuid,DateTime scheduledOnStart,DateTime scheduledOnEnd,String offsetBy,int pageSize){
  checkArgument(isNotBlank(healthCode));
  checkArgument(isNotBlank(activityGuid));
  if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
    throw new BadRequestException(PAGE_SIZE_ERROR);
  }
  if (scheduledOnStart == null && scheduledOnEnd == null) {
    scheduledOnEnd=DateTime.now().plusDays(MAX_EXPIRES_ON_DAYS);
    scheduledOnStart=scheduledOnEnd.minusWeeks(2);
  }
  if (scheduledOnStart == null || scheduledOnEnd == null) {
    throw new BadRequestException(EITHER_BOTH_DATES_OR_NEITHER);
  }
  DateTimeZone timezone=scheduledOnStart.getZone();
  if (!timezone.equals(scheduledOnEnd.getZone())) {
    throw new BadRequestException(AMBIGUOUS_TIMEZONE_ERROR);
  }
  return activityDao.getActivityHistoryV2(healthCode,activityGuid,scheduledOnStart,scheduledOnEnd,timezone,offsetBy,pageSize);
}
Program: 25696
Project: 25696
Buggy source:
@Test public void activityHistoryDefaultsDateRange(){
  DateTimeUtils.setCurrentMillisFixed(STARTS_ON.getMillis());
  service.getActivityHistory(HEALTH_CODE,ACTIVITY_GUID,null,null,null,40);
  verify(activityDao).getActivityHistoryV2(HEALTH_CODE,ACTIVITY_GUID,STARTS_ON.minusDays(9),STARTS_ON.plusDays(5),null,40);
  DateTimeUtils.setCurrentMillisSystem();
}

Fixed version (ground truth):
@Test public void activityHistoryDefaultsDateRange(){
  DateTimeUtils.setCurrentMillisFixed(STARTS_ON.getMillis());
  service.getActivityHistory(HEALTH_CODE,ACTIVITY_GUID,null,null,null,40);
  verify(activityDao).getActivityHistoryV2(HEALTH_CODE,ACTIVITY_GUID,STARTS_ON.minusDays(9),STARTS_ON.plusDays(5),TIME_ZONE,null,40);
  DateTimeUtils.setCurrentMillisSystem();
}
Program: 25697
Project: 25697
Buggy source:
public NumericalConstraints(){
  setSupportedHints(EnumSet.of(UIHint.NUMBERFIELD,UIHint.SLIDER));
}

Fixed version (ground truth):
public NumericalConstraints(){
  setSupportedHints(EnumSet.of(UIHint.NUMBERFIELD,UIHint.SLIDER,UIHint.SELECT));
}
Program: 25698
Project: 25698
Buggy source:
private void doValidateConstraintsType(Errors errors,UIHint hint,NumericalConstraints con){
  Double min=con.getMinValue();
  Double max=con.getMaxValue();
  if (min != null && max != null) {
    if (max < min) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    double diff=max - min;
    if (con.getStep() != null && con.getStep() > diff) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void doValidateConstraintsType(Errors errors,UIHint hint,NumericalConstraints con){
  Double min=con.getMinValue();
  Double max=con.getMaxValue();
  if (min != null && max != null) {
    if (max < min) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
    double diff=max - min;
    if (con.getStep() != null && con.getStep() > diff) {
      errors.rejectValue("String_Node_Str","String_Node_Str");
    }
  }
 else   if (UIHint.SELECT == hint || UIHint.SLIDER == hint) {
    if (min == null) {
      errors.rejectValue("String_Node_Str","String_Node_Str" + hint.name().toLowerCase());
    }
    if (max == null) {
      errors.rejectValue("String_Node_Str","String_Node_Str" + hint.name().toLowerCase());
    }
  }
}
Program: 25699
Project: 25699
Buggy source:
/** 
 * Try Redis providers to find one that is provisioned. Using this URL in the environment variables is the documented way to interact with these services.
 */
private String getRedisURL(){
}

Fixed version (ground truth):
/** 
 * Try Redis providers to find one that is provisioned. Using this URL in the environment variables is the documented way to interact with these services.
 */
private String getRedisURL(){
  for (  String provider : redisProviders) {
    if (System.getenv(provider) != null) {
      LOG.info("String_Node_Str" + provider);
      return System.getenv(provider);
    }
  }
  LOG.info("String_Node_Str");
  return bridgeConfig.getProperty("String_Node_Str");
}
Program: 25701
Project: 25701
Buggy source:
public Class<? extends BridgeEntity> getEntityClass(){
  return entity.getClass();
}

Fixed version (ground truth):
public Class<? extends BridgeEntity> getEntityClass(){
  return entity != null ? entity.getClass() : null;
}
Program: 25703
Project: 25703
Buggy source:
@Test public void resolveTaskRefWithoutSchema(){
  Activity activity=new Activity.Builder().withTask(TASK_ID).build();
  setupSchedulePlanServiceWithActivity(activity);
  List<ScheduledActivity> scheduledActivityList=scheduledActivityService.scheduleActivitiesForPlans(SCHEDULE_CONTEXT);
  assertEquals(scheduledActivityList.size(),2);
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    TaskReference taskRef=oneScheduledActivity.getActivity().getTask();
    assertEquals(TASK_ID,taskRef.getIdentifier());
    assertNull(taskRef.getSchema());
  }
  verify(mockCompoundActivityDefinitionService,never()).getCompoundActivityDefinition(any(),any());
  verify(mockSchemaService,never()).getLatestUploadSchemaRevisionForAppVersion(any(),any(),any());
  verify(mockSurveyService,never()).getSurveyMostRecentlyPublishedVersion(any(),any());
}

Fixed version (ground truth):
@Test public void resolveTaskRefWithoutSchema(){
  Activity activity=new Activity.Builder().withTask(TASK_ID).build();
  setupSchedulePlanServiceWithActivity(activity);
  List<ScheduledActivity> scheduledActivityList=scheduledActivityService.scheduleActivitiesForPlans(SCHEDULE_CONTEXT);
  verifyActivityListSizeAndLabels(scheduledActivityList);
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    TaskReference taskRef=oneScheduledActivity.getActivity().getTask();
    assertEquals(TASK_ID,taskRef.getIdentifier());
    assertNull(taskRef.getSchema());
  }
  verify(mockCompoundActivityDefinitionService,never()).getCompoundActivityDefinition(any(),any());
  verify(mockSchemaService,never()).getLatestUploadSchemaRevisionForAppVersion(any(),any(),any());
  verify(mockSurveyService,never()).getSurveyMostRecentlyPublishedVersion(any(),any());
}
Program: 25704
Project: 25704
Buggy source:
private static void verifySurveys(List<ScheduledActivity> scheduledActivityList){
  assertEquals(2,scheduledActivityList.size());
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    SurveyReference surveyRef=oneScheduledActivity.getActivity().getSurvey();
    assertEquals(SURVEY_ID,surveyRef.getIdentifier());
    assertEquals(SURVEY_GUID,surveyRef.getGuid());
    assertEquals(SURVEY_CREATED_ON_MILLIS,surveyRef.getCreatedOn().getMillis());
  }
}

Fixed version (ground truth):
private static void verifySurveys(List<ScheduledActivity> scheduledActivityList){
  verifyActivityListSizeAndLabels(scheduledActivityList);
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    SurveyReference surveyRef=oneScheduledActivity.getActivity().getSurvey();
    assertEquals(SURVEY_ID,surveyRef.getIdentifier());
    assertEquals(SURVEY_GUID,surveyRef.getGuid());
    assertEquals(SURVEY_CREATED_ON_MILLIS,surveyRef.getCreatedOn().getMillis());
  }
}
Program: 25705
Project: 25705
Buggy source:
private void setupSchedulePlanServiceWithActivity(Activity activity){
  SchedulePlan plan=SchedulePlan.create();
  Activity activityCopy=new Activity.Builder().withActivity(activity).build();
  ScheduledActivity scheduledActivity=ScheduledActivity.create();
  scheduledActivity.setActivity(activity);
  ScheduledActivity scheduledActivityCopy=ScheduledActivity.create();
  scheduledActivityCopy.setActivity(activityCopy);
  List<ScheduledActivity> scheduledActivityList=ImmutableList.of(scheduledActivity,scheduledActivityCopy);
  ActivityScheduler mockScheduler=mock(ActivityScheduler.class);
  when(mockScheduler.getScheduledActivities(plan,SCHEDULE_CONTEXT)).thenReturn(scheduledActivityList);
  Schedule mockSchedule=mock(Schedule.class);
  when(mockSchedule.getScheduler()).thenReturn(mockScheduler);
  SimpleScheduleStrategy strategy=new SimpleScheduleStrategy();
  strategy.setSchedule(mockSchedule);
  plan.setStrategy(strategy);
  when(mockSchedulePlanService.getSchedulePlans(ClientInfo.UNKNOWN_CLIENT,TestConstants.TEST_STUDY)).thenReturn(ImmutableList.of(plan));
}

Fixed version (ground truth):
private void setupSchedulePlanServiceWithActivity(Activity activity){
  SchedulePlan plan=SchedulePlan.create();
  Activity activityCopy1=new Activity.Builder().withActivity(activity).withLabel(ACTIVITY_LABEL_PREFIX + "String_Node_Str").build();
  Activity activityCopy2=new Activity.Builder().withActivity(activity).withLabel(ACTIVITY_LABEL_PREFIX + "String_Node_Str").build();
  ScheduledActivity scheduledActivity=ScheduledActivity.create();
  scheduledActivity.setActivity(activityCopy1);
  ScheduledActivity scheduledActivityCopy=ScheduledActivity.create();
  scheduledActivityCopy.setActivity(activityCopy2);
  List<ScheduledActivity> scheduledActivityList=ImmutableList.of(scheduledActivity,scheduledActivityCopy);
  ActivityScheduler mockScheduler=mock(ActivityScheduler.class);
  when(mockScheduler.getScheduledActivities(plan,SCHEDULE_CONTEXT)).thenReturn(scheduledActivityList);
  Schedule mockSchedule=mock(Schedule.class);
  when(mockSchedule.getScheduler()).thenReturn(mockScheduler);
  SimpleScheduleStrategy strategy=new SimpleScheduleStrategy();
  strategy.setSchedule(mockSchedule);
  plan.setStrategy(strategy);
  when(mockSchedulePlanService.getSchedulePlans(ClientInfo.UNKNOWN_CLIENT,TestConstants.TEST_STUDY)).thenReturn(ImmutableList.of(plan));
}
Program: 25706
Project: 25706
Buggy source:
private static void verifyCompoundActivities(List<ScheduledActivity> scheduledActivityList){
  assertEquals(2,scheduledActivityList.size());
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    CompoundActivity compoundActivity=oneScheduledActivity.getActivity().getCompoundActivity();
    assertEquals(COMPOUND_ACTIVITY_REF_TASK_ID,compoundActivity.getTaskIdentifier());
    assertEquals(1,compoundActivity.getSchemaList().size());
    assertEquals(SCHEMA_ID,compoundActivity.getSchemaList().get(0).getId());
    assertEquals(SCHEMA_REV,compoundActivity.getSchemaList().get(0).getRevision().intValue());
    assertEquals(1,compoundActivity.getSurveyList().size());
    assertEquals(SURVEY_ID,compoundActivity.getSurveyList().get(0).getIdentifier());
    assertEquals(SURVEY_GUID,compoundActivity.getSurveyList().get(0).getGuid());
    assertEquals(SURVEY_CREATED_ON_MILLIS,compoundActivity.getSurveyList().get(0).getCreatedOn().getMillis());
  }
}

Fixed version (ground truth):
private static void verifyCompoundActivities(List<ScheduledActivity> scheduledActivityList){
  verifyActivityListSizeAndLabels(scheduledActivityList);
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    CompoundActivity compoundActivity=oneScheduledActivity.getActivity().getCompoundActivity();
    assertEquals(COMPOUND_ACTIVITY_REF_TASK_ID,compoundActivity.getTaskIdentifier());
    assertEquals(1,compoundActivity.getSchemaList().size());
    assertEquals(SCHEMA_ID,compoundActivity.getSchemaList().get(0).getId());
    assertEquals(SCHEMA_REV,compoundActivity.getSchemaList().get(0).getRevision().intValue());
    assertEquals(1,compoundActivity.getSurveyList().size());
    assertEquals(SURVEY_ID,compoundActivity.getSurveyList().get(0).getIdentifier());
    assertEquals(SURVEY_GUID,compoundActivity.getSurveyList().get(0).getGuid());
    assertEquals(SURVEY_CREATED_ON_MILLIS,compoundActivity.getSurveyList().get(0).getCreatedOn().getMillis());
  }
}
Program: 25707
Project: 25707
Buggy source:
private static void verifySchemas(List<ScheduledActivity> scheduledActivityList){
  assertEquals(2,scheduledActivityList.size());
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    SchemaReference schemaRef=oneScheduledActivity.getActivity().getTask().getSchema();
    assertEquals(SCHEMA_ID,schemaRef.getId());
    assertEquals(SCHEMA_REV,schemaRef.getRevision().intValue());
  }
}

Fixed version (ground truth):
private static void verifySchemas(List<ScheduledActivity> scheduledActivityList){
  verifyActivityListSizeAndLabels(scheduledActivityList);
  for (  ScheduledActivity oneScheduledActivity : scheduledActivityList) {
    SchemaReference schemaRef=oneScheduledActivity.getActivity().getTask().getSchema();
    assertEquals(SCHEMA_ID,schemaRef.getId());
    assertEquals(SCHEMA_REV,schemaRef.getRevision().intValue());
  }
}
Program: 25708
Project: 25708
Buggy source:
@Before public void before() throws Exception {
  service=new ReportService();
  service.setReportDataDao(mockReportDataDao);
  service.setReportIndexDao(mockReportIndexDao);
  List<ReportData> list=Lists.newArrayList();
  list.add(createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str"));
  list.add(createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str"));
  results=new DateRangeResourceList<ReportData>(list,START_DATE,END_DATE);
  ReportIndex index=ReportIndex.create();
  index.setIdentifier(IDENTIFIER);
  indices=new ReportTypeResourceList<>(Lists.newArrayList(index),ReportType.STUDY);
}

Fixed version (ground truth):
@Before public void before() throws Exception {
  service=new ReportService();
  service.setReportDataDao(mockReportDataDao);
  service.setReportIndexDao(mockReportIndexDao);
  List<ReportData> list=Lists.newArrayList();
  list.add(createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str"));
  list.add(createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str"));
  results=new DateRangeResourceList<>(list,START_DATE,END_DATE);
  ReportIndex index=ReportIndex.create();
  index.setIdentifier(IDENTIFIER);
  indices=new ReportTypeResourceList<>(Lists.newArrayList(index),ReportType.STUDY);
}
Program: 25709
Project: 25709
Buggy source:
@Test public void deleteStudyReportRecord(){
  LocalDate startDate=LocalDate.parse("String_Node_Str").minusDays(45);
  LocalDate endDate=LocalDate.parse("String_Node_Str");
  DateRangeResourceList<ReportData> emptyResults=new DateRangeResourceList<ReportData>(Lists.newArrayList(),START_DATE,END_DATE);
  doReturn(emptyResults).when(mockReportDataDao).getReportData(STUDY_REPORT_DATA_KEY,startDate,endDate);
  DateTimeUtils.setCurrentMillisFixed(DateTime.parse("String_Node_Str").getMillis());
  try {
    service.deleteStudyReportRecord(TEST_STUDY,IDENTIFIER,DATE);
    verify(mockReportDataDao).deleteReportDataRecord(STUDY_REPORT_DATA_KEY,DATE);
    verify(mockReportDataDao).getReportData(STUDY_REPORT_DATA_KEY,startDate,endDate);
    verify(mockReportIndexDao).removeIndex(STUDY_REPORT_DATA_KEY);
  }
  finally {
    DateTimeUtils.setCurrentMillisSystem();
  }
}

Fixed version (ground truth):
@Test public void deleteStudyReportRecord(){
  LocalDate startDate=LocalDate.parse("String_Node_Str").minusDays(45);
  LocalDate endDate=LocalDate.parse("String_Node_Str");
  DateRangeResourceList<ReportData> emptyResults=new DateRangeResourceList<>(Lists.newArrayList(),START_DATE,END_DATE);
  doReturn(emptyResults).when(mockReportDataDao).getReportData(STUDY_REPORT_DATA_KEY,startDate,endDate);
  DateTimeUtils.setCurrentMillisFixed(DateTime.parse("String_Node_Str").getMillis());
  try {
    service.deleteStudyReportRecord(TEST_STUDY,IDENTIFIER,DATE);
    verify(mockReportDataDao).deleteReportDataRecord(STUDY_REPORT_DATA_KEY,DATE);
    verify(mockReportDataDao).getReportData(STUDY_REPORT_DATA_KEY,startDate,endDate);
    verify(mockReportIndexDao).removeIndex(STUDY_REPORT_DATA_KEY);
  }
  finally {
    DateTimeUtils.setCurrentMillisSystem();
  }
}
Program: 25710
Project: 25710
Buggy source:
@Test public void getReportIndex(){
  ReportDataKey key=new ReportDataKey.Builder().withIdentifier(IDENTIFIER).withReportType(ReportType.STUDY).withStudyIdentifier(TEST_STUDY).build();
  ReportIndex index=ReportIndex.create();
  index.setIdentifier(IDENTIFIER);
  index.setIdentifier(IDENTIFIER);
  doReturn(index).when(mockReportIndexDao).getIndex(key);
  ReportIndex retrievedKey=service.getReportIndex(key);
  assertEquals(key.getIdentifier(),retrievedKey.getIdentifier());
  verify(mockReportIndexDao).getIndex(key);
}

Fixed version (ground truth):
@Test public void getReportIndex(){
  ReportDataKey key=new ReportDataKey.Builder().withIdentifier(IDENTIFIER).withReportType(ReportType.STUDY).withStudyIdentifier(TEST_STUDY).build();
  ReportIndex index=ReportIndex.create();
  index.setIdentifier(IDENTIFIER);
  doReturn(index).when(mockReportIndexDao).getIndex(key);
  ReportIndex retrievedKey=service.getReportIndex(key);
  assertEquals(key.getIdentifier(),retrievedKey.getIdentifier());
  verify(mockReportIndexDao).getIndex(key);
}
Program: 25711
Project: 25711
Buggy source:
@Test public void saveParticipantReportData() throws Exception {
  ReportData someData=createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str");
  service.saveParticipantReport(TEST_STUDY,IDENTIFIER,HEALTH_CODE,someData);
  service.saveParticipantReport(TEST_STUDY,IDENTIFIER,HEALTH_CODE,someData);
  verify(mockReportDataDao,times(2)).saveReportData(reportDataCaptor.capture());
  ReportData retrieved=reportDataCaptor.getValue();
  assertEquals(someData,retrieved);
  assertEquals(PARTICIPANT_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().withHealthCode(HEALTH_CODE).withStudyIdentifier(TEST_STUDY).withReportType(ReportType.PARTICIPANT).withIdentifier(IDENTIFIER).build());
}

Fixed version (ground truth):
@Test public void saveParticipantReportData() throws Exception {
  ReportData someData=createReport(LocalDate.parse("String_Node_Str"),"String_Node_Str","String_Node_Str");
  service.saveParticipantReport(TEST_STUDY,IDENTIFIER,HEALTH_CODE,someData);
  verify(mockReportDataDao).saveReportData(reportDataCaptor.capture());
  ReportData retrieved=reportDataCaptor.getValue();
  assertEquals(someData,retrieved);
  assertEquals(PARTICIPANT_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().withHealthCode(HEALTH_CODE).withStudyIdentifier(TEST_STUDY).withReportType(ReportType.PARTICIPANT).withIdentifier(IDENTIFIER).build());
}