### Question:
MetadataService extends DatasourceService { public RepositoryFileAclDto getMetadataAcl( String domainId ) throws PentahoAccessControlException, FileNotFoundException { checkMetadataExists( domainId ); if ( aclAwarePentahoMetadataDomainRepositoryImporter != null ) { final RepositoryFileAcl acl = aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor( domainId ); return acl == null ? null : repositoryFileAclAdapter.marshal( acl ); } return null; } 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 testGetMetadataDatasourceAcl() throws Exception { String domainId = DOMAIN_ID; final RepositoryFileAcl acl = new RepositoryFileAcl.Builder( "owner" ).build(); doReturn( true ).when( metadataService ).canManageACL(); when( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor( domainId ) ).thenReturn( acl ); final Map<String, InputStream> domainFilesData = mock( Map.class ); when( domainFilesData.isEmpty() ).thenReturn( false ); when( ( (PentahoMetadataDomainRepository) metadataService.metadataDomainRepository ).getDomainFilesData( domainId ) ) .thenReturn( domainFilesData ); final RepositoryFileAclDto aclDto = metadataService.getMetadataAcl( domainId ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).getAclFor( eq( domainId ) ); assertEquals( acl, new RepositoryFileAclAdapter().unmarshal( aclDto ) ); }
@Test( expected = FileNotFoundException.class ) public void testGetMetadataDatasourceAclNoDS() throws Exception { String domainId = DOMAIN_ID; doReturn( true ).when( metadataService ).canManageACL(); when( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor( domainId ) ).thenReturn( null ); final RepositoryFileAclDto aclDto = metadataService.getMetadataAcl( domainId ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).getAclFor( eq( domainId ) ); assertNull( aclDto ); }
@Test public void testGetMetadataDatasourceAclNoAcl() throws Exception { String domainId = DOMAIN_ID; doReturn( true ).when( metadataService ).canManageACL(); when( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter.getAclFor( domainId ) ).thenReturn( null ); final Map<String, InputStream> domainFilesData = mock( Map.class ); when( domainFilesData.isEmpty() ).thenReturn( false ); when( ( (PentahoMetadataDomainRepository) metadataService.metadataDomainRepository ).getDomainFilesData( domainId ) ) .thenReturn( domainFilesData ); final RepositoryFileAclDto aclDto = metadataService.getMetadataAcl( domainId ); verify( metadataService.aclAwarePentahoMetadataDomainRepositoryImporter ).getAclFor( eq( domainId ) ); assertNull( aclDto ); }