Program: 136637
Project: 136637
Buggy source:
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case3: between Rule and analysis
 */
@Test public void testSaveAnalysisCase3() 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);
  WhereRuleIndicator whereRuleIndicator=IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
  createAnalysisResult.getIndicators().add(whereRuleIndicator);
  DQRule dqRule=RulesFactory.eINSTANCE.createDQRule();
  whereRuleIndicator.setIndicatorDefinition(dqRule);
  TDQBusinessRuleItem createTDQBusinessRuleItem=PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
  createTDQBusinessRuleItem.setDqrule(dqRule);
  Property createPatternProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createPatternProperty.setLabel("String_Node_Str");
  createTDQBusinessRuleItem.setProperty(createPatternProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQBusinessRuleItem,Path.EMPTY,false);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(whereRuleIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().size());
  Assert.assertEquals(0,dqRule.getSupplierDependency().get(0).getClient().size());
}

Fixed version (ground truth):
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case3: between Rule and analysis
 */
@Test public void testSaveAnalysisCase3() 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);
  WhereRuleIndicator whereRuleIndicator=IndicatorSqlFactory.eINSTANCE.createWhereRuleIndicator();
  createAnalysisResult.getIndicators().add(whereRuleIndicator);
  DQRule dqRule=RulesFactory.eINSTANCE.createWhereRule();
  whereRuleIndicator.setIndicatorDefinition(dqRule);
  TDQBusinessRuleItem createTDQBusinessRuleItem=PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
  createTDQBusinessRuleItem.setDqrule(dqRule);
  Property createPatternProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createPatternProperty.setLabel("String_Node_Str");
  createTDQBusinessRuleItem.setProperty(createPatternProperty);
  createPatternProperty.setId(EcoreUtil.generateUUID());
  ProxyRepositoryFactory.getInstance().create(createTDQBusinessRuleItem,Path.EMPTY,false);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(whereRuleIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,dqRule.getSupplierDependency().size());
  Assert.assertEquals(0,dqRule.getSupplierDependency().get(0).getClient().size());
}