Updated documentation for JSONText.java.

Addressed issue #44
This commit is contained in:
top19 2020-05-01 14:40:15 +01:00
parent 5d4ed5441b
commit 155dee3a55

View file

@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
/** /**
* Class that contains methods which will be used to test that the JSON package classes are * Class that contains methods which will be used to test that the JSON package classes are
* correctly loading and saving to and from the JSON file. * correctly loading and saving to and from the JSON file.
*
* @author Tom Perry [top19] * @author Tom Perry [top19]
* @version 0.1 Initial development. * @version 0.1 Initial development.
* @see JsonProcessing * @see JsonProcessing
@ -25,14 +26,23 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
*/ */
public class JSONTest { public class JSONTest {
// //////////////// //
// Class variables. //
// //////////////// //
static LinkedList<DictionaryEntry> testList; static LinkedList<DictionaryEntry> testList;
LinkedList<DictionaryEntry> loadedList; LinkedList<DictionaryEntry> loadedList;
static File testFile; static File testFile;
static JsonProcessing processor = new JsonProcessing(); static JsonProcessing processor = new JsonProcessing();
// ////////////// //
// Class methods. //
// ////////////// //
/** /**
* Setup method that is run before all of the tests, setting up a test list of DictionaryEntry's that it saved to a JSON test file. * Setup method that is run before all of the tests, setting up a test list of DictionaryEntry's that it saved to a JSON test file.
*
* @see JsonProcessing * @see JsonProcessing
* @see DictionaryEntry * @see DictionaryEntry
*/ */
@ -52,7 +62,21 @@ public class JSONTest {
} }
/** /**
* JUnit test to check that the JSON file has been correctly loaded. * Method that is ran after the JUnit tests have finished to remove the JSON test file from program.
*/
@AfterAll
public static void deleteFile() {
testFile.delete();
}
// //////// //
// Methods. //
// //////// //
/**
* JUnit test to check that the JSON file has been correctly loaded. This works by loading the test file and check
* its contents match the list that was saved to it.
*
* @see JsonProcessing * @see JsonProcessing
* @see DictionaryEntry * @see DictionaryEntry
*/ */
@ -65,8 +89,10 @@ public class JSONTest {
} }
/** /**
* JUnit test to check that any changes to the list of definitions are * JUnit test to check that changes to the list of definitions are
* updated and saved to the JSON file accordingly. * updated and saved to the JSON file accordingly. This is done by adding a new item to the JSON test list and
* saving it to the file before reloading it to check the loaded list matches the updated test list.
*
* @see JsonProcessing * @see JsonProcessing
* @see DictionaryEntry * @see DictionaryEntry
*/ */
@ -80,12 +106,5 @@ public class JSONTest {
assertArrayEquals(testList.toArray(), loadedList.toArray()); assertArrayEquals(testList.toArray(), loadedList.toArray());
} }
/**
* Method that is ran after the JUnit tests have finished to remove the JSON test file from program.
*/
@AfterAll
public static void deleteFile() {
testFile.delete();
}
} }