### Question:
MetadataService extends DatasourceService { public void importMetadataFromTemp( String domainId, MetadataTempFilesListDto fileList, boolean overwrite, RepositoryFileAclDto acl ) throws PentahoAccessControlException, PlatformImportException, Exception { String metadataTempFileName = fileList.getXmiFileName(); InputStream metaDataFileInputStream = createInputStreamFromFile( internalGetUploadDir() + File.separatorChar + metadataTempFileName ); List<MetadataTempFilesListBundleDto> locBundles = fileList.getBundles(); List<String> localeFileNames = new ArrayList<String>(); List<InputStream> localeFileStreams = new ArrayList<InputStream>(); if ( locBundles != null ) { for ( MetadataTempFilesListBundleDto bundle : locBundles ) { localeFileNames.add( bundle.getOriginalFileName() ); localeFileStreams.add( createInputStreamFromFile( internalGetUploadDir() + File.separatorChar + bundle.getTempFileName() ) ); } } importMetadataDatasource( domainId, metaDataFileInputStream, overwrite, localeFileStreams, localeFileNames, acl ); } MetadataService(); static String getUploadDir(); void removeMetadata( String metadataId ); List<String> getMetadataDatasourceIds(); MetadataTempFilesListDto uploadMetadataFilesToTempDir( InputStream metadataFile,
      List<InputStream> localeFileStreams, List<String> localeFileNames ); MetadataTempFilesListDto uploadMetadataFilesToTempDir( InputStream metadataFile,
      List<FormDataBodyPart> localeFiles ); void importMetadataDatasource( String domainId, InputStream metadataFile,
                                        FormDataContentDisposition metadataFileInfo, boolean overwrite,
                                        List<FormDataBodyPart> localeFiles,
                                        List<FormDataContentDisposition> localeFilesInfo, RepositoryFileAclDto acl ); void importMetadataDatasource( String domainId, InputStream metadataFile, boolean overwrite,
      List<InputStream> localeFileStreams, List<String> localeFileNames, RepositoryFileAclDto acl ); boolean isContainsModel( String tempFileName ); void importMetadataFromTemp( String domainId, MetadataTempFilesListDto fileList,
      boolean overwrite, RepositoryFileAclDto acl ); RepositoryFileAclDto getMetadataAcl( String domainId ); void setMetadataAcl( String domainId, RepositoryFileAclDto aclDto ); static RepositoryFileImportBundle createNewRepositoryFileImportBundle( InputStream bais, String fileName, String domainId );  }### Answer:
@Test public void testImportMetadataFromTemp() throws Exception { final boolean IS_CONTAINS_MODEL = true; InputStream metadataFile = mock( InputStream.class ); boolean overwrite = true; when( metadataFile.read( any() ) ).thenReturn( -1 ); fillServiceMock( DOMAIN_ID, metadataFile ); doReturn( IS_CONTAINS_MODEL ).when( metadataService ).isContainsModel( any( Domain.class ) ); doReturn( metadataFile ).when( metadataService ).createInputStreamFromFile( anyString() ); MetadataTempFilesListDto fileList = new MetadataTempFilesListDto(); fileList.setXmiFileName( XMI_TEMP_FILE_NAME ); metadataService.importMetadataFromTemp( DOMAIN_ID, fileList, overwrite, null ); verify( metadataService, times( 1 ) ) .importMetadataDatasource( DOMAIN_ID, metadataFile, overwrite, new ArrayList<InputStream>(), new ArrayList<String>(), null ); }