Program: 126872
Project: 126872
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.Schema,java.lang.String)}.
 */
@Test public void testIsContainsViewConnectionSchemaString(){
  String schemaName="String_Node_Str";
  String tablePattern=null;
  boolean containsTable=false;
  Connection dataProvider=null;
  DatabaseMetaData metaData=null;
  java.sql.Connection sqlConn=null;
  Schema schema=null;
  ResultSet tables=Mockito.mock(ResultSet.class);
  try {
    Mockito.when(tables.next()).thenReturn(true);
    metaData=Mockito.mock(DatabaseMetaData.class);
    Mockito.when(metaData.getTables(null,schemaName,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);
    schema=Mockito.mock(Schema.class);
    Mockito.when(schema.getName()).thenReturn(schemaName);
    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(schema)).thenReturn(schema);
    Mockito.when(PackageHelper.getParentPackage(schema)).thenReturn(null);
    containsTable=DqRepositoryViewService.isContainsView(dataProvider,schema,tablePattern);
    Mockito.verify(metaData).getTables(null,schemaName,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(tables).next();
    Mockito.verify(sqlConn).isClosed();
    Mockito.verify(schema).getName();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Mockito.verifyZeroInteractions(metaData,tables,dataProvider,sqlConn,schema);
  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.Schema,java.lang.String)}.
 */
@Test public void testIsContainsViewConnectionSchemaString(){
  String schemaName="String_Node_Str";
  String tablePattern=null;
  boolean containsTable=false;
  Connection dataProvider=null;
  DatabaseMetaData metaData=null;
  java.sql.Connection sqlConn=null;
  Schema schema=null;
  ResultSet tables=Mockito.mock(ResultSet.class);
  try {
    Mockito.when(tables.next()).thenReturn(true);
    metaData=Mockito.mock(DatabaseMetaData.class);
    Mockito.when(metaData.getTables(null,schemaName,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);
    schema=Mockito.mock(Schema.class);
    Mockito.when(schema.getName()).thenReturn(schemaName);
    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(schema)).thenReturn(schema);
    Mockito.when(PackageHelper.getParentPackage(schema)).thenReturn(null);
    containsTable=DqRepositoryViewService.isSchemaHasChildren(dataProvider,schema,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(metaData).getTables(null,schemaName,tablePattern,DqRepositoryViewService.VIEW_TYPES);
    Mockito.verify(tables).next();
    Mockito.verify(sqlConn).isClosed();
    Mockito.verify(schema).getName();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail(e.getMessage());
  }
  Mockito.verifyZeroInteractions(metaData,tables,dataProvider,sqlConn,schema);
  assertTrue(containsTable);
}