diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterCustomXMLTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterCustomXMLTest.java index 42277aba..72f9285b 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterCustomXMLTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterCustomXMLTest.java @@ -49,7 +49,7 @@ public class MustangReaderWriterCustomXMLTest extends TestCase { // //////// TESTS // ////////////////////////////////////////////////////////////////////////////////////////// - public void testCustomZF2Export() throws Exception { + public void testCustomZF2Export() { final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506custom.pdf"; // the writing part @@ -288,10 +288,10 @@ public class MustangReaderWriterCustomXMLTest extends TestCase { * ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds * metadata, writes to @{code ./target/testout-*} and then imports to check the * values. It would not make sense to have it run before the less complex - * importer test (which is probably redundant) --> as only Name Ascending is + * importer test (which is probably redundant). As only Name Ascending is * supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export */ - public void testCustomZF1Export() throws Exception { + public void testCustomZF1Export() { final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505custom.pdf"; // the writing part diff --git a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java index 74dee7e6..db00461a 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/MustangReaderWriterEdgeTest.java @@ -170,13 +170,11 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase { /** * The importer test imports from ./src/test/MustangGnuaccountingBeispielRE-20170509_505.pdf to check the values. - * --> as only Name Ascending is supported for Test Unit sequence, I renamed the this test-A-Export to run before + * As only Name Ascending is supported for Test Unit sequence, I renamed the this test-A-Import to run before * testZExport - * - * @throws IOException */ - public void testAImport() throws IOException { + public void testAImport() { InputStream inputStream = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf"); ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream); @@ -195,12 +193,11 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase { /** * The exporter test bases on @{code ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds metadata, - * writes - * to @{code ./target/testout-*} and then imports to check the values. - * It would not make sense to have it run before the less complex importer test (which is probably redundant) - * --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export + * writes to @{code ./target/testout-*} and then imports to check the values. + * It would not make sense to have it run before the less complex importer test (which is probably redundant). + * As only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export */ - public void testEdgeExport() throws Exception { + public void testEdgeExport() { final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505newEdge.pdf"; // the writing part @@ -218,6 +215,8 @@ public class MustangReaderWriterEdgeTest extends MustangReaderTestCase { String theXML = new String(ze.getProvider().getXML()); assertTrue(theXML.contains(" as only Name Ascending is supported for Test Unit sequence, I - * renamed the this test-A-Export to run before testZExport - * - * @throws IOException + * The importer test imports from ./src/test/MustangGnuaccountingBeispielRE-20170509_505.pdf to check the + * values. As only Name Ascending is supported for Test Unit sequence, I renamed the this testAImport + * to run before testZExport */ - public void testAImport() throws IOException { + public void testAImport() { InputStream inputStream = this.getClass().getResourceAsStream("/MustangGnuaccountingBeispielRE-20170509_505.pdf"); ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream); @@ -206,7 +203,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase { assertEquals(zi.getForeignReference(), "RE-20170509/505"); } - public void testForeignImport() throws IOException { + public void testForeignImport() { InputStream inputStream = this.getClass().getResourceAsStream("/zugferd_invoice.pdf"); ZUGFeRDImporter zi = new ZUGFeRDImporter(inputStream); @@ -343,10 +340,10 @@ public class MustangReaderWriterTest extends MustangReaderTestCase { * ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds * metadata, writes to @{code ./target/testout-*} and then imports to check the * values. It would not make sense to have it run before the less complex - * importer test (which is probably redundant) --> as only Name Ascending is + * importer test (which is probably redundant). As only Name Ascending is * supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export */ - public void testZExport() throws Exception { + public void testZExport() { final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20171118_506new.pdf"; @@ -370,6 +367,8 @@ public class MustangReaderWriterTest extends MustangReaderTestCase { // assertFalse(pdfContent.indexOf("zf") == -1); // assertFalse(pdfContent.indexOf("urn:zugferd:pdfa:CrossIndustryDocument:invoice:2p0#") == -1); + } catch (IOException e) { + fail("IOException should not happen in testZExport"); } // now check the contents (like MustangReaderTest) @@ -423,11 +422,7 @@ public class MustangReaderWriterTest extends MustangReaderTestCase { assertEquals(zi.getForeignReference(), getNumber()); } - /** - * @throws Exception - * @Test(expected = IndexOutOfBoundsException.class) - */ - public void testExceptionOnPDF14() throws Exception { + public void testExceptionOnPDF14() { final String TARGET_PDF = "./target/testout-MustangGnuaccountingBeispielRE-20170509_505new.pdf"; diff --git a/src/test/java/org/mustangproject/ZUGFeRD/ResourceUtilities.java b/src/test/java/org/mustangproject/ZUGFeRD/ResourceUtilities.java index 2a36e4ef..cf908e72 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/ResourceUtilities.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/ResourceUtilities.java @@ -34,6 +34,10 @@ public class ResourceUtilities { /** * Loading a File into a String using a certain encoding and file path + * @param encoding the charset used in the file + * @param path the path to the file + * @return the file contents as a String + * @throws IOException if the file cannot be read */ public static String readFile(Charset encoding, String path) throws IOException { byte[] content = Files.readAllBytes(Paths.get(path)); @@ -42,6 +46,10 @@ public class ResourceUtilities { /** * Saving a String as a file to a certain file path + * @param encoding the charset used in the file + * @param path the path to the file + * @param content the contents of the file + * @throws FileNotFoundException if the file cannot be found */ public static void saveFile(Charset encoding, String path, String content) throws FileNotFoundException { @@ -147,7 +155,7 @@ public class ResourceUtilities { /** * To fix the 3 slashes bug for File URI: For example: - * file:/C:/work/test.txt -> file:///C:/work/test.txt + * file:/C:/work/test.txt gives file:///C:/work/test.txt * * @param u - the File URI * @return the String of the URI diff --git a/src/test/java/org/mustangproject/ZUGFeRD/VersionMigrationTest.java b/src/test/java/org/mustangproject/ZUGFeRD/VersionMigrationTest.java index ab628dcd..62e83b67 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/VersionMigrationTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/VersionMigrationTest.java @@ -41,7 +41,7 @@ import static org.junit.Assert.assertFalse; * will be migrated to src/test/resources/migration/output. * If there is a similar named file as test reference src/test/resources/migration/reference a test * will be triggered for every single file. - *

+ * * Note: Any 'ZUGFeRD1' will be exchanged to 'ZUGFeRD2' during migration and adequate reference will be searched for. */ @RunWith(Parameterized.class) diff --git a/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java b/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java index 21f9131f..c0c56af4 100644 --- a/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java +++ b/src/test/java/org/mustangproject/ZUGFeRD/ZF2EdgeTest.java @@ -170,13 +170,10 @@ public class ZF2EdgeTest extends MustangReaderTestCase { // //////// TESTS ////////////////////////////////////////////////////////////////////////////////////////// /** - * The exporter test bases on @{code ./src/test/MustangGnuaccountingBeispielRE-20140703_502blanko.pdf}, adds metadata, - * writes - * to @{code ./target/testout-*} and then imports to check the values. - * It would not make sense to have it run before the less complex importer test (which is probably redundant) - * --> as only Name Ascending is supported for Test Unit sequence, I renamed the Exporter Test test-Z-Export + * The exporter test bases on @{code ./src/test/MustangGnuaccountingBeispielRE-20170509_505PDFA3.pdf}, adds metadata, + * writes to @{code ./target/testout-*} and then imports to check the values. */ - public void testEdgeExport() throws Exception { + public void testEdgeExport() { // the writing part @@ -194,6 +191,8 @@ public class ZF2EdgeTest extends MustangReaderTestCase { String theXML = new String(ze.getProvider().getXML()); assertTrue(theXML.contains("