Class CruTs2pt1SupplierTest
@TestInstance(PER_CLASS) @TestMethodOrder(org.junit.jupiter.api.MethodOrderer.OrderAnnotation.class) @DisplayName("Unit tests for CruTs2pt1Supplier, minus GUI") public class CruTs2pt1SupplierTest extends Object
Tests were built for edge conditions for a few specific methods, but the most significant tests run through a full file load.
Reads defaults and first and last lines from application.properties
to allow for simple replacement of data for fundamental tests.
JUnit 5.
Note: because of the nature of the exception testing these tests only work with the English language localisation.
- Author:
- Andy Evans
- Version: 1.0 01 Mar 2021
-
Field Summary
Fields Modifier and Type Field Description private DerbyConsumer
dataConsumer
Data consumer to use.private CruTs2pt1Supplier
dataSupplier
Data supplier to use.private String
defaultDatabaseDirectory
Directory database is in - gained from properties.private String
defaultDataset
Default database name - gained from properties.private String
defaultDatasetOriginal
Default source file without characters removed - gained from properties.private String
defaultFileDirectory
Directory files are in - gained from properties.private String
defaultSource
Default source file - gained from properties.private String
defaultSource1stLine
Default source file - gained from properties.private int
defaultSourceCount
Record count in default source.private String
defaultSourceLastLine
Default source file - gained from properties.private String
defaultTable
Default table name - gained from properties.private String
defaultTableOriginal
Default table name without characters removed - gained from properties.private String
propertiesDirectory
Directory for properties files.private String
store
Database location - constructed from default variables. -
Constructor Summary
Constructors Constructor Description CruTs2pt1SupplierTest()
-
Method Summary
Modifier and Type Method Description private void
connectAndProcess(String filename)
Connects to a file and processes it.void
disconnect()
Releases file.void
extraDataValueTest()
Test for file with an extra long line or extra data value.void
initialisationlTest()
This is largely checked in the full runthrough, but here we check the estimate.void
invalidDateTest()
Test for header with invalid date, e.g.(package private) void
loadData()
Runs the application to build data files.void
longDataValuesTest()
Test for file with a correct five significant figures running into each other.void
missingDataTest()
Test for file with missing data.void
missingDataValueTest()
Test for file with a missing data value.void
missingHeaderTest()
Test for data with missing header.
-
Field Details
-
propertiesDirectory
Directory for properties files. -
defaultDatabaseDirectory
Directory database is in - gained from properties. -
defaultFileDirectory
Directory files are in - gained from properties. -
defaultDataset
Default database name - gained from properties. -
defaultTable
Default table name - gained from properties. -
defaultTableOriginal
Default table name without characters removed - gained from properties. -
defaultSource
Default source file - gained from properties. -
defaultDatasetOriginal
Default source file without characters removed - gained from properties. -
defaultSource1stLine
Default source file - gained from properties. -
defaultSourceLastLine
Default source file - gained from properties. -
store
Database location - constructed from default variables. -
defaultSourceCount
private int defaultSourceCountRecord count in default source. -
dataSupplier
Data supplier to use. -
dataConsumer
Data consumer to use.
-
-
Constructor Details
-
CruTs2pt1SupplierTest
public CruTs2pt1SupplierTest()
-
-
Method Details
-
loadData
@BeforeAll @DisplayName("Load data") void loadData()Runs the application to build data files. Uses default locations from the app's META-INF/application.properties file. -
connectAndProcess
Connects to a file and processes it.Uses
classLoader.getResource()
so file must be in test "resources" directory.- Parameters:
filename
- The filename to connect to.- Throws:
Exception
- A wide variety of exceptions - see exception tests.
-
disconnect
@AfterAll @DisplayName("Releases file") public void disconnect()Releases file. -
initialisationlTest
@Order(1) @Test @DisplayName("(initialisation) -> record count estimation") public void initialisationlTest()This is largely checked in the full runthrough, but here we check the estimate. -
missingHeaderTest
@Order(2) @Test @DisplayName("(initialisation) missing header -> exception") public void missingHeaderTest()Test for data with missing header.Unfortunately, as the end point of a wide variety of exceptions, the data linker throws generic Exceptions for the GUI to pick up and display. However, the internal messages vary, so we can test those.
-
missingDataTest
@Order(3) @Test @DisplayName("(initialisation) missing data -> exception") public void missingDataTest()Test for file with missing data.Unfortunately, as the end point of a wide variety of exceptions, the data linker throws generic Exceptions for the GUI to pick up and display. However, the internal messages vary, so we can test those.
-
missingDataValueTest
@Order(4) @Test @DisplayName("(initialisation) missing data value -> exception") public void missingDataValueTest()Test for file with a missing data value.Unfortunately, as the end point of a wide variety of exceptions, the data linker throws generic Exceptions for the GUI to pick up and display. However, the internal messages vary, so we can test those.
-
extraDataValueTest
@Order(5) @Test @DisplayName("(initialisation) extra // long data -> exception") public void extraDataValueTest()Test for file with an extra long line or extra data value.Unfortunately, as the end point of a wide variety of exceptions, the data linker throws generic Exceptions for the GUI to pick up and display. However, the internal messages vary, so we can test those.
-
invalidDateTest
@Order(6) @Test @DisplayName("(initialisation) invalid date -> exception") public void invalidDateTest()Test for header with invalid date, e.g. 32/13/2004.Unfortunately, as the end point of a wide variety of exceptions, the data linker throws generic Exceptions for the GUI to pick up and display. However, the internal messages vary, so we can test those.
-
longDataValuesTest
@Order(7) @Test @DisplayName("(initialisation) long but ok data -> no exception") public void longDataValuesTest()Test for file with a correct five significant figures running into each other.This should not throw an exception as data is width (not space) delimited.
-