### Question:
DatasourceInMemoryServiceHelper { public static SQLConnection getConnection( String connectionName ) throws DatasourceServiceException { IDatabaseConnection connection = null; try { ConnectionServiceImpl service = new ConnectionServiceImpl(); connection = service.getConnectionByName( connectionName ); DatabaseDialectService dialectService = new DatabaseDialectService(); IDatabaseDialect dialect = dialectService.getDialect( connection ); String driverClass = null; if ( connection.getDatabaseType().getShortName().equals( "GENERIC" ) ) { driverClass = connection.getAttributes().get( GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS ); } else { driverClass = dialect.getNativeDriver(); } return new SQLConnection( driverClass, dialect.getURLWithExtraOptions( connection ), connection.getUsername(), connection.getPassword(), null ); } catch ( ConnectionServiceException e1 ) { return null; } catch ( DatabaseDialectException e ) { return null; } }  static java.sql.Connection getDataSourceConnection( String connectionName ); static SQLConnection getConnection( String connectionName ); static SerializedResultSet getSerializeableResultSet( String connectionName, String query, int rowLimit,
                                                               IPentahoSession session ); static List<List<String>> getCsvDataSample( String fileLocation, boolean headerPresent, String delimiter,
                                                     String enclosure, int rowLimit );  }### Answer:
@Test public void testGetConnection_ValidGeneric() throws DatasourceServiceException { assertNotNull( DatasourceInMemoryServiceHelper.getConnection( GENERIC_CONN_DRIVER_CLASS ) ); }
@Test public void testGetConnection_Invalid() throws DatasourceServiceException { assertNull( DatasourceInMemoryServiceHelper.getConnection( CONN_CAN_NOT_PREPARED ) ); }
@Test public void testGetConnection_Exception() throws DatasourceServiceException { assertNull( DatasourceInMemoryServiceHelper.getConnection( CONN_THROW_EXCEPTION ) ); }