Tests in separate methodes
This commit is contained in:
@@ -22,6 +22,7 @@ package org.mustangproject.ZUGFeRD;
|
|||||||
|
|
||||||
import org.junit.FixMethodOrder;
|
import org.junit.FixMethodOrder;
|
||||||
import org.junit.runners.MethodSorters;
|
import org.junit.runners.MethodSorters;
|
||||||
|
import org.mustangproject.ZUGFeRD.ZUGFeRDVisualizer.Language;
|
||||||
import org.mustangproject.util.ByteArraySearcher;
|
import org.mustangproject.util.ByteArraySearcher;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
@@ -40,162 +41,32 @@ public class VisualizationTest extends ResourceCase {
|
|||||||
final String TARGET_PDF_UBL = "./target/testout-Visualization-cii.pdf";
|
final String TARGET_PDF_UBL = "./target/testout-Visualization-cii.pdf";
|
||||||
|
|
||||||
public void testCIIVisualizationBasic() {
|
public void testCIIVisualizationBasic() {
|
||||||
|
this.runZUGFeRDVisualization("factur-x.xml", "factur-x-vis.fr.html", Language.FR);
|
||||||
// the writing part
|
|
||||||
String sourceFilename = "factur-x.xml";
|
|
||||||
File CIIinputFile = getResourceAsFile(sourceFilename);
|
|
||||||
|
|
||||||
String expected = null;
|
|
||||||
String result = null;
|
|
||||||
try {
|
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
|
||||||
/* remove file endings so that tests can also pass after checking
|
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.FR)
|
|
||||||
.replace("\r", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
|
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis.fr.html");
|
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
|
||||||
.replace("\r", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
|
||||||
} catch (IOException e) {
|
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
assertEquals(expected, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCIIVisualizationExtended() {
|
public void testCIIVisualizationExtended() {
|
||||||
|
this.runZUGFeRDVisualization("factur-x-extended.xml", "factur-x-vis-extended.de.html", Language.DE);
|
||||||
// the writing part
|
|
||||||
String sourceFilename = "factur-x-extended.xml";
|
|
||||||
File CIIinputFile = getResourceAsFile(sourceFilename);
|
|
||||||
|
|
||||||
String expected = null;
|
|
||||||
String result = null;
|
|
||||||
try {
|
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
|
||||||
/* remove file endings so that tests can also pass after checking
|
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.DE).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
|
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-extended.de.html");
|
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
|
||||||
.replace("\r", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
|
||||||
} catch (IOException e) {
|
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
|
||||||
} catch (SAXException e) {
|
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
assertEquals(expected, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCIIVisualizationExtended() {
|
|
||||||
|
|
||||||
// the writing part
|
|
||||||
String sourceFilename = "factur-x-extended.xml";
|
|
||||||
File CIIinputFile = getResourceAsFile(sourceFilename);
|
|
||||||
|
|
||||||
String expected = null;
|
|
||||||
String result = null;
|
|
||||||
try {
|
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
|
||||||
/* remove file endings so that tests can also pass after checking
|
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(CIIinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.DE).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
|
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-extended.de.html");
|
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
|
||||||
} catch (IOException e) {
|
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
|
||||||
} catch (ParserConfigurationException e) {
|
|
||||||
fail("ParserConfigurationException should not happen: " + e.getMessage());
|
|
||||||
} catch (SAXException e) {
|
|
||||||
fail("SAXException should not happen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
assertEquals(expected, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUBLCreditNoteVisualizationBasic() {
|
public void testUBLCreditNoteVisualizationBasic() {
|
||||||
|
this.runZUGFeRDVisualization("ubl-creditnote.xml", "factur-x-vis-ubl-creditnote.en.html", Language.EN);
|
||||||
|
}
|
||||||
|
|
||||||
// the writing part
|
public void testUBLVisualizationBasic() {
|
||||||
File UBLinputFile = getResourceAsFile("ubl-creditnote.xml");
|
this.runZUGFeRDVisualization("ubl/01.01a-INVOICE.ubl.xml", "factur-x-vis-ubl.en.html", Language.EN);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runZUGFeRDVisualization(String inputFilename, String resultFileName, Language lang) {
|
||||||
|
File CIIinputFile = getResourceAsFile(inputFilename);
|
||||||
|
|
||||||
String expected = null;
|
String expected = null;
|
||||||
String result = null;
|
String result = null;
|
||||||
try {
|
try {
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
||||||
/* remove file endings so that tests can also pass after checking
|
result = zvi.visualize(CIIinputFile.getAbsolutePath(), lang);
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN)
|
|
||||||
.replace("\r", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
|
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-ubl-creditnote.en.html");
|
File expectedResult = getResourceAsFile(resultFileName);
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8)
|
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8);
|
||||||
.replace("\r", "")
|
|
||||||
.replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
||||||
@@ -212,48 +83,17 @@ public class VisualizationTest extends ResourceCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
// Reading ZUGFeRD
|
/* remove file endings so that tests can also pass after checking
|
||||||
assertEquals(expected, result);
|
out from git with arbitrary options (which may include CSRF changes)
|
||||||
}
|
*/
|
||||||
|
assertEquals(expected.replace("\r", "")
|
||||||
public void testUBLVisualizationBasic() {
|
.replace("\n", "")
|
||||||
|
.replace("\t", "")
|
||||||
// the writing part
|
.replace(" ", ""), result.replace("\r", "")
|
||||||
File UBLinputFile = getResourceAsFile("ubl/01.01a-INVOICE.ubl.xml");
|
.replace("\n", "")
|
||||||
|
.replace("\t", "")
|
||||||
String expected = null;
|
.replace(" ", ""));
|
||||||
String result = null;
|
|
||||||
try {
|
|
||||||
ZUGFeRDVisualizer zvi = new ZUGFeRDVisualizer();
|
|
||||||
/* remove file endings so that tests can also pass after checking
|
|
||||||
out from git with arbitrary options (which may include CSRF changes)
|
|
||||||
*/
|
|
||||||
result = zvi.visualize(UBLinputFile.getAbsolutePath(), ZUGFeRDVisualizer.Language.EN).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
|
|
||||||
File expectedResult = getResourceAsFile("factur-x-vis-ubl.en.html");
|
|
||||||
expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r", "").replace("\n", "")
|
|
||||||
.replace("\t", "")
|
|
||||||
.replace(" ", "");
|
|
||||||
// remove linebreaks as well...
|
|
||||||
|
|
||||||
} catch (UnsupportedOperationException e) {
|
|
||||||
fail("UnsupportedOperationException should not happen: " + e.getMessage());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
fail("IllegalArgumentException should not happen: " + e.getMessage());
|
|
||||||
} catch (TransformerException e) {
|
|
||||||
fail("TransformerException should not happen: " + e.getMessage());
|
|
||||||
} catch (IOException e) {
|
|
||||||
fail("IOException should not happen: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
assertNotNull(result);
|
|
||||||
// Reading ZUGFeRD
|
|
||||||
assertEquals(expected, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPDFVisualizationCII() {
|
public void testPDFVisualizationCII() {
|
||||||
|
|||||||
Reference in New Issue
Block a user