java.lang.Object
org.sejda.tests.tasks.TaskTestContext
- All Implemented Interfaces:
Closeable,AutoCloseable
Context to be used in tests
- Author:
- Andrea Vacondio
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasserts the creator has been set to the info dictionaryasserts that a multiple output task has generated no outputassertFailedSource(String source) assertHasAcroforms(boolean hasForms) assert that the document has an acroform with some field in itassertHasOutline(boolean hasOutline) assertOutlineContains(String title) assert the document outline contains an item with the given titleassertOutlineDoesntContain(String title) assert the document outline doesn't contain an item with the given titleassertOutputContainsFilenames(String... filenames) asserts that a multiple output task has generated the given file namesassertOutputSize(int size) asserts that a multiple output task has generated the given number of output files, hidden files don't countassertOutputSizeIncludingHidden(int size) asserts that a multiple output task has generated the given number of output files, including hidden files (in case the task is expected to have some hidden leftover)assertPages(int expected) asserts the output document has that number of pagesassertPages(String filename, int expected) asserts the output document with the given filename exists and has that number of pages.voidassertSimilar(String resourcePath) voidassertSimilar(String resourcePath, double similarityThreshold) voidassertSimilar(String filename, String resourcePath) voidassertSimilar(String filename, String resourcePath, double similarityThreshold) org.sejda.sambox.pdmodel.PDDocumentAsserts that the task has completed and generated some output.org.sejda.sambox.pdmodel.PDDocumentassertTaskCompleted(String password) Asserts that the task has completed and generated some output.assertTaskFailed(Class<? extends Throwable> cause) assertTaskFailed(String message) assertTaskWarning(String message) assertTaskWarnings(List<String> messages) assertVersion(PdfVersion version) asserts the PDF version of the output is the given onevoidclose()voidvoidInitialize the given params with aDirectoryTaskOutputInitialize the given params with a directory asFileOrDirectoryTaskOutputvoidDeprecated.fileOutputTo(SingleOutputTaskParameters params, String extension) Initialize the given params with aFileTaskOutputon a file with the given extensionforEachPdfOutput(Consumer<org.sejda.sambox.pdmodel.PDDocument> consumer) Applies the given consumer to every generated outputforEachRawOutput(Consumer<Path> consumer) Applies the given consumer to every generated outputforPdfOutput(String filename, Consumer<org.sejda.sambox.pdmodel.PDDocument> consumer) Applies the given consumer to generated output PDF document with the given nameforPdfOutput(Consumer<org.sejda.sambox.pdmodel.PDDocument> consumer) Applies the given consumer to generated single output PDF documentforRawOutput(String filename, Consumer<Path> consumer) forRawOutput(Consumer<Path> consumer) Applies the given consumer to a single generated outputvoidvoidvoidInitialize the given params with a pdf file asFileOrDirectoryTaskOutputInitialize the given params with aFileTaskOutput
-
Constructor Details
-
TaskTestContext
public TaskTestContext()
-
-
Method Details
-
pdfOutputTo
Initialize the given params with aFileTaskOutput- Parameters:
params-- Returns:
- Throws:
IOException
-
fileOutputTo
public TaskTestContext fileOutputTo(SingleOutputTaskParameters params, String extension) throws IOException Initialize the given params with aFileTaskOutputon a file with the given extension- Parameters:
params-extension-- Returns:
- Throws:
IOException
-
directoryOutputTo
Initialize the given params with aDirectoryTaskOutput- Parameters:
params-- Returns:
- Throws:
IOException
-
directoryOutputTo
public TaskTestContext directoryOutputTo(SingleOrMultipleOutputTaskParameters params) throws IOException Initialize the given params with a directory asFileOrDirectoryTaskOutput- Parameters:
params-- Returns:
- Throws:
IOException
-
pdfOutputTo
Initialize the given params with a pdf file asFileOrDirectoryTaskOutput- Parameters:
params-- Returns:
- Throws:
IOException
-
assertCreator
asserts the creator has been set to the info dictionary- Returns:
-
assertVersion
asserts the PDF version of the output is the given one- Returns:
-
assertPages
asserts the output document has that number of pages- Returns:
-
assertPages
asserts the output document with the given filename exists and has that number of pages. This assert will work only for multiple output task.- Returns:
- Throws:
IOException
-
assertHasOutline
- Parameters:
hasOutline-
-
assertHasAcroforms
assert that the document has an acroform with some field in it- Parameters:
hasForms-
-
assertOutlineContains
assert the document outline contains an item with the given title- Parameters:
title-- Returns:
-
assertOutlineDoesntContain
assert the document outline doesn't contain an item with the given title- Parameters:
title-- Returns:
-
assertOutputSize
asserts that a multiple output task has generated the given number of output files, hidden files don't count- Returns:
- Throws:
IOException
-
assertOutputSizeIncludingHidden
asserts that a multiple output task has generated the given number of output files, including hidden files (in case the task is expected to have some hidden leftover)- Parameters:
size-- Returns:
-
assertEmptyMultipleOutput
asserts that a multiple output task has generated no output- Returns:
-
assertOutputContainsFilenames
asserts that a multiple output task has generated the given file names- Parameters:
filenames-- Returns:
-
forEachPdfOutput
public TaskTestContext forEachPdfOutput(Consumer<org.sejda.sambox.pdmodel.PDDocument> consumer) throws IOException Applies the given consumer to every generated output- Parameters:
consumer-- Returns:
- Throws:
IOException
-
forPdfOutput
Applies the given consumer to generated single output PDF document- Parameters:
consumer-- Returns:
- Throws:
IOException
-
forPdfOutput
public TaskTestContext forPdfOutput(String filename, Consumer<org.sejda.sambox.pdmodel.PDDocument> consumer) throws IOException Applies the given consumer to generated output PDF document with the given name- Parameters:
consumer-- Returns:
- Throws:
IOException
-
forEachRawOutput
Applies the given consumer to every generated output- Parameters:
consumer-- Returns:
- Throws:
IOException
-
forRawOutput
Applies the given consumer to a single generated output- Parameters:
consumer-- Returns:
- Throws:
IOException
-
forRawOutput
-
assertTaskCompleted
Asserts that the task has completed and generated some output. If a single output task, then the output is paresed and aPDDocumentis returned- Returns:
- Throws:
IOException
-
assertTaskCompleted
Asserts that the task has completed and generated some output. If the task generated a single output, then the output is parsed and aPDDocumentis returned- Parameters:
password-- Returns:
- Throws:
IOException
-
getTaskWarnings
-
listenForTaskFailure
public void listenForTaskFailure() -
listenForTaskStart
public void listenForTaskStart() -
assertTaskFailed
-
assertTaskFailed
-
assertTaskFailed
-
assertFailedSource
-
assertTaskStarted
-
assertTaskDidNotFail
-
expectTaskWillProduceWarnings
Deprecated. -
listenForTaskWarnings
public void listenForTaskWarnings() -
assertTaskWarning
-
assertTaskWarnings
-
assertNoTaskWarnings
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getFileOutput
-
assertSimilar
- Throws:
IOException
-
assertSimilar
-
assertSimilar
-
assertSimilar
public void assertSimilar(String filename, String resourcePath, double similarityThreshold) throws IOException - Throws:
IOException
-
debug
-
debugTo
-