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.
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 benchmarkingstatic 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 runvoid
deserialize()
Deserialize the response obtained from the file.void
fetchJson()
Fetch json from the filevoid
persist()
Persist the deserialized responsevoid
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
-
Field Details
-
PARAMS_DIR
public static final java.lang.String PARAMS_DIRThe directory which contains the test parameters- See Also:
- Constant Field Values
-
BILLION
public static final double BILLIONThe 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 fileresponseType
- the response typeinitialize
- the initialize
-
-
Method Details
-
testParams
public static java.util.Collection testParams() throws java.io.FileNotFoundExceptionObtains 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.FileNotFoundExceptionDb 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.IllegalAccessExceptionChecks a json "response" (provided from the params file) from the 'index' level.- Throws:
java.lang.reflect.InvocationTargetException
- if there are problem instantiating the responsejava.lang.NoSuchMethodException
- if there are problem instantiating the responsejava.lang.InstantiationException
- if there are problem instantiating the responsejava.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.IllegalAccessExceptionDeserialize the response obtained from the file.- Throws:
java.lang.reflect.InvocationTargetException
- if there are problem instantiating the responsejava.lang.NoSuchMethodException
- if there are problem instantiating the responsejava.lang.InstantiationException
- if there are problem instantiating the responsejava.lang.IllegalAccessException
- if there are problem instantiating the response
-
persist
public void persist()Persist the deserialized response
-