Program: 6957
Project: 6957
Buggy source:
@Test public void testWorkflowPauseResume() throws Exception {
  String pauseResumeWorkflowApp="String_Node_Str";
  String pauseResumeWorkflow="String_Node_Str";
  File firstSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File firstSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File forkedSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File forkedSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File anotherForkedSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File anotherForkedSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File lastSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File lastSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  HttpResponse response=deploy(PauseResumeWorklowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,pauseResumeWorkflowApp,ProgramType.WORKFLOW,pauseResumeWorkflow);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  runtimeArguments.put("String_Node_Str",firstSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",firstSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",forkedSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",forkedSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",anotherForkedSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",anotherForkedSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",lastSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",lastSimpleActionDoneFile.getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId,200);
  waitState(programId,"String_Node_Str");
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 1);
  String runId=historyRuns.get(0).getPid();
  while (!firstSimpleActionFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyRunningProgramCount(programId,runId,1);
  suspendWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  suspendWorkflow(programId,runId,409);
  firstSimpleActionDoneFile.createNewFile();
  verifyRunningProgramCount(programId,runId,0);
  verifyProgramRuns(programId,"String_Node_Str");
  resumeWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  resumeWorkflow(programId,runId,409);
  while (!(forkedSimpleActionFile.exists() && anotherForkedSimpleActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyRunningProgramCount(programId,runId,2);
  suspendWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  forkedSimpleActionDoneFile.createNewFile();
  anotherForkedSimpleActionDoneFile.createNewFile();
  verifyRunningProgramCount(programId,runId,0);
  verifyProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(!lastSimpleActionFile.exists());
  resumeWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  while (!lastSimpleActionFile.exists()) {
    TimeUnit.SECONDS.sleep(1);
  }
  verifyRunningProgramCount(programId,runId,1);
  lastSimpleActionDoneFile.createNewFile();
  verifyProgramRuns(programId,"String_Node_Str");
  waitState(programId,"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testWorkflowPauseResume() throws Exception {
  String pauseResumeWorkflowApp="String_Node_Str";
  String pauseResumeWorkflow="String_Node_Str";
  File firstSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File firstSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File forkedSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File forkedSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File anotherForkedSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File anotherForkedSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File lastSimpleActionFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  File lastSimpleActionDoneFile=new File(tmpFolder.newFolder() + "String_Node_Str");
  HttpResponse response=deploy(PauseResumeWorklowApp.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,pauseResumeWorkflowApp,ProgramType.WORKFLOW,pauseResumeWorkflow);
  Map<String,String> runtimeArguments=Maps.newHashMap();
  runtimeArguments.put("String_Node_Str",firstSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",firstSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",forkedSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",forkedSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",anotherForkedSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",anotherForkedSimpleActionDoneFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",lastSimpleActionFile.getAbsolutePath());
  runtimeArguments.put("String_Node_Str",lastSimpleActionDoneFile.getAbsolutePath());
  setAndTestRuntimeArgs(programId,runtimeArguments);
  startProgram(programId,200);
  waitState(programId,"String_Node_Str");
  List<RunRecord> historyRuns=getProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(historyRuns.size() == 1);
  String runId=historyRuns.get(0).getPid();
  while (!firstSimpleActionFile.exists()) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyRunningProgramCount(programId,runId,1);
  suspendWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  suspendWorkflow(programId,runId,409);
  firstSimpleActionDoneFile.createNewFile();
  verifyRunningProgramCount(programId,runId,0);
  verifyProgramRuns(programId,"String_Node_Str");
  resumeWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  resumeWorkflow(programId,runId,409);
  while (!(forkedSimpleActionFile.exists() && anotherForkedSimpleActionFile.exists())) {
    TimeUnit.MILLISECONDS.sleep(50);
  }
  verifyRunningProgramCount(programId,runId,2);
  suspendWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  verifyProgramRuns(programId,"String_Node_Str");
  forkedSimpleActionDoneFile.createNewFile();
  anotherForkedSimpleActionDoneFile.createNewFile();
  verifyRunningProgramCount(programId,runId,0);
  verifyProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(!lastSimpleActionFile.exists());
  resumeWorkflow(programId,runId,200);
  waitState(programId,"String_Node_Str");
  while (!lastSimpleActionFile.exists()) {
    TimeUnit.SECONDS.sleep(1);
  }
  verifyRunningProgramCount(programId,runId,1);
  lastSimpleActionDoneFile.createNewFile();
  verifyProgramRuns(programId,"String_Node_Str");
  waitState(programId,"String_Node_Str");
  suspendWorkflow(programId,runId,404);
  resumeWorkflow(programId,runId,404);
}