Package data

Class TestDeserializationPersistence<R extends NessusResponse>

java.lang.Object
data.TestDeserializationPersistence<R>
Type Parameters:
R - the response type being tested

public class TestDeserializationPersistence<R extends NessusResponse>
extends java.lang.Object
Tests the pipeline from deserialization into persistence, and then fetching back out of the database, to ensure the re-constituted entity matches the originally deserialized entity
https://www.guru99.com/junit-parameterized-test.html#:~:text=What%20is%20Parameterized%20Test%20in,their%20inputs%20and%20expected%20results.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static double BILLION
    The constant BILLION, used to convert from nanoseconds into seconds for benchmarking
    static java.lang.String PARAMS_DIR
    The directory which contains the test parameters
  • Constructor Summary

    Constructors 
    Constructor Description
    TestDeserializationPersistence​(java.lang.String jsonFile, java.lang.Class<R> responseType, Lambda1<com.fasterxml.jackson.databind.node.ObjectNode,​java.lang.Integer> initialize)
    Instantiates a new Test deserialization persistence.
  • Method Summary

    Modifier and Type Method Description
    static void dbReset()
    Db reset performed before any of the tests run
    void deserialize()
    Deserialize the response obtained from the file.
    void fetchJson()
    Fetch json from the file
    void persist()
    Persist the deserialized response
    void run()
    Checks a json "response" (provided from the params file) from the 'index' level.
    static java.util.Collection testParams()
    Obtains the test parameters from the params directory, and produces the appropriate inputs for each test

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PARAMS_DIR

      public static final java.lang.String PARAMS_DIR
      The directory which contains the test parameters
      See Also:
      Constant Field Values
    • BILLION

      public static final double BILLION
      The constant BILLION, used to convert from nanoseconds into seconds for benchmarking
      See Also:
      Constant Field Values
  • Constructor Details

    • TestDeserializationPersistence

      public TestDeserializationPersistence​(java.lang.String jsonFile, java.lang.Class<R> responseType, Lambda1<com.fasterxml.jackson.databind.node.ObjectNode,​java.lang.Integer> initialize)
      Instantiates a new Test deserialization persistence.
      Parameters:
      jsonFile - the json file
      responseType - the response type
      initialize - the initialize
  • Method Details

    • testParams

      public static java.util.Collection testParams() throws java.io.FileNotFoundException
      Obtains the test parameters from the params directory, and produces the appropriate inputs for each test
      Returns:
      the collection
      Throws:
      java.io.FileNotFoundException - the file not found exception
    • dbReset

      @BeforeAll public static void dbReset() throws java.io.FileNotFoundException
      Db reset performed before any of the tests run
      Throws:
      java.io.FileNotFoundException - if the db reset SQL script cannot be found
    • run

      public void run() throws java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, java.lang.InstantiationException, java.lang.IllegalAccessException
      Checks a json "response" (provided from the params file) from the 'index' level.
      Throws:
      java.lang.reflect.InvocationTargetException - if there are problem instantiating the response
      java.lang.NoSuchMethodException - if there are problem instantiating the response
      java.lang.InstantiationException - if there are problem instantiating the response
      java.lang.IllegalAccessException - if there are problem instantiating the response
    • fetchJson

      public void fetchJson()
      Fetch json from the file
    • deserialize

      public void deserialize() throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException, java.lang.InstantiationException, java.lang.IllegalAccessException
      Deserialize the response obtained from the file.
      Throws:
      java.lang.reflect.InvocationTargetException - if there are problem instantiating the response
      java.lang.NoSuchMethodException - if there are problem instantiating the response
      java.lang.InstantiationException - if there are problem instantiating the response
      java.lang.IllegalAccessException - if there are problem instantiating the response
    • persist

      public void persist()
      Persist the deserialized response