Program: 126876
Project: 126876
Buggy source:
/** 
 * Test method for  {@link org.talend.core.model.metadata.builder.database.DqRepositoryViewService#isContainsView(org.talend.core.model.metadata.builder.connection.Connection,orgomg.cwm.resource.relational.Catalog,java.lang.String)}.
 */
@Test public void testIsContainsViewConnectionCatalogString(){
  String catalogName="String_Node_Str";
  String tablePattern=null;
  boolean containsTable=false;
  Connection dataProvider=null;
  DatabaseMetaData metaData=null;
  java.sql.Connection sqlConn=null;
  Catalog catalog=null;
  ResultSet tables=Mockito.mock(ResultSet.class);
  try {
    Mockito.when(tables.next()).thenReturn(true);
    metaData=Mockito.mock(DatabaseMetaData.class);
    Mockito.when(metaData.getTables(catalogName,null,tablePattern,DqRepositoryViewService.VIEW_TYPES)).thenReturn(tables);
    dataProvider=Mockito.mock(DatabaseConnection.class);
    TypedReturnCode<java.sql.Connection> reConn=new TypedReturnCode<java.sql.Connection>();
    sqlConn=Mockito.mock(java.sql.Connection.class);
    reConn.setOk(true);
    reConn.setObject(sqlConn);
    Mockito.when(sqlConn.getMetaData()).thenReturn(metaData);
    Mockito.when(sqlConn.isClosed()).thenReturn(true);
    catalog=Mockito.mock(Catalog.class);
    Mockito.when(catalog.getName()).thenReturn(catalogName);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    Mockito.when(MetadataConnectionUtils.checkConnection((DatabaseConnection)dataProvider)).thenReturn(reConn);
    PowerMockito.mockStatic(ExtractMetaDataUtils.class);
    ExtractMetaDataUtils extract=Mockito.mock(ExtractMetaDataUtils.class);
    Mockito.when(ExtractMetaDataUtils.getInstance()).thenReturn(extract);
    Mockito.when(extract.getDatabaseMetaData(sqlConn,(DatabaseConnection)dataProvider,false)).thenReturn(metaData);
    PowerMockito.mockStatic(PackageHelper.class);
    Mockito.when(PackageHelper.getCatalogOrSchema(catalog)).thenReturn(catalog);
    containsTable=DqRepositoryViewService.isContainsView(dataProvider,catalog,tablePattern);
    Mockito.verify(metaData).getTables(catalogName,null,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(tables).next();
    Mockito.verify(sqlConn).isClosed();
    Mockito.verify(catalog).getName();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Mockito.verifyZeroInteractions(metaData,tables,dataProvider,sqlConn,catalog);
  assertTrue(containsTable);
}

Fixed version (ground truth):
/** 
 * Test method for  {@link org.talend.core.model.metadata.builder.database.DqRepositoryViewService#hasChildren(org.talend.core.model.metadata.builder.connection.Connection,orgomg.cwm.resource.relational.Catalog,java.lang.String)}.
 */
@Test public void testIsContainsViewConnectionCatalogString(){
  String catalogName="String_Node_Str";
  String tablePattern=null;
  boolean containsTable=false;
  Connection dataProvider=null;
  DatabaseMetaData metaData=null;
  java.sql.Connection sqlConn=null;
  Catalog catalog=null;
  ResultSet tables=Mockito.mock(ResultSet.class);
  try {
    Mockito.when(tables.next()).thenReturn(true);
    metaData=Mockito.mock(DatabaseMetaData.class);
    Mockito.when(metaData.getTables(catalogName,null,tablePattern,DqRepositoryViewService.VIEW_TYPES)).thenReturn(tables);
    dataProvider=Mockito.mock(DatabaseConnection.class);
    TypedReturnCode<java.sql.Connection> reConn=new TypedReturnCode<java.sql.Connection>();
    sqlConn=Mockito.mock(java.sql.Connection.class);
    reConn.setOk(true);
    reConn.setObject(sqlConn);
    Mockito.when(sqlConn.getMetaData()).thenReturn(metaData);
    Mockito.when(sqlConn.isClosed()).thenReturn(true);
    catalog=Mockito.mock(Catalog.class);
    Mockito.when(catalog.getName()).thenReturn(catalogName);
    PowerMockito.mockStatic(MetadataConnectionUtils.class);
    Mockito.when(MetadataConnectionUtils.createConnection((DatabaseConnection)dataProvider)).thenReturn(reConn);
    PowerMockito.mockStatic(ExtractMetaDataUtils.class);
    ExtractMetaDataUtils extract=Mockito.mock(ExtractMetaDataUtils.class);
    Mockito.when(ExtractMetaDataUtils.getInstance()).thenReturn(extract);
    Mockito.when(extract.getDatabaseMetaData(sqlConn,(DatabaseConnection)dataProvider,false)).thenReturn(metaData);
    PowerMockito.mockStatic(PackageHelper.class);
    Mockito.when(PackageHelper.getCatalogOrSchema(catalog)).thenReturn(catalog);
    containsTable=DqRepositoryViewService.isCatalogHasChildren(dataProvider,catalog,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(metaData).getTables(catalogName,null,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(tables).next();
    Mockito.verify(sqlConn).isClosed();
    Mockito.verify(catalog).getName();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Mockito.verifyZeroInteractions(metaData,tables,dataProvider,sqlConn,catalog);
  assertTrue(containsTable);
}