Program: 59599
Project: 59599
Buggy source:
@Test @Category(IntegrationTestDebug.class) public void singleFileCollabSucceeds(){
  HashMap<String,BoxCollaboration.Info> collabsMap=new HashMap<String,BoxCollaboration.Info>();
  BoxAPIConnection api=new BoxAPIConnection(TestConfig.getAccessToken());
  BoxFolder rootFolder=BoxFolder.getRootFolder(api);
  String fileName="String_Node_Str";
  String fileContent="String_Node_Str";
  byte[] fileBytes=fileContent.getBytes(StandardCharsets.UTF_8);
  InputStream uploadStream=new ByteArrayInputStream(fileBytes);
  BoxFile uploadedFile=rootFolder.uploadFile(uploadStream,fileName).getResource();
  String collaboratorLogin=TestConfig.getCollaborator();
  BoxCollaboration.Role originalRole=BoxCollaboration.Role.VIEWER;
  BoxCollaboration.Role newRole=BoxCollaboration.Role.EDITOR;
  BoxCollaboration.Info collabInfo=uploadedFile.collaborate(collaboratorLogin,originalRole);
  collabsMap.put(collabInfo.getID(),collabInfo);
  assertThat(collabInfo.getRole(),is(equalTo(originalRole)));
  BoxCollaboration collab=collabInfo.getResource();
  collabInfo.setRole(newRole);
  collab.updateInfo(collabInfo);
  assertThat(collabInfo.getRole(),is(equalTo(newRole)));
  BoxCollaboration remoteCollab=new BoxCollaboration(api,collab.getID());
  BoxCollaboration.Info remoteInfo=remoteCollab.getInfo();
  assertThat(remoteInfo.getRole(),is(equalTo(newRole)));
  assertThat(remoteInfo.getCreatedBy().getID(),is(collabInfo.getCreatedBy().getID()));
  BoxCollaboration.Info collab2Info=uploadedFile.collaborate("String_Node_Str",originalRole);
  collabsMap.put(collab2Info.getID(),collab2Info);
  BoxResourceIterable<BoxCollaboration.Info> collabs=uploadedFile.getAllFileCollaborations();
  Iterator<BoxCollaboration.Info> collabIterator=collabs.iterator();
  int numCollabs=0;
  while (collabIterator.hasNext() && (numCollabs < 5)) {
    numCollabs++;
    BoxCollaboration.Info fileCollabInfo=collabIterator.next();
    BoxCollaboration.Info localFileCollabInfor=collabsMap.get(fileCollabInfo.getID());
    assertEquals(fileCollabInfo.getID(),localFileCollabInfor.getID());
    assertEquals(fileCollabInfo.getCreatedBy().getID(),localFileCollabInfor.getCreatedBy().getID());
    assertEquals(fileCollabInfo.getCreatedBy().getName(),localFileCollabInfor.getCreatedBy().getName());
    assertEquals(fileCollabInfo.getAccessibleBy().getID(),localFileCollabInfor.getAccessibleBy().getID());
    assertEquals(fileCollabInfo.getAccessibleBy().getName(),localFileCollabInfor.getAccessibleBy().getName());
    assertEquals(fileCollabInfo.getRole(),localFileCollabInfor.getRole());
    assertEquals(fileCollabInfo.getStatus(),localFileCollabInfor.getStatus());
  }
  BoxCollaboration.Info colInfo=collabIterator.next();
  assertThat(colInfo.getID(),is(equalTo(collab2Info.getID())));
  assertEquals(colInfo.getID(),collab2Info.getID());
  assertEquals(colInfo.getID(),collabInfo.getID());
  assertEquals(collabs.iterator().hasNext(),true);
  colInfo=collabIterator.next();
  assertEquals(colInfo.getID(),collabInfo.getID());
  assertEquals(collabs.iterator().hasNext(),false);
  assertEquals(2,numCollabs);
  uploadedFile.delete();
}

Fixed version (ground truth):
@Test @Category(IntegrationTest.class) public void singleFileCollabSucceeds(){
  HashMap<String,BoxCollaboration.Info> collabsMap=new HashMap<String,BoxCollaboration.Info>();
  BoxAPIConnection api=new BoxAPIConnection(TestConfig.getAccessToken());
  BoxFolder rootFolder=BoxFolder.getRootFolder(api);
  String fileName="String_Node_Str";
  String fileContent="String_Node_Str";
  byte[] fileBytes=fileContent.getBytes(StandardCharsets.UTF_8);
  InputStream uploadStream=new ByteArrayInputStream(fileBytes);
  BoxFile uploadedFile=rootFolder.uploadFile(uploadStream,fileName).getResource();
  String collaboratorLogin=TestConfig.getCollaborator();
  BoxCollaboration.Role originalRole=BoxCollaboration.Role.VIEWER;
  BoxCollaboration.Role newRole=BoxCollaboration.Role.EDITOR;
  BoxCollaboration.Info collabInfo=uploadedFile.collaborate(collaboratorLogin,originalRole);
  collabsMap.put(collabInfo.getID(),collabInfo);
  assertThat(collabInfo.getRole(),is(equalTo(originalRole)));
  BoxCollaboration collab=collabInfo.getResource();
  collabInfo.setRole(newRole);
  collab.updateInfo(collabInfo);
  assertThat(collabInfo.getRole(),is(equalTo(newRole)));
  BoxCollaboration remoteCollab=new BoxCollaboration(api,collab.getID());
  BoxCollaboration.Info remoteInfo=remoteCollab.getInfo();
  assertThat(remoteInfo.getRole(),is(equalTo(newRole)));
  assertThat(remoteInfo.getCreatedBy().getID(),is(collabInfo.getCreatedBy().getID()));
  BoxCollaboration.Info collab2Info=uploadedFile.collaborate("String_Node_Str",originalRole);
  collabsMap.put(collab2Info.getID(),collab2Info);
  BoxResourceIterable<BoxCollaboration.Info> collabs=uploadedFile.getAllFileCollaborations();
  Iterator<BoxCollaboration.Info> collabIterator=collabs.iterator();
  int numCollabs=0;
  while (collabIterator.hasNext()) {
    numCollabs++;
    BoxCollaboration.Info fileCollabInfo=collabIterator.next();
    BoxCollaboration.Info localFileCollabInfor=collabsMap.get(fileCollabInfo.getID());
    assertEquals(fileCollabInfo.getID(),localFileCollabInfor.getID());
    assertEquals(fileCollabInfo.getCreatedBy().getID(),localFileCollabInfor.getCreatedBy().getID());
    assertEquals(fileCollabInfo.getCreatedBy().getName(),localFileCollabInfor.getCreatedBy().getName());
    assertEquals(fileCollabInfo.getAccessibleBy().getID(),localFileCollabInfor.getAccessibleBy().getID());
    assertEquals(fileCollabInfo.getAccessibleBy().getName(),localFileCollabInfor.getAccessibleBy().getName());
    assertEquals(fileCollabInfo.getRole(),localFileCollabInfor.getRole());
    assertEquals(fileCollabInfo.getStatus(),localFileCollabInfor.getStatus());
  }
  assertEquals(collabIterator.hasNext(),false);
  assertEquals(2,numCollabs);
  uploadedFile.delete();
}