Class TestData

java.lang.Object
org.apache.rat.testhelpers.data.TestData
All Implemented Interfaces:
Comparable<TestData>

public final class TestData extends Object implements Comparable<TestData>
The definition of a test.
  • Constructor Details

    • TestData

      public TestData(String name, List<org.apache.commons.lang3.tuple.ImmutablePair<org.apache.commons.cli.Option,String[]>> commandLine, Consumer<Path> setupFiles, Consumer<ValidatorData> validator)
      Constructs the Test data
      Parameters:
      name - the sub name of the test. Must not be null but may be an empty string. Should be specified in Camel case for multiple words.
      commandLine - the command line for the test. May not be null but may consist of a single ImmutablePair.nullPair().
      setupFiles - the method to set up the files for the test. Must not be null.
      validator - the validator for the results of the test. Must not be null.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getOption

      public org.apache.commons.cli.Option getOption()
      The option for the test. This is the first option specified in the command line. If the command line is empty this returns null.
      Returns:
      the first option in the command line or null if there is no option.
    • getName

      public String getName()
      Get the sub name for this test.
      Returns:
      the sub name for this test.
    • getExpectedException

      public Exception getExpectedException()
      Gets the expected exception or null if no exception is expected.
      Returns:
      the expected exception or null if no exception is expected.
    • expectingException

      public boolean expectingException()
      Determines if the test is expecting an exception.
      Returns:
      true if the test is expecting to throw an exception.
    • getCommandLine

      public String[] getCommandLine()
      Gets the command line as the string objects that are normally parsed by the command line parser.
      Returns:
      the command line strings.
    • getCommandLine

      public String[] getCommandLine(String workingDir)
      Gets the command line as the string objects that are normally parsed by the command line parser. The result will include "--" to terminate a trailing multi argument option.
      Parameters:
      workingDir - the directory to add to the command line. May be null.
      Returns:
      the command line strings.
    • getArgs

      public List<? extends org.apache.commons.lang3.tuple.Pair<org.apache.commons.cli.Option,String[]>> getArgs()
      Get the arguments for the command line.
      Returns:
      the arguments for the command line as Option, String[] pairs.
    • getValidator

      public Consumer<ValidatorData> getValidator()
      Gets the validator for the test.
      Returns:
      the validator for the test.
    • setupFiles

      public void setupFiles(Path path)
      Sets up the files for the test.
      Parameters:
      path - the path to use as the base directory. Subdirectories and files may be added to this path.
    • getTestName

      public String getTestName()
      Gets the test name. This is the option concatenated with the name.
      Returns:
      the unique test name
    • getClassName

      public String getClassName()
      Gets the test name as a class name. This is based on the option concatenated with the name.
      Returns:
      the unique Java class name
    • compareTo

      public int compareTo(TestData other)
      Specified by:
      compareTo in interface Comparable<TestData>