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 TestParameterValuesProvider that provides SimulationConfig objects from configs to exercise different extractor paths.

A factory for Extractor instances.

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

Constants

const Int

Public functions

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 under the conditions specified by simulationConfig.

java-static Unit
assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    peekLimit: Int,
    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!,
    peekLimit: Int,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    simulationConfig: ExtractorAsserts.SimulationConfig!
)

Asserts that an extractor consumes valid input data 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.

Constants

PEEK_LIMIT_FAIL_WITH_MAX

const val PEEK_LIMIT_FAIL_WITH_MAX = -2: Int

Public functions

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 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.

assertBehavior

java-static fun assertBehavior(
    factory: ExtractorAsserts.ExtractorFactory!,
    file: String!,
    peekLimit: Int,
    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.

peekLimit: Int

The limit that getPeekPosition is permitted to advance ahead of getPosition. LENGTH_UNSET disables enforcement of this limit. PEEK_LIMIT_FAIL_WITH_MAX forces the test to fail at the end and print the max limit that was used (which can be helpful when setting this value).

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!,
    peekLimit: Int,
    assertionConfig: ExtractorAsserts.AssertionConfig!,
    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.

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.

peekLimit: Int

The limit that getPeekPosition is permitted to advance ahead of getPosition. LENGTH_UNSET disables enforcement of this limit. PEEK_LIMIT_FAIL_WITH_MAX forces the test to fail at the end and print the max limit that was used (which can be helpful when setting this value).

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.