ReportContentLocation implements ContentLocation { public ContentEntity getEntry( final String name ) throws ContentIOException { IUnifiedRepository repo = PentahoSystem.get( IUnifiedRepository.class ); String path = this.location.getPath() + "/" + name; final RepositoryFile rawFile = repo.getFile( path ); if ( rawFile == null ) { throw new ContentIOException( "Could not get ContentItem entry" ); } return new ReportContentItem( rawFile, this, MimeHelper.getMimeTypeFromFileName( name ) ); } ReportContentLocation( final RepositoryFile location, final ReportContentRepository repository ); ContentEntity[] listContents(); ContentEntity getEntry( final String name ); ContentItem createItem( final String name ); ContentLocation createLocation( final String string ); boolean exists( final String name ); String getName(); Object getContentId(); Object getAttribute( final String domain, final String key ); boolean setAttribute( final String domain, final String key, final Object object ); ContentLocation getParent(); Repository getRepository(); boolean delete(); boolean isHiddenExtension( String extension ); static final String RESERVEDMAPKEY_LINEAGE_ID; }
@Test( expected = ContentIOException.class ) public void testGetEntryNotExist() throws ContentIOException { final ReportContentLocation reportContentLocation = new ReportContentLocation( this.repositoryFile, reportContentRepository ); reportContentLocation.getEntry( "test" ); }
@Test public void testGetEntry() throws ContentIOException { final RepositoryFile repositoryFile = mock( RepositoryFile.class ); final String value = UUID.randomUUID().toString(); when( repositoryFile.getName() ).thenReturn( value ); when( repository.getFile( "null/test" ) ).thenReturn( repositoryFile ); final ReportContentLocation reportContentLocation = new ReportContentLocation( this.repositoryFile, reportContentRepository ); final ContentEntity test = reportContentLocation.getEntry( "test" ); assertNotNull( test ); assertEquals( value, test.getName() ); }