@Test
public void testNullStream() throws Exception {

  final IFixedSizeStreamingContent content = mock( IFixedSizeStreamingContent.class );
  final IAsyncReportExecution reportExecution = mock( IAsyncReportExecution.class );
  final IAsyncReportState state = mock( IAsyncReportState.class );
  when( state.getMimeType() ).thenReturn( "application/pdf" );
  when( state.getPath() ).thenReturn( "report.prpt" );
  when( reportExecution.getState() ).thenReturn( state );
  final InputStream inputStream = mock( InputStream.class );
  when( inputStream.read( any() ) ).thenThrow( new IOException( "Test" ) );
  when( content.getStream() ).thenReturn( inputStream );
  final ReportContentRepository contentRepository = mock( ReportContentRepository.class );
  final ContentLocation contentLocation = mock( ContentLocation.class );
  final ContentItem contentItem = mock( ContentItem.class );
  when( contentItem.getOutputStream() ).thenReturn( null );
  when( contentLocation.createItem( any() ) ).thenReturn( contentItem );
  when( contentRepository.getRoot() ).thenReturn( contentLocation );
  final WriteToJcrTask toJcrTask = new WriteToJcrTask( reportExecution, inputStream ) {
    @Override protected ReportContentRepository getReportContentRepository( final RepositoryFile outputFolder ) {
      return contentRepository;
    }
  };
  assertNull( toJcrTask.call() );
}