Program: 125407
Project: 125407
Buggy source:
/** 
 * Test method for  {@link org.talend.repository.localprovider.model.LocalRepositoryFactory#unloadUnlockedResources()}.
 * @throws CoreException
 * @throws PersistenceException
 * @throws LoginException
 */
@Test public void testUnloadUnlockedResources() throws PersistenceException, CoreException, LoginException {
  repositoryFactory.logOnProject(sampleProject);
  Property property=PropertiesFactory.eINSTANCE.createProperty();
  property.setAuthor(sampleProject.getAuthor());
  property.setVersion(VersionUtils.DEFAULT_VERSION);
  property.setStatusCode("String_Node_Str");
  property.setLabel("String_Node_Str");
  final String nextId=repositoryFactory.getNextId();
  property.setId(nextId);
  ProcessItem processItem=PropertiesFactory.eINSTANCE.createProcessItem();
  processItem.setProperty(property);
  ProcessType process=TalendFileFactory.eINSTANCE.createProcessType();
  processItem.setProcess(process);
  Property property2=PropertiesFactory.eINSTANCE.createProperty();
  property2.setAuthor(sampleProject.getAuthor());
  property2.setVersion(VersionUtils.DEFAULT_VERSION);
  property2.setStatusCode("String_Node_Str");
  property2.setLabel("String_Node_Str");
  final String nextId2=repositoryFactory.getNextId();
  property2.setId(nextId2);
  ProcessItem processItem2=PropertiesFactory.eINSTANCE.createProcessItem();
  processItem2.setProperty(property2);
  ProcessType process2=TalendFileFactory.eINSTANCE.createProcessType();
  processItem2.setProcess(process2);
  repositoryFactory.create(sampleProject,processItem,new Path("String_Node_Str"),false);
  repositoryFactory.create(sampleProject,processItem2,new Path("String_Node_Str"),false);
  ProcessItem pItem=createTempProcessItem(repositoryFactory,"String_Node_Str");
  RoutineItem rItem=createTempRoutineItem(repositoryFactory,"String_Node_Str");
  assertNotNull(processItem.eResource());
  assertNotNull(processItem2.eResource());
  assertNotNull(pItem.eResource());
  assertNotNull(rItem.eResource());
  FolderItem parent=(FolderItem)pItem.getParent();
  ProxyRepositoryFactory.getInstance().setFullLogonFinished(true);
  repositoryFactory.unloadUnlockedResources();
  assertNull(processItem.eResource());
  assertNull(processItem2.eResource());
  assertNull(pItem.eResource());
  assertNull(rItem.eResource());
  assertNull(pItem.getParent());
  assertTrue(!parent.getChildren().contains(pItem));
  IRepositoryViewObject object1=repositoryFactory.getLastVersion(sampleProject,pItem.getProperty().getId());
  Property prop1=object1.getProperty();
  pItem=(ProcessItem)prop1.getItem();
  IRepositoryViewObject object2=repositoryFactory.getLastVersion(sampleProject,rItem.getProperty().getId());
  Property prop2=object2.getProperty();
  rItem=(RoutineItem)prop2.getItem();
  assertNotNull(pItem.eResource());
  assertNotNull(rItem.eResource());
  assertTrue(((NodeType)(pItem).getProcess().getNode().get(0)).getComponentVersion().equals("String_Node_Str"));
  String content=new String((rItem).getContent().getInnerContent());
  assertTrue(content.equals("String_Node_Str"));
  pItem.getState().setDeleted(true);
  repositoryFactory.unloadUnlockedResources();
  assertNotNull(pItem.getParent());
  assertTrue(((FolderItem)pItem.getParent()).getChildren().contains(pItem));
  pItem=(ProcessItem)repositoryFactory.getLastVersion(sampleProject,pItem.getProperty().getId()).getProperty().getItem();
  pItem.getState().setDeleted(false);
  pItem.getState().setLocked(true);
  repositoryFactory.unloadUnlockedResources();
  assertNotNull(pItem.getParent());
  assertTrue(((FolderItem)pItem.getParent()).getChildren().contains(pItem));
  assertNotNull(pItem.eResource());
  property=repositoryFactory.getUptodateProperty(sampleProject,property);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(property));
  property2=repositoryFactory.getUptodateProperty(sampleProject,property2);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(property2));
  prop1=repositoryFactory.getUptodateProperty(sampleProject,prop1);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(prop1));
  prop2=repositoryFactory.getUptodateProperty(sampleProject,prop2);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(prop2));
}

