### Question:
MetadataService extends DatasourceService { public void setMetadataAcl( String domainId, RepositoryFileAclDto aclDto ) throws PentahoAccessControlException, FileNotFoundException { checkMetadataExists( domainId ); if ( aclAwarePentahoMetadataDomainRepositoryImporter != null ) { final RepositoryFileAcl acl = aclDto == null ? null : repositoryFileAclAdapter.unmarshal( aclDto ); aclAwarePentahoMetadataDomainRepositoryImporter.setAclFor( domainId, acl ); flushDataSources(); } } 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 testSetMetadataDatasourceAcl() throws Exception { String domainId = DOMAIN_ID; final RepositoryFileAclDto aclDto = new RepositoryFileAclDto(); aclDto.setOwner( "owner" ); aclDto.setOwnerType( RepositoryFileSid.Type.USER.ordinal() ); doReturn( true ).when( metadataService ).canManageACL(); final Map<String, InputStream> domainFilesData = mock( Map.class ); when( domainFilesData.isEmpty() ).thenReturn( false ); when( ( (PentahoMetadataDomainRepository) metadataService.metadataDomainRepository ).getDomainFilesData( domainId ) ) .thenReturn( domainFilesData ); metadataService.setMetadataAcl( domainId, aclDto ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).setAclFor( eq( domainId ), eq( new RepositoryFileAclAdapter().unmarshal( aclDto ) ) ); }
@Test( expected = FileNotFoundException.class ) public void testSetMetadataDatasourceAclNoDS() throws Exception { String domainId = DOMAIN_ID; doReturn( true ).when( metadataService ).canManageACL(); metadataService.setMetadataAcl( domainId, null ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).setAclFor( eq( domainId ), (RepositoryFileAcl) isNull() ); }
@Test public void testSetMetadataDatasourceAclNoAcl() throws Exception { String domainId = DOMAIN_ID; doReturn( true ).when( metadataService ).canManageACL(); final Map<String, InputStream> domainFilesData = mock( Map.class ); when( domainFilesData.isEmpty() ).thenReturn( false ); when( ( (PentahoMetadataDomainRepository) metadataService.metadataDomainRepository ).getDomainFilesData( domainId ) ) .thenReturn( domainFilesData ); metadataService.setMetadataAcl( domainId, null ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).setAclFor( eq( domainId ), (RepositoryFileAcl) isNull() ); }