Program: 136640
Project: 136640
Buggy source:
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case1: between UDI and analysis
 */
@Test public void testSaveAnalysisCase1() throws PersistenceException {
  AnalysisWriter createAnalysisWriter=ElementWriterFactory.getInstance().createAnalysisWrite();
  Analysis createAnalysis=AnalysisFactory.eINSTANCE.createAnalysis();
  AnalysisResult createAnalysisResult=AnalysisFactory.eINSTANCE.createAnalysisResult();
  AnalysisContext createAnalysisContext=AnalysisFactory.eINSTANCE.createAnalysisContext();
  createAnalysis.setResults(createAnalysisResult);
  createAnalysis.setContext(createAnalysisContext);
  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);
  UserDefIndicator createUserDefIndicator=IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
  createAnalysisResult.getIndicators().add(createUserDefIndicator);
  UDIndicatorDefinition createUDIndicatorDefinition=UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
  createUserDefIndicator.setIndicatorDefinition(createUDIndicatorDefinition);
  TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  createTDQIndicatorDefinitionItem.setIndicatorDefinition(createUDIndicatorDefinition);
  Property createProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createProperty.setLabel("String_Node_Str");
  createTDQIndicatorDefinitionItem.setProperty(createProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem,Path.EMPTY,false);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(createUserDefIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().size());
  Assert.assertEquals(0,createUDIndicatorDefinition.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 UDI and analysis
 */
@Test public void testSaveAnalysisCase1() throws PersistenceException {
  AnalysisWriter createAnalysisWriter=ElementWriterFactory.getInstance().createAnalysisWrite();
  Analysis createAnalysis=AnalysisFactory.eINSTANCE.createAnalysis();
  AnalysisResult createAnalysisResult=AnalysisFactory.eINSTANCE.createAnalysisResult();
  AnalysisContext createAnalysisContext=AnalysisFactory.eINSTANCE.createAnalysisContext();
  createAnalysis.setResults(createAnalysisResult);
  createAnalysis.setContext(createAnalysisContext);
  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);
  createAnalysisProperty.setId(EcoreUtil.generateUUID());
  ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem,Path.EMPTY,false);
  UserDefIndicator createUserDefIndicator=IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
  createAnalysisResult.getIndicators().add(createUserDefIndicator);
  UDIndicatorDefinition createUDIndicatorDefinition=UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
  createUserDefIndicator.setIndicatorDefinition(createUDIndicatorDefinition);
  createAnalysisResult.getIndicators().add(createUserDefIndicator);
  TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  createTDQIndicatorDefinitionItem.setIndicatorDefinition(createUDIndicatorDefinition);
  Property createProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createProperty.setLabel("String_Node_Str");
  createTDQIndicatorDefinitionItem.setProperty(createProperty);
  createProperty.setId(EcoreUtil.generateUUID());
  ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem,new Path(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS.getFolder()).removeFirstSegments(2),false);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(createUserDefIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,createUDIndicatorDefinition.getSupplierDependency().size());
  Assert.assertEquals(0,createUDIndicatorDefinition.getSupplierDependency().get(0).getClient().size());
}