Program: 136632
Project: 136632
Buggy source:
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case2: between Pattern and analysis
 */
@Test public void testSaveAnalysisCase2() 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);
  RegexpMatchingIndicator regexMatchingIndicator=IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
  IndicatorParameters createIndicatorParameters=IndicatorsFactory.eINSTANCE.createIndicatorParameters();
  regexMatchingIndicator.setParameters(createIndicatorParameters);
  IndicatorDefinition createIndicatorDefinition=DefinitionFactory.eINSTANCE.createIndicatorDefinition();
  regexMatchingIndicator.setIndicatorDefinition(createIndicatorDefinition);
  TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
  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);
  Pattern pattern=PatternFactory.eINSTANCE.createPattern();
  createAnalysisResult.getIndicators().add(regexMatchingIndicator);
  TDQPatternItem createTDQPatternItem=PropertiesFactory.eINSTANCE.createTDQPatternItem();
  createTDQPatternItem.setPattern(pattern);
  Property createPatternProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createPatternProperty.setLabel("String_Node_Str");
  createTDQPatternItem.setProperty(createPatternProperty);
  ProxyRepositoryFactory.getInstance().create(createTDQPatternItem,Path.EMPTY,false);
  Domain createDomain=DomainFactory.eINSTANCE.createDomain();
  createIndicatorParameters.setDataValidDomain(createDomain);
  createIndicatorParameters.getDataValidDomain().getPatterns().add(pattern);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(regexMatchingIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().size());
  Assert.assertEquals(0,pattern.getSupplierDependency().get(0).getClient().size());
}

Fixed version (ground truth):
/** 
 * Test method for   {@link org.talend.dq.writer.AElementPersistance#save(Item,boolean)}.
 * @throws PersistenceException case2: between Pattern and analysis
 */
@Test public void testSaveAnalysisCase2() 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);
  RegexpMatchingIndicator regexMatchingIndicator=IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
  IndicatorParameters createIndicatorParameters=IndicatorsFactory.eINSTANCE.createIndicatorParameters();
  regexMatchingIndicator.setParameters(createIndicatorParameters);
  IndicatorDefinition createIndicatorDefinition=DefinitionFactory.eINSTANCE.createIndicatorDefinition();
  regexMatchingIndicator.setIndicatorDefinition(createIndicatorDefinition);
  TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem=PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
  createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
  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,Path.EMPTY,false);
  Pattern pattern=PatternFactory.eINSTANCE.createPattern();
  createAnalysisResult.getIndicators().add(regexMatchingIndicator);
  TDQPatternItem createTDQPatternItem=PropertiesFactory.eINSTANCE.createTDQPatternItem();
  createTDQPatternItem.setPattern(pattern);
  Property createPatternProperty=org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
  createPatternProperty.setLabel("String_Node_Str");
  createTDQPatternItem.setProperty(createPatternProperty);
  createPatternProperty.setId(EcoreUtil.generateUUID());
  ProxyRepositoryFactory.getInstance().create(createTDQPatternItem,new Path(ERepositoryObjectType.TDQ_PATTERN_REGEX.getFolder()).removeFirstSegments(2),false);
  Domain createDomain=DomainFactory.eINSTANCE.createDomain();
  createIndicatorParameters.setDataValidDomain(createDomain);
  createIndicatorParameters.getDataValidDomain().getPatterns().add(pattern);
  ReturnCode save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(1,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().get(0).getClient().size());
  createAnalysisResult.getIndicators().remove(regexMatchingIndicator);
  save=createAnalysisWriter.save(createTDQAnalysisItem,true);
  Assert.assertTrue(save.isOk());
  Assert.assertEquals(0,createAnalysis.getClientDependency().size());
  Assert.assertEquals(1,pattern.getSupplierDependency().size());
  Assert.assertEquals(0,pattern.getSupplierDependency().get(0).getClient().size());
}