Program: 89738
Project: 89738
Buggy source:
public void testProcessMissingRequest() throws Exception {
  Settings.set(ArchiveSettings.DIR_ARCREPOSITORY_BITPRESERVATION,TestInfo.WORKING_DIR.getAbsolutePath());
  Settings.set(ArchiveSettings.DIRS_ARCREPOSITORY_ADMIN,TestInfo.WORKING_DIR.getAbsolutePath());
  AdminData.getUpdateableInstance();
  MockFileBasedActiveBitPreservation mockabp=new MockFileBasedActiveBitPreservation();
  MockHttpServletRequest request=new MockHttpServletRequest();
  String replicaID1="String_Node_Str";
  String replicaID2="String_Node_Str";
  String filename1="String_Node_Str";
  String filename2="String_Node_Str";
  Locale defaultLocale=new Locale("String_Node_Str");
  Map<String,String[]> args=new HashMap<String,String[]>();
  args.put(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID1).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1});
  request.setupAddParameter(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID1).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1});
  args.put(GET_INFO_COMMAND,new String[]{filename1});
  request.setupAddParameter(GET_INFO_COMMAND,new String[]{filename1});
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupGetParameterMap(args);
  request.setupGetParameterNames(new Vector<String>(args.keySet()).elements());
  Map<String,PreservationState> status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",1,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",1,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",null,status.get(filename1));
  mockabp.calls.clear();
  request=new MockHttpServletRequest();
  args.clear();
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupGetParameterMap(args);
  status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",0,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",0,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",0,status.size());
  mockabp.calls.clear();
  request=new MockHttpServletRequest();
  args.clear();
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID2).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID2).getName()});
  request.setupAddParameter(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID2).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1,Replica.getReplicaFromId(replicaID2).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1});
  args.put(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID2).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1,Replica.getReplicaFromId(replicaID2).getName() + Constants.STRING_FILENAME_SEPARATOR + filename1});
  request.setupAddParameter(GET_INFO_COMMAND,new String[]{filename1,filename2,filename1});
  args.put(GET_INFO_COMMAND,new String[]{filename1,filename2,filename1});
  request.setupGetParameterMap(args);
  status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",2,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",3,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",2,status.size());
  assertEquals("String_Node_Str",null,status.get(filename1));
  assertEquals("String_Node_Str",null,status.get(filename2));
  CollectionAsserts.assertIteratorEquals("String_Node_Str",Arrays.asList(new String[]{filename1 + "String_Node_Str" + replicaID2,filename1 + "String_Node_Str" + replicaID2}).iterator(),mockabp.calls.get(ADD_METHOD).iterator());
  CollectionAsserts.assertIteratorEquals("String_Node_Str",Arrays.asList(new String[]{filename1,filename2,filename1}).iterator(),mockabp.calls.get(GET_INFO_METHOD).iterator());
}

Fixed version (ground truth):
public void testProcessMissingRequest() throws Exception {
  Settings.set(ArchiveSettings.DIR_ARCREPOSITORY_BITPRESERVATION,TestInfo.WORKING_DIR.getAbsolutePath());
  Settings.set(ArchiveSettings.DIRS_ARCREPOSITORY_ADMIN,TestInfo.WORKING_DIR.getAbsolutePath());
  AdminData.getUpdateableInstance();
  MockFileBasedActiveBitPreservation mockabp=new MockFileBasedActiveBitPreservation();
  MockHttpServletRequest request=new MockHttpServletRequest();
  String replicaID1="String_Node_Str";
  String replicaID2="String_Node_Str";
  String filename1="String_Node_Str";
  String filename2="String_Node_Str";
  Locale defaultLocale=new Locale("String_Node_Str");
  Map<String,String[]> args=new HashMap<String,String[]>();
  args.put(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID1).getName() + STRING_FILENAME_SEPARATOR + filename1});
  request.setupAddParameter(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID1).getName() + STRING_FILENAME_SEPARATOR + filename1});
  args.put(GET_INFO_COMMAND,new String[]{filename1});
  request.setupAddParameter(GET_INFO_COMMAND,new String[]{filename1});
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupGetParameterMap(args);
  request.setupGetParameterNames(new Vector<String>(args.keySet()).elements());
  Map<String,PreservationState> status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",1,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",1,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",null,status.get(filename1));
  mockabp.calls.clear();
  request=new MockHttpServletRequest();
  args.clear();
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID1).getName()});
  request.setupGetParameterMap(args);
  status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",0,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",0,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",0,status.size());
  mockabp.calls.clear();
  request=new MockHttpServletRequest();
  args.clear();
  args.put(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID2).getName()});
  request.setupAddParameter(BITARCHIVE_NAME_PARAM,new String[]{Replica.getReplicaFromId(replicaID2).getName()});
  request.setupAddParameter(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID2).getName() + STRING_FILENAME_SEPARATOR + filename1,Replica.getReplicaFromId(replicaID2).getName() + STRING_FILENAME_SEPARATOR + filename1});
  args.put(ADD_COMMAND,new String[]{Replica.getReplicaFromId(replicaID2).getName() + STRING_FILENAME_SEPARATOR + filename1,Replica.getReplicaFromId(replicaID2).getName() + STRING_FILENAME_SEPARATOR + filename1});
  request.setupAddParameter(GET_INFO_COMMAND,new String[]{filename1,filename2,filename1});
  args.put(GET_INFO_COMMAND,new String[]{filename1,filename2,filename1});
  request.setupGetParameterMap(args);
  status=BitpreserveFileState.processMissingRequest(WebinterfaceTestCase.getDummyPageContext(defaultLocale,request),new StringBuilder());
  assertEquals("String_Node_Str",2,mockabp.getCallCount(ADD_METHOD));
  assertEquals("String_Node_Str",3,mockabp.getCallCount(GET_INFO_METHOD));
  assertEquals("String_Node_Str",2,status.size());
  assertEquals("String_Node_Str",null,status.get(filename1));
  assertEquals("String_Node_Str",null,status.get(filename2));
  CollectionAsserts.assertIteratorEquals("String_Node_Str",Arrays.asList(new String[]{filename1 + "String_Node_Str" + replicaID2,filename1 + "String_Node_Str" + replicaID2}).iterator(),mockabp.calls.get(ADD_METHOD).iterator());
  CollectionAsserts.assertIteratorEquals("String_Node_Str",Arrays.asList(new String[]{filename1,filename2,filename1}).iterator(),mockabp.calls.get(GET_INFO_METHOD).iterator());
}