Program: 126871
Project: 126871
Buggy source:
/** 
 * Test method for  {@link org.talend.core.model.metadata.builder.database.DqRepositoryViewService#getColumns(org.talend.core.model.metadata.builder.connection.Connection,orgomg.cwm.resource.relational.ColumnSet,java.lang.String,boolean)}.
 * @throws SQLException
 */
@Test public void testGetColumns(){
  ColumnSet columnSet=RelationalPackage.eINSTANCE.getRelationalFactory().createTdTable();
  TdColumn column1=RelationalPackage.eINSTANCE.getRelationalFactory().createTdColumn();
  column1.setName("String_Node_Str");
  ColumnSetHelper.addColumn(column1,columnSet);
  TdColumn column2=RelationalPackage.eINSTANCE.getRelationalFactory().createTdColumn();
  column2.setName("String_Node_Str");
  ColumnSetHelper.addColumn(column2,columnSet);
  String connFailedMessage="String_Node_Str";
  try {
    List<TdColumn> columns=DqRepositoryViewService.getColumns(null,columnSet,null,false);
    assertEquals(2,columns.size());
    DatabaseConnection dbConn=createDatabaseConn();
    TypedReturnCode<java.sql.Connection> retCode=new TypedReturnCode<java.sql.Connection>();
    retCode.setOk(Boolean.FALSE);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    when(MetadataConnectionUtils.checkConnection(dbConn)).thenReturn(retCode);
    retCode.setMessage(connFailedMessage);
    DqRepositoryViewService.getColumns(dbConn,columnSet,null,true);
    List<TdColumn> columnsExpected=new ArrayList<TdColumn>(3);
    java.sql.Connection sqlConn=null;
    DatabaseMetaData databaseMetaData=mock(DatabaseMetaData.class);
    when(ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,dbConn)).thenReturn(databaseMetaData);
    MetadataFillFactory metadataFactory=mock(MetadataFillFactory.class);
    when(metadataFactory.fillColumns(columnSet,databaseMetaData,null,null)).thenReturn(columnsExpected);
    PowerMockito.mockStatic(MetadataFillFactory.class);
    when(MetadataFillFactory.getDBInstance()).thenReturn(metadataFactory);
    List<TdColumn> columnsActual=DqRepositoryViewService.getColumns(dbConn,columnSet,null,true);
    assertEquals(columnsExpected.size(),columnsActual.size());
  }
 catch (  Exception e) {
    assertEquals(connFailedMessage,e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Test method for  {@link org.talend.core.model.metadata.builder.database.DqRepositoryViewService#getColumns(org.talend.core.model.metadata.builder.connection.Connection,orgomg.cwm.resource.relational.ColumnSet,java.lang.String,boolean)}.
 * @throws SQLException
 */
@Test public void testGetColumns(){
  ColumnSet columnSet=RelationalPackage.eINSTANCE.getRelationalFactory().createTdTable();
  TdColumn column1=RelationalPackage.eINSTANCE.getRelationalFactory().createTdColumn();
  column1.setName("String_Node_Str");
  ColumnSetHelper.addColumn(column1,columnSet);
  TdColumn column2=RelationalPackage.eINSTANCE.getRelationalFactory().createTdColumn();
  column2.setName("String_Node_Str");
  ColumnSetHelper.addColumn(column2,columnSet);
  String connFailedMessage="String_Node_Str";
  try {
    List<TdColumn> columns=DqRepositoryViewService.getColumns(null,columnSet,null,false);
    assertEquals(2,columns.size());
    DatabaseConnection dbConn=createDatabaseConn();
    TypedReturnCode<java.sql.Connection> retCode=new TypedReturnCode<java.sql.Connection>();
    retCode.setOk(Boolean.FALSE);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    when(MetadataConnectionUtils.createConnection(dbConn)).thenReturn(retCode);
    retCode.setMessage(connFailedMessage);
    DqRepositoryViewService.getColumns(dbConn,columnSet,null,true);
    List<TdColumn> columnsExpected=new ArrayList<TdColumn>(3);
    java.sql.Connection sqlConn=null;
    DatabaseMetaData databaseMetaData=mock(DatabaseMetaData.class);
    when(ExtractMetaDataUtils.getInstance().getDatabaseMetaData(sqlConn,dbConn)).thenReturn(databaseMetaData);
    MetadataFillFactory metadataFactory=mock(MetadataFillFactory.class);
    when(metadataFactory.fillColumns(columnSet,databaseMetaData,null,null)).thenReturn(columnsExpected);
    PowerMockito.mockStatic(MetadataFillFactory.class);
    when(MetadataFillFactory.getDBInstance()).thenReturn(metadataFactory);
    List<TdColumn> columnsActual=DqRepositoryViewService.getColumns(dbConn,columnSet,null,true);
    assertEquals(columnsExpected.size(),columnsActual.size());
  }
 catch (  Exception e) {
    assertEquals(connFailedMessage,e.getMessage());
  }
}