### Question:
DSWDatasourceServiceImpl implements IDSWDatasourceService { public BusinessData generateLogicalModel( String modelName, String connectionName, String dbType, String query, String previewLimit ) throws DatasourceServiceException { if ( !hasDataAccessPermission() ) { logger.error( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED" ) ); throw new DatasourceServiceException( Messages .getErrorString( "DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED" ) ); } try { connectionName = UtilHtmlSanitizer.getInstance().safeEscapeHtml( connectionName ); executeQuery( connectionName, query, previewLimit ); Boolean securityEnabled = ( getPermittedRoleList() != null && getPermittedRoleList().size() > 0 ) || ( getPermittedUserList() != null && getPermittedUserList().size() > 0 ); SerializedResultSet resultSet = DatasourceServiceHelper.getSerializeableResultSet( connectionName, query, Integer.parseInt( previewLimit ), PentahoSessionHolder.getSession() ); SQLModelGenerator sqlModelGenerator = new SQLModelGenerator( modelName, connectionName, dbType, resultSet.getColumnTypes(), resultSet.getColumns(), query, securityEnabled, getEffectivePermittedUserList( securityEnabled ), getPermittedRoleList(), getDefaultAcls(), ( PentahoSessionHolder.getSession() != null ) ? PentahoSessionHolder.getSession().getName() : null ); Domain domain = sqlModelGenerator.generate(); return new BusinessData( domain, resultSet.getData() ); } catch ( SQLModelGeneratorException smge ) { logger.error( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0011_UNABLE_TO_GENERATE_MODEL", smge.getLocalizedMessage() ), smge ); throw new DatasourceServiceException( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0011_UNABLE_TO_GENERATE_MODEL", smge.getLocalizedMessage() ), smge ); } catch ( QueryValidationException e ) { throw new DatasourceServiceException( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage() ), e ); } catch ( SqlQueriesNotSupportedException e ) { throw new DatasourceServiceException( e.getLocalizedMessage(), e ); } } DSWDatasourceServiceImpl();  DSWDatasourceServiceImpl( ConnectionServiceImpl connService ); boolean deleteLogicalModel( String domainId, String modelName ); SerializedResultSet doPreview( String connectionName, String query, String previewLimit ); boolean testDataSourceConnection( String connectionName ); BusinessData generateLogicalModel( String modelName, String connectionName, String dbType, String query,
                                            String previewLimit ); IMetadataDomainRepository getMetadataDomainRepository(); void setMetadataDomainRepository( IMetadataDomainRepository metadataDomainRepository ); boolean saveLogicalModel( Domain domain, boolean overwrite ); boolean hasPermission(); List<LogicalModelSummary> getLogicalModels( String context ); BusinessData loadBusinessData( String domainId, String modelId ); BogoPojo gwtWorkaround( BogoPojo pojo ); String serializeModelState( DatasourceDTO dto ); DatasourceDTO deSerializeModelState( String dtoStr ); List<String> listDatasourceNames(); @Override QueryDatasourceSummary generateQueryDomain( String name, String query, DatabaseConnection connection,
                                                     DatasourceDTO datasourceDTO ); void prepareForSerializaton( Domain domain ); String getDatasourceIllegalCharacters(); @Override GeoContext getGeoContext();  }### Answer:
@Test public void testGenerateLogicalModel() throws DatasourceServiceException { testGenerateLogicalModel( MODEL_NAME, CONNECTION_NAME, VALID_QUERY, null, null ); }