Fixed version (ground truth):
/** 
 * Test method for  {@link org.talend.repository.localprovider.model.LocalRepositoryFactory#unloadUnlockedResources()}.
 * @throws CoreException
 * @throws PersistenceException
 * @throws LoginException
 */
@Test public void testUnloadUnlockedResources() throws PersistenceException, CoreException, LoginException {
  repositoryFactory.logOnProject(sampleProject);
  Property property=PropertiesFactory.eINSTANCE.createProperty();
  property.setAuthor(sampleProject.getAuthor());
  property.setVersion(VersionUtils.DEFAULT_VERSION);
  property.setStatusCode("String_Node_Str");
  property.setLabel("String_Node_Str");
  final String nextId=repositoryFactory.getNextId();
  property.setId(nextId);
  ProcessItem processItem=PropertiesFactory.eINSTANCE.createProcessItem();
  processItem.setProperty(property);
  ProcessType process=TalendFileFactory.eINSTANCE.createProcessType();
  processItem.setProcess(process);
  Property property2=PropertiesFactory.eINSTANCE.createProperty();
  property2.setAuthor(sampleProject.getAuthor());
  property2.setVersion(VersionUtils.DEFAULT_VERSION);
  property2.setStatusCode("String_Node_Str");
  property2.setLabel("String_Node_Str");
  final String nextId2=repositoryFactory.getNextId();
  property2.setId(nextId2);
  ProcessItem processItem2=PropertiesFactory.eINSTANCE.createProcessItem();
  processItem2.setProperty(property2);
  ProcessType process2=TalendFileFactory.eINSTANCE.createProcessType();
  processItem2.setProcess(process2);
  repositoryFactory.create(sampleProject,processItem,new Path("String_Node_Str"),false);
  repositoryFactory.create(sampleProject,processItem2,new Path("String_Node_Str"),false);
  ProcessItem pItem=createTempProcessItem(repositoryFactory,"String_Node_Str");
  RoutineItem rItem=createTempRoutineItem(repositoryFactory,"String_Node_Str");
  assertNotNull(processItem.eResource());
  assertNotNull(processItem2.eResource());
  assertNotNull(pItem.eResource());
  assertNotNull(rItem.eResource());
  FolderItem parent=(FolderItem)pItem.getParent();
  ProxyRepositoryFactory.getInstance().setFullLogonFinished(true);
  repositoryFactory.unloadUnlockedResources();
  assertNull(processItem.eResource());
  assertNull(processItem2.eResource());
  assertNull(pItem.eResource());
  assertNull(rItem.eResource());
  assertNull(pItem.getParent());
  assertTrue(!parent.getChildren().contains(pItem));
  IRepositoryViewObject object1=repositoryFactory.getLastVersion(sampleProject,pItem.getProperty().getId());
  Property prop1=object1.getProperty();
  pItem=(ProcessItem)prop1.getItem();
  IRepositoryViewObject object2=repositoryFactory.getLastVersion(sampleProject,rItem.getProperty().getId());
  Property prop2=object2.getProperty();
  rItem=(RoutineItem)prop2.getItem();
  assertNotNull(pItem.eResource());
  assertNotNull(rItem.eResource());
  assertTrue(((NodeType)(pItem).getProcess().getNode().get(0)).getComponentVersion().equals("String_Node_Str"));
  String content=new String((rItem).getContent().getInnerContent());
  assertTrue(content.equals("String_Node_Str"));
  pItem.getState().setDeleted(true);
  repositoryFactory.unloadUnlockedResources();
  assertNotNull(pItem.getParent());
  assertTrue(((FolderItem)pItem.getParent()).getChildren().contains(pItem));
  pItem=(ProcessItem)repositoryFactory.getLastVersion(sampleProject,pItem.getProperty().getId()).getProperty().getItem();
  pItem.getState().setDeleted(false);
  pItem.getState().setLocked(true);
  repositoryFactory.unloadUnlockedResources();
  assertNotNull(pItem.getParent());
  assertTrue(((FolderItem)pItem.getParent()).getChildren().contains(pItem));
  assertNotNull(pItem.eResource());
  property=repositoryFactory.getUptodateProperty(sampleProject,property);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(property),false);
  property2=repositoryFactory.getUptodateProperty(sampleProject,property2);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(property2),false);
  prop1=repositoryFactory.getUptodateProperty(sampleProject,prop1);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(prop1),false);
  prop2=repositoryFactory.getUptodateProperty(sampleProject,prop2);
  repositoryFactory.deleteObjectPhysical(sampleProject,new RepositoryObject(prop2),false);
}