Program: 137957
Project: 137957
Buggy source:
/** 
 * Test method for   {@link org.talend.dq.indicators.ColumnSetIndicatorEvaluator#executeSqlQuery(String)} .
 */
@Test public void testExecuteSqlQuery_file() throws Exception {
  Analysis analysis=mock(Analysis.class);
  stub(method(DelimitedFileIndicatorEvaluator.class,"String_Node_Str"));
  stub(method(DelimitedFileIndicatorEvaluator.class,"String_Node_Str",Indicator.class,EMap.class));
  AnalysisContext context=mock(AnalysisContext.class);
  when(analysis.getContext()).thenReturn(context);
  DelimitedFileConnection deliFileConn=mock(DelimitedFileConnection.class);
  when(context.getConnection()).thenReturn(deliFileConn);
  when(deliFileConn.isContextMode()).thenReturn(true);
  when(deliFileConn.getFilePath()).thenReturn(context_fd1_File);
  when(deliFileConn.getFieldSeparatorValue()).thenReturn(context_fd1_FieldSeparator);
  when(deliFileConn.getEncoding()).thenReturn(context_fd1_Encoding);
  IPath iPath=mock(IPath.class);
  File file=new File(realFile);
  BufferedWriter output=new BufferedWriter(new FileWriter(file));
  String str="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  output.write(str);
  output.close();
  when(iPath.toFile()).thenReturn(file);
  assertTrue(file.exists());
  PowerMockito.mockStatic(ConnectionUtils.class);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_File)).thenReturn(realFile);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_FieldSeparator)).thenReturn(realFieldSeparator);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_Encoding)).thenReturn(realEncoding);
  PowerMockito.mockStatic(ResourceBundle.class);
  ResourceBundle bundle=mock(ResourceBundle.class);
  when(ResourceBundle.getBundle("String_Node_Str")).thenReturn(bundle);
  PowerMockito.mockStatic(Messages.class);
  when(Messages.getString(anyString())).thenReturn("String_Node_Str");
  AnalysisResult results=mock(AnalysisResult.class);
  when(analysis.getResults()).thenReturn(results);
  EMap<Indicator,AnalyzedDataSet> indicToRowMap=mock(EMap.class);
  when(results.getIndicToRowMap()).thenReturn(indicToRowMap);
  when(deliFileConn.getHeaderValue()).thenReturn(context_fd1_Header);
  when(deliFileConn.getFooterValue()).thenReturn(zero);
  when(deliFileConn.getLimitValue()).thenReturn(zero);
  when(deliFileConn.getEscapeType()).thenReturn(Escape.DELIMITED);
  when(deliFileConn.getRowSeparatorValue()).thenReturn(context_fd1_RowSeparator);
  when(deliFileConn.isSplitRecord()).thenReturn(false);
  when(deliFileConn.isRemoveEmptyRow()).thenReturn(false);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_Header)).thenReturn(realHeading);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,zero)).thenReturn(zero);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_RowSeparator)).thenReturn(realRowSeparator);
  PowerMockito.mockStatic(LanguageManager.class);
  when(LanguageManager.getCurrentLanguage()).thenReturn(ECodeLanguage.JAVA);
  PowerMockito.mockStatic(ParameterUtil.class);
  when(ParameterUtil.trimParameter(realFile)).thenReturn(realFile);
  when(ParameterUtil.trimParameter(realEncoding)).thenReturn(realEncoding);
  PowerMockito.mockStatic(StringUtils.class);
  when(StringUtils.loadConvert(realFieldSeparator,ECodeLanguage.JAVA.getName())).thenReturn(realFieldSeparator);
  when(ParameterUtil.trimParameter(realFieldSeparator)).thenReturn(realFieldSeparator);
  when(StringUtils.loadConvert(realRowSeparator,ECodeLanguage.JAVA.getName())).thenReturn(realRowSeparator);
  when(ParameterUtil.trimParameter(realRowSeparator)).thenReturn(realRowSeparator);
  List<ModelElement> columnElementList=new BasicEList<ModelElement>();
  List<MetadataColumn> columnElementList2=new BasicEList<MetadataColumn>();
  MetadataColumn mc0=mock(MetadataColumn.class);
  MetadataColumn mc1=mock(MetadataColumn.class);
  MetadataColumn mc2=mock(MetadataColumn.class);
  columnElementList.add(mc0);
  columnElementList.add(mc1);
  columnElementList.add(mc2);
  columnElementList2.add(mc0);
  columnElementList2.add(mc1);
  columnElementList2.add(mc2);
  EList<ModelElement> eLs=(EList<ModelElement>)columnElementList;
  when(context.getAnalysedElements()).thenReturn(eLs);
  PowerMockito.mockStatic(ColumnHelper.class);
  MetadataTable mTable=mock(MetadataTable.class);
  when(mTable.getColumns()).thenReturn((EList<MetadataColumn>)columnElementList2);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc0)).thenReturn(mTable);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc1)).thenReturn(mTable);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc2)).thenReturn(mTable);
  ColumnSetIndicatorEvaluator evaluator=new ColumnSetIndicatorEvaluator(analysis);
  ReturnCode rc=evaluator.executeSqlQuery(empty);
  assertTrue(rc.isOk());
}

Fixed version (ground truth):
/** 
 * Test method for   {@link org.talend.dq.indicators.ColumnSetIndicatorEvaluator#executeSqlQuery(String)} .
 */
@Test public void testExecuteSqlQuery_file() throws Exception {
  Analysis analysis=mock(Analysis.class);
  stub(method(DelimitedFileIndicatorEvaluator.class,"String_Node_Str"));
  stub(method(DelimitedFileIndicatorEvaluator.class,"String_Node_Str",Indicator.class,EMap.class));
  AnalysisContext context=mock(AnalysisContext.class);
  when(analysis.getContext()).thenReturn(context);
  DelimitedFileConnection deliFileConn=mock(DelimitedFileConnection.class);
  when(context.getConnection()).thenReturn(deliFileConn);
  when(deliFileConn.isContextMode()).thenReturn(true);
  when(deliFileConn.getFilePath()).thenReturn(context_fd1_File);
  when(deliFileConn.getFieldSeparatorValue()).thenReturn(context_fd1_FieldSeparator);
  when(deliFileConn.getEncoding()).thenReturn(context_fd1_Encoding);
  IPath iPath=mock(IPath.class);
  File file=new File(realFile);
  BufferedWriter output=new BufferedWriter(new FileWriter(file));
  String str="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  output.write(str);
  output.close();
  when(iPath.toFile()).thenReturn(file);
  assertTrue(file.exists());
  PowerMockito.mockStatic(ConnectionUtils.class);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_File)).thenReturn(realFile);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_FieldSeparator)).thenReturn(realFieldSeparator);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_Encoding)).thenReturn(realEncoding);
  PowerMockito.mockStatic(ResourceBundle.class);
  ResourceBundle bundle=mock(ResourceBundle.class);
  when(ResourceBundle.getBundle("String_Node_Str")).thenReturn(bundle);
  PowerMockito.mockStatic(Messages.class);
  when(Messages.getString(anyString())).thenReturn("String_Node_Str");
  AnalysisResult results=mock(AnalysisResult.class);
  when(analysis.getResults()).thenReturn(results);
  EMap<Indicator,AnalyzedDataSet> indicToRowMap=mock(EMap.class);
  when(results.getIndicToRowMap()).thenReturn(indicToRowMap);
  when(deliFileConn.getHeaderValue()).thenReturn(context_fd1_Header);
  when(deliFileConn.getFooterValue()).thenReturn(zero);
  when(deliFileConn.getLimitValue()).thenReturn(zero);
  when(deliFileConn.getEscapeType()).thenReturn(Escape.DELIMITED);
  when(deliFileConn.getRowSeparatorValue()).thenReturn(context_fd1_RowSeparator);
  when(deliFileConn.isSplitRecord()).thenReturn(false);
  when(deliFileConn.isRemoveEmptyRow()).thenReturn(false);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_Header)).thenReturn(realHeading);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,zero)).thenReturn(zero);
  when(ConnectionUtils.getOriginalConntextValue(deliFileConn,context_fd1_RowSeparator)).thenReturn(realRowSeparator);
  PowerMockito.mockStatic(LanguageManager.class);
  when(LanguageManager.getCurrentLanguage()).thenReturn(ECodeLanguage.JAVA);
  PowerMockito.mockStatic(ParameterUtil.class);
  when(ParameterUtil.trimParameter(realFile)).thenReturn(realFile);
  when(ParameterUtil.trimParameter(realEncoding)).thenReturn(realEncoding);
  PowerMockito.mockStatic(StringUtils.class);
  when(StringUtils.loadConvert(realFieldSeparator,ECodeLanguage.JAVA.getName())).thenReturn(realFieldSeparator);
  when(ParameterUtil.trimParameter(realFieldSeparator)).thenReturn(realFieldSeparator);
  when(StringUtils.loadConvert(realRowSeparator,ECodeLanguage.JAVA.getName())).thenReturn(realRowSeparator);
  when(ParameterUtil.trimParameter(realRowSeparator)).thenReturn(realRowSeparator);
  List<ModelElement> columnElementList=new BasicEList<ModelElement>();
  List<MetadataColumn> columnElementList2=new BasicEList<MetadataColumn>();
  MetadataColumn mc0=mock(MetadataColumn.class);
  MetadataColumn mc1=mock(MetadataColumn.class);
  MetadataColumn mc2=mock(MetadataColumn.class);
  columnElementList.add(mc0);
  columnElementList.add(mc1);
  columnElementList.add(mc2);
  columnElementList2.add(mc0);
  columnElementList2.add(mc1);
  columnElementList2.add(mc2);
  EList<ModelElement> eLs=(EList<ModelElement>)columnElementList;
  when(context.getAnalysedElements()).thenReturn(eLs);
  PowerMockito.mockStatic(ColumnHelper.class);
  MetadataTable mTable=mock(MetadataTable.class);
  when(mTable.getColumns()).thenReturn((EList<MetadataColumn>)columnElementList2);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc0)).thenReturn(mTable);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc1)).thenReturn(mTable);
  when(ColumnHelper.getColumnOwnerAsMetadataTable(mc2)).thenReturn(mTable);
  ColumnSetIndicatorEvaluator evaluator=new ColumnSetIndicatorEvaluator(analysis);
  ColumnSetIndicatorEvaluator spyEvaluator=Mockito.spy(evaluator);
  Mockito.doReturn(true).when(spyEvaluator).continueRun();
  ReturnCode rc=spyEvaluator.executeSqlQuery(empty);
  assertTrue(rc.isOk());
}