Program: 4787
Project: 4787
Buggy source:
@Test public void testWorkflowForkApp() throws Exception {
  File directory=tmpFolder.newFolder();
  Map<String,String> runtimeArgs=new HashMap<>();
  File firstFile=new File(directory,"String_Node_Str");
  File firstDoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",firstFile.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",firstDoneFile.getAbsolutePath());
  File branch1File=new File(directory,"String_Node_Str");
  File branch1DoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",branch1File.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",branch1DoneFile.getAbsolutePath());
  File branch2File=new File(directory,"String_Node_Str");
  File branch2DoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",branch2File.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",branch2DoneFile.getAbsolutePath());
  HttpResponse response=deploy(WorkflowAppWithFork.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithFork.class.getSimpleName(),ProgramType.WORKFLOW,WorkflowAppWithFork.WorkflowWithFork.class.getSimpleName());
  setAndTestRuntimeArgs(programId,runtimeArgs);
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  String runId=getRunIdOfRunningProgram(programId);
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  stopProgram(programId);
  verifyProgramRuns(programId,"String_Node_Str");
  Assert.assertTrue(firstFile.delete());
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  String newRunId=getRunIdOfRunningProgram(programId);
  Assert.assertTrue(String.format("String_Node_Str" + "String_Node_Str",runId,newRunId),!runId.equals(newRunId));
  runId=newRunId;
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  Assert.assertTrue(firstDoneFile.createNewFile());
  verifyFileExists(Lists.newArrayList(branch1File,branch2File));
  verifyRunningProgramCount(programId,runId,2);
  stopProgram(programId,200);
  waitState(programId,ProgramStatus.STOPPED.name());
  response=getWorkflowCurrentStatus(programId,runId);
  Assert.assertEquals(404,response.getStatusLine().getStatusCode());
  verifyProgramRuns(programId,"String_Node_Str",1);
  Assert.assertTrue(firstFile.delete());
  Assert.assertTrue(firstDoneFile.delete());
  Assert.assertTrue(branch1File.delete());
  Assert.assertTrue(branch2File.delete());
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  runId=getRunIdOfRunningProgram(programId);
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  Assert.assertTrue(firstDoneFile.createNewFile());
  verifyFileExists(Lists.newArrayList(branch1File,branch2File));
  verifyRunningProgramCount(programId,runId,2);
  Assert.assertTrue(branch1DoneFile.createNewFile());
  Assert.assertTrue(branch2DoneFile.createNewFile());
  verifyProgramRuns(programId,"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testWorkflowForkApp() throws Exception {
  File directory=tmpFolder.newFolder();
  Map<String,String> runtimeArgs=new HashMap<>();
  File firstFile=new File(directory,"String_Node_Str");
  File firstDoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",firstFile.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",firstDoneFile.getAbsolutePath());
  File branch1File=new File(directory,"String_Node_Str");
  File branch1DoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",branch1File.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",branch1DoneFile.getAbsolutePath());
  File branch2File=new File(directory,"String_Node_Str");
  File branch2DoneFile=new File(directory,"String_Node_Str");
  runtimeArgs.put("String_Node_Str",branch2File.getAbsolutePath());
  runtimeArgs.put("String_Node_Str",branch2DoneFile.getAbsolutePath());
  HttpResponse response=deploy(WorkflowAppWithFork.class,Constants.Gateway.API_VERSION_3_TOKEN,TEST_NAMESPACE2);
  Assert.assertEquals(200,response.getStatusLine().getStatusCode());
  Id.Program programId=Id.Program.from(TEST_NAMESPACE2,WorkflowAppWithFork.class.getSimpleName(),ProgramType.WORKFLOW,WorkflowAppWithFork.WorkflowWithFork.class.getSimpleName());
  setAndTestRuntimeArgs(programId,runtimeArgs);
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  String runId=getRunIdOfRunningProgram(programId);
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  stopProgram(programId);
  verifyProgramRuns(programId,ProgramRunStatus.KILLED);
  Assert.assertTrue(firstFile.delete());
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  String newRunId=getRunIdOfRunningProgram(programId);
  Assert.assertTrue(String.format("String_Node_Str" + "String_Node_Str",runId,newRunId),!runId.equals(newRunId));
  runId=newRunId;
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  Assert.assertTrue(firstDoneFile.createNewFile());
  verifyFileExists(Lists.newArrayList(branch1File,branch2File));
  verifyRunningProgramCount(programId,runId,2);
  stopProgram(programId,200);
  waitState(programId,ProgramStatus.STOPPED.name());
  response=getWorkflowCurrentStatus(programId,runId);
  Assert.assertEquals(404,response.getStatusLine().getStatusCode());
  verifyProgramRuns(programId,ProgramRunStatus.KILLED,1);
  Assert.assertTrue(firstFile.delete());
  Assert.assertTrue(firstDoneFile.delete());
  Assert.assertTrue(branch1File.delete());
  Assert.assertTrue(branch2File.delete());
  startProgram(programId);
  waitState(programId,ProgramStatus.RUNNING.name());
  runId=getRunIdOfRunningProgram(programId);
  verifyFileExists(Lists.newArrayList(firstFile));
  verifyRunningProgramCount(programId,runId,1);
  Assert.assertTrue(firstDoneFile.createNewFile());
  verifyFileExists(Lists.newArrayList(branch1File,branch2File));
  verifyRunningProgramCount(programId,runId,2);
  Assert.assertTrue(branch1DoneFile.createNewFile());
  Assert.assertTrue(branch2DoneFile.createNewFile());
  verifyProgramRuns(programId,ProgramRunStatus.COMPLETED);
}