Program: 136639
Project: 136639
Buggy source:
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case1: between analysis and report
 */
@Test public void testSaveReportCase1() throws PersistenceException {
  ReportWriter createReportWriter=ElementWriterFactory.getInstance().createReportWriter();
  Analysis createAnalysis=AnalysisFactory.eINSTANCE.createAnalysis();
  AnalysisResult createAnalysisResult=AnalysisFactory.eINSTANCE.createAnalysisResult();
  createAnalysis.setResults(createAnalysisResult);
  createAnalysis.setName("String_Node_Str");
  TDQAnalysisItem createTDQAnalysisItem=PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
  createTDQAnalysisItem.setAnalysis(createAnalysis);
  Property createAnalysisProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createAnalysisProperty.setLabel("String_Node_Str");
  createTDQAnalysisItem.setProperty(createAnalysisProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem,Path.EMPTY,false);
  TdReport createTdReport=ReportsFactory.eINSTANCE.createTdReport();
  TDQReportItem createTDQReportItem=PropertiesFactory.eINSTANCE.createTDQReportItem();
  createTDQReportItem.setReport(createTdReport);
  Property createReportProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createReportProperty.setLabel("String_Node_Str");
  createTDQReportItem.setProperty(createReportProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQReportItem,Path.EMPTY,false);
  createTdReport.addAnalysis(createAnalysis);
  ReturnCode save=createReportWriter.save(createTDQReportItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createTdReport.getClientDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().get(0).getClient().size());
  createTdReport.removeAnalysis(createAnalysis);
  save=createReportWriter.save(createTDQReportItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createTdReport.getClientDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().size());
  Assert.assertEquals(0,createAnalysis.getSupplierDependency().get(0).getClient().size());
}

Fixed version (ground truth):
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case1: between analysis and report
 */
@Test public void testSaveReportCase1() throws PersistenceException {
  ReportWriter createReportWriter=ElementWriterFactory.getInstance().createReportWriter();
  Analysis createAnalysis=AnalysisFactory.eINSTANCE.createAnalysis();
  AnalysisResult createAnalysisResult=AnalysisFactory.eINSTANCE.createAnalysisResult();
  createAnalysis.setResults(createAnalysisResult);
  createAnalysis.setName("String_Node_Str");
  TDQAnalysisItem createTDQAnalysisItem=PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
  createTDQAnalysisItem.setAnalysis(createAnalysis);
  Property createAnalysisProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createAnalysisProperty.setLabel("String_Node_Str");
  createAnalysisProperty.setId(EcoreUtil.generateUUID());
  createTDQAnalysisItem.setProperty(createAnalysisProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem,Path.EMPTY,false);
  TdReport createTdReport=ReportsFactory.eINSTANCE.createTdReport();
  TDQReportItem createTDQReportItem=PropertiesFactory.eINSTANCE.createTDQReportItem();
  createTDQReportItem.setReport(createTdReport);
  Property createReportProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createReportProperty.setLabel("String_Node_Str");
  createTDQReportItem.setProperty(createReportProperty);
  createReportProperty.setId(EcoreUtil.generateUUID());
  ProxyRepositoryFactory.getInstance().create(createTDQReportItem,Path.EMPTY,false);
  createTdReport.addAnalysis(createAnalysis);
  ReturnCode save=createReportWriter.save(createTDQReportItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createTdReport.getClientDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().get(0).getClient().size());
  createTdReport.removeAnalysis(createAnalysis);
  save=createReportWriter.save(createTDQReportItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createTdReport.getClientDependency().size());
  Assert.assertEquals(1,createAnalysis.getSupplierDependency().size());
  Assert.assertEquals(0,createAnalysis.getSupplierDependency().get(0).getClient().size());
}