Program: 127384
Project: 127384
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;
  String[] tableType=new String[]{TableType.VIEW.toString()};
  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,tableType)).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);
    Mockito.when(ExtractMetaDataUtils.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,tableType);
    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#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);
    Mockito.when(ExtractMetaDataUtils.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);
}