Program: 126857
Project: 126857
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.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());
  }
}

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);
    retCode.setMessage(connFailedMessage);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    when(MetadataConnectionUtils.createConnection(dbConn)).thenReturn(retCode);
    DqRepositoryViewService.getColumns(dbConn,columnSet,null,true);
    List<TdColumn> columnsExpected=new ArrayList<TdColumn>(3);
    java.sql.Connection sqlConn=Mockito.mock(java.sql.Connection.class);
    DatabaseMetaData databaseMetaData=mock(DatabaseMetaData.class);
    TypedReturnCode<java.sql.Connection> rc=new TypedReturnCode<java.sql.Connection>();
    rc.setOk(Boolean.TRUE);
    rc.setObject(sqlConn);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    when(MetadataConnectionUtils.createConnection(dbConn)).thenReturn(rc);
    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());
  }
}