### Question:
DSWDatasourceServiceImpl implements IDSWDatasourceService { public boolean saveLogicalModel( Domain domain, boolean overwrite ) throws DatasourceServiceException { if ( !hasDataAccessPermission() ) { logger.error( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED" ) ); throw new DatasourceServiceException( Messages .getErrorString( "DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED" ) ); } String domainName = domain.getId(); try { getMetadataDomainRepository().storeDomain( domain, overwrite ); return true; } catch ( DomainStorageException dse ) { logger.error( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0012_UNABLE_TO_STORE_DOMAIN", domainName, dse.getLocalizedMessage() ), dse ); throw new DatasourceServiceException( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0012_UNABLE_TO_STORE_DOMAIN", domainName, dse.getLocalizedMessage() ), dse ); } catch ( DomainAlreadyExistsException dae ) { logger.error( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0013_DOMAIN_ALREADY_EXIST", domainName, dae.getLocalizedMessage() ), dae ); throw new DatasourceServiceException( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0013_DOMAIN_ALREADY_EXIST", domainName, dae.getLocalizedMessage() ), dae ); } catch ( DomainIdNullException dne ) { logger.error( Messages .getErrorString( "DatasourceServiceImpl.ERROR_0014_DOMAIN_IS_NULL", dne.getLocalizedMessage() ), dne ); throw new DatasourceServiceException( Messages.getErrorString( "DatasourceServiceImpl.ERROR_0014_DOMAIN_IS_NULL", dne.getLocalizedMessage() ), dne ); } } 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 testSaveLogicalModel() throws Exception { doReturn( true ).when( dswService ).hasDataAccessPermission(); assertTrue( dswService.saveLogicalModel( domain2Models, false ) ); verify( domainRepository ).storeDomain( any( Domain.class ), anyBoolean() ); }