### Question:
PGBulkLoader extends BaseStep implements StepInterface { @VisibleForTesting Database getDatabase( LoggingObjectInterface parentObject, PGBulkLoaderMeta pgBulkLoaderMeta ) { DatabaseMeta dbMeta = pgBulkLoaderMeta.getDatabaseMeta(); String dbNameOverride = environmentSubstitute( pgBulkLoaderMeta.getDbNameOverride() ); if ( !Utils.isEmpty( dbNameOverride ) ) { dbMeta = (DatabaseMeta) pgBulkLoaderMeta.getDatabaseMeta().clone(); dbMeta.setDBName( dbNameOverride.trim() ); logDebug( "DB name overridden to the value: " + dbNameOverride ); } return new Database( parentObject, dbMeta ); } PGBulkLoader( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta,
    Trans trans ); String getCopyCommand( ); boolean processRow( StepMetaInterface smi, StepDataInterface sdi ); boolean init( StepMetaInterface smi, StepDataInterface sdi );  }### Answer:
@Test public void testDBNameOverridden_IfDbNameOverrideSetUp() throws Exception { PGBulkLoaderMeta pgBulkLoaderMock = getPgBulkLoaderMock( DB_NAME_OVVERRIDE ); Database database = pgBulkLoader.getDatabase( pgBulkLoader, pgBulkLoaderMock ); assertNotNull( database ); assertEquals( DB_NAME_OVVERRIDE, database.getDatabaseMeta().getDatabaseName() ); assertEquals( CONNECTION_NAME, database.getDatabaseMeta().getName() ); assertEquals( CONNECTION_DB_HOST, database.getDatabaseMeta().getHostname() ); assertEquals( CONNECTION_DB_PORT, database.getDatabaseMeta().getDatabasePortNumberString() ); assertEquals( CONNECTION_DB_USERNAME, database.getDatabaseMeta().getUsername() ); assertEquals( CONNECTION_DB_PASSWORD, database.getDatabaseMeta().getPassword() ); }
@Test public void testDBNameNOTOverridden_IfDbNameOverrideEmpty() throws Exception { PGBulkLoaderMeta pgBulkLoaderMock = getPgBulkLoaderMock( DB_NAME_EMPTY ); Database database = pgBulkLoader.getDatabase( pgBulkLoader, pgBulkLoaderMock ); assertNotNull( database ); assertEquals( CONNECTION_DB_NAME, database.getDatabaseMeta().getDatabaseName() ); assertEquals( CONNECTION_NAME, database.getDatabaseMeta().getName() ); assertEquals( CONNECTION_DB_HOST, database.getDatabaseMeta().getHostname() ); assertEquals( CONNECTION_DB_PORT, database.getDatabaseMeta().getDatabasePortNumberString() ); assertEquals( CONNECTION_DB_USERNAME, database.getDatabaseMeta().getUsername() ); assertEquals( CONNECTION_DB_PASSWORD, database.getDatabaseMeta().getPassword() ); }
@Test public void testDBNameNOTOverridden_IfDbNameOverrideNull() throws Exception { PGBulkLoaderMeta pgBulkLoaderMock = getPgBulkLoaderMock( null ); Database database = pgBulkLoader.getDatabase( pgBulkLoader, pgBulkLoaderMock ); assertNotNull( database ); assertEquals( CONNECTION_DB_NAME, database.getDatabaseMeta().getDatabaseName() ); assertEquals( CONNECTION_NAME, database.getDatabaseMeta().getName() ); assertEquals( CONNECTION_DB_HOST, database.getDatabaseMeta().getHostname() ); assertEquals( CONNECTION_DB_PORT, database.getDatabaseMeta().getDatabasePortNumberString() ); assertEquals( CONNECTION_DB_USERNAME, database.getDatabaseMeta().getUsername() ); assertEquals( CONNECTION_DB_PASSWORD, database.getDatabaseMeta().getPassword() ); }