ExtractorAsserts


@UnstableApi
class ExtractorAsserts


Assertion methods for Extractor.

Summary

Nested types

A config for the assertions made (e.g. dump file location).

Builder for AssertionConfig instances.

A factory for Extractor instances.

A config of different environments to simulate and extractor behaviours to test.

Public functions

java-static Unit
assertAllBehaviors(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!
)

Asserts that an extractor behaves correctly given valid input data.

java-static Unit
assertAllBehaviors(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    dumpFilesPrefix: String!
)

Asserts that an extractor behaves correctly given valid input data:

java-static Unit
assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
)

Asserts that an extractor consumes valid input data successfully under the conditions specified by simulationConfig.

java-static Unit
assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
)

Asserts that an extractor consumes valid input data successfully successfully under the conditions specified by simulationConfig.

java-static Unit
assertSniff(
    extractor: Extractor!,
    input: FakeExtractorInput!,
    expectedResult: Boolean
)

Asserts that sniff returns the expectedResult for a given input, retrying repeatedly when SimulatedIOException is thrown.

java-static ImmutableList<ExtractorAsserts.SimulationConfig!>!

Returns a list of arrays containing SimulationConfig objects to exercise different extractor paths.

java-static (Mutable)List<Array<Any!>!>!

Returns a list of arrays containing SimulationConfig objects to exercise different extractor paths in which the input is not sniffed.

Public functions

assertAllBehaviors

java-static fun assertAllBehaviors(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!
): Unit

Asserts that an extractor behaves correctly given valid input data.

  • Calls seek and release without calling init to check these calls do not fail.
  • Calls assertOutput with all possible combinations of "simulate" parameters.
Parameters
factory: ExtractorAsserts.ExtractorFactory!

An ExtractorFactory which creates instances of the Extractor class which is to be tested.

file: String!

The path to the input sample.

Throws
java.io.IOException

If reading from the input fails.

assertAllBehaviors

java-static fun assertAllBehaviors(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    dumpFilesPrefix: String!
): Unit

Asserts that an extractor behaves correctly given valid input data:

  • Calls seek and release without calling init to check these calls do not fail.
  • Calls assertOutput with all possible combinations of "simulate" parameters.
Parameters
factory: ExtractorAsserts.ExtractorFactory!

An ExtractorFactory which creates instances of the Extractor class which is to be tested.

file: String!

The path to the input sample.

dumpFilesPrefix: String!

The dump files prefix appended to the dump files path.

Throws
java.io.IOException

If reading from the input fails.

assertBehavior

java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit

Asserts that an extractor consumes valid input data successfully under the conditions specified by simulationConfig.

The output of the extractor is compared against prerecorded dump files whose names are derived from the file parameter as specified in the docs for dumpFilesPrefix.

Parameters
factory: ExtractorAsserts.ExtractorFactory!

An ExtractorFactory which creates instances of the Extractor class which is to be tested.

file: String!

The path to the input sample.

simulationConfig: ExtractorAsserts.SimulationConfig!

Details on the environment to simulate and behaviours to assert.

Throws
java.io.IOException

If reading from the input fails.

assertBehavior

java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
): Unit

Asserts that an extractor consumes valid input data successfully successfully under the conditions specified by simulationConfig.

The output of the extractor is compared against prerecorded dump files.

Parameters
factory: ExtractorAsserts.ExtractorFactory!

An ExtractorFactory which creates instances of the Extractor class which is to be tested.

file: String!

The input file to pass to the extractor.

assertionConfig: ExtractorAsserts.AssertionConfig!

Details of how to read and process the source and dump files.

simulationConfig: ExtractorAsserts.SimulationConfig!

Details on the environment to simulate and behaviours to assert.

Throws
java.io.IOException

If reading from the input fails.

assertSniff

java-static fun assertSniff(
    extractor: Extractor!,
    input: FakeExtractorInput!,
    expectedResult: Boolean
): Unit

Asserts that sniff returns the expectedResult for a given input, retrying repeatedly when SimulatedIOException is thrown.

Parameters
extractor: Extractor!

The extractor to test.

input: FakeExtractorInput!

The extractor input.

expectedResult: Boolean

The expected return value.

Throws
java.io.IOException

If reading from the input fails.

configs

java-static fun configs(): ImmutableList<ExtractorAsserts.SimulationConfig!>!

Returns a list of arrays containing SimulationConfig objects to exercise different extractor paths.

This is intended to be used from tests using ParameterizedRobolectricTestRunner or org.junit.runners.Parameterized.

configsNoSniffing

java-static fun configsNoSniffing(): (Mutable)List<Array<Any!>!>!

Returns a list of arrays containing SimulationConfig objects to exercise different extractor paths in which the input is not sniffed.

This is intended to be used from tests using ParameterizedRobolectricTestRunner or org.junit.runners.Parameterized.