### Question:
DataSourceWizardService extends DatasourceService { public String publishDsw( String domainId, InputStream metadataFile, boolean overwrite, boolean checkConnection, RepositoryFileAclDto acl ) throws PentahoAccessControlException, IllegalArgumentException, DswPublishValidationException, Exception { return publishDsw( domainId, metadataFile, null, null, overwrite, checkConnection, acl ); } DataSourceWizardService(); Map<String, InputStream> doGetDSWFilesAsDownload( String dswId ); void removeDSW( String dswId ); List<String> getDSWDatasourceIds(); String publishDsw( String domainId, InputStream metadataFile, boolean overwrite, boolean checkConnection,
      RepositoryFileAclDto acl ); String publishDsw( String domainId, InputStream metadataFile, List<InputStream> localizeFiles, List<String> localizeFileNames,
      boolean overwrite, boolean checkConnection, RepositoryFileAclDto acl ); String publishDswFromTemp( String domainId,
      MetadataTempFilesListDto fileList,
      boolean overwrite,
      boolean checkConnection,
      RepositoryFileAclDto acl ); RepositoryFileAclDto getDSWAcl( String dswId ); void setDSWAcl( String dswId, RepositoryFileAclDto aclDto ); static final String METADATA_EXT; }### Answer:
@Test public void testPublishDsw() throws Exception { String domainId = DOMAIN_ID; InputStream metadataFile = mock( InputStream.class ); boolean overwrite = true; boolean checkConnection = false; XmiParser mockXmiParser = mock( XmiParser.class ); Domain mockDomain = mock( Domain.class ); InputStream mockInputStream = mock( InputStream.class ); IPlatformImportBundle mockMetadataBundle = mock( IPlatformImportBundle.class ); IPlatformImportBundle mockMondrianBundle = mock( IPlatformImportBundle.class ); IPlatformImporter mockIPlatformImporter = mock( IPlatformImporter.class ); IPentahoSession mockIPentahoSession = mock( IPentahoSession.class ); String mockObject = "not null"; String dswId = "dswId"; final RepositoryFileAclDto aclDto = new RepositoryFileAclDto(); aclDto.setOwner( "owner" ); aclDto.setOwnerType( RepositoryFileSid.Type.USER.ordinal() ); doReturn( true ).when( dataSourceWizardService ).hasManageAccessCheck(); doReturn( true ).when( dataSourceWizardService ).endsWith( anyString(), anyString() ); doReturn( mockXmiParser ).when( dataSourceWizardService ).createXmiParser(); doReturn( mockDomain ).when( mockXmiParser ).parseXmi( metadataFile ); doReturn( mockInputStream ).when( dataSourceWizardService ).toInputStreamWrapper( mockDomain, mockXmiParser ); doReturn( mockMetadataBundle ).when( dataSourceWizardService ).createMetadataDswBundle( mockDomain, mockInputStream, overwrite, aclDto ); doReturn( mockMondrianBundle ).when( dataSourceWizardService ).createMondrianDswBundle( mockDomain, aclDto ); doReturn( mockIPlatformImporter ).when( dataSourceWizardService ).getIPlatformImporter(); doReturn( mockIPentahoSession ).when( dataSourceWizardService ).getSession(); String response = dataSourceWizardService.publishDsw( domainId, metadataFile, overwrite, checkConnection, aclDto ); verify( dataSourceWizardService, times( 1 ) ).publishDsw( domainId, metadataFile, overwrite, checkConnection, aclDto ); assertEquals( domainId, response ); checkConnection = true; String testName = "クイズ"; doReturn( testName ).when( dataSourceWizardService ).getMondrianDatasourceWrapper( mockDomain ); doReturn( mock( IDatabaseConnection.class ) ).when( dataSourceWizardService.datasourceMgmtSvc ).getDatasourceByName( anyString() ); dataSourceWizardService.publishDsw( domainId, metadataFile, overwrite, checkConnection, aclDto ); verify( dataSourceWizardService.sanitizer ).escape( testName ); verify( dataSourceWizardService, times( 1 ) ).publishDsw( domainId, metadataFile, overwrite, checkConnection, aclDto ); }