+ * Use is subject to license terms. + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0. + *
+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + *
+ * See the License for the specific language governing permissions and + * limitations under the License. + *
+ * **********************************************************************
+ */
+package org.mustangproject.ZUGFeRD;
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+import org.mustangproject.CII.CIIToUBL;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class UBLTest extends ResourceCase {
+
+ public void testUBLBasic() {
+
+ // the writing part
+ CIIToUBL c2u = new CIIToUBL();
+ String sourceFilename = "factur-x.xml";
+ File input = getResourceAsFile(sourceFilename);
+ File expectedFile = getResourceAsFile("ubl-conv-ubl-output-factur-x.xml");
+ String expected = null;
+ String result = null;
+ try {
+ File tempFile = File.createTempFile("ZUGFeRD-UBL-", "-test");
+ c2u.convert(input, tempFile);
+ expected = ResourceUtilities.readFile(StandardCharsets.UTF_8, expectedFile.getAbsolutePath());
+ result = ResourceUtilities.readFile(StandardCharsets.UTF_8, tempFile.getAbsolutePath());
+ } catch (IOException e) {
+ fail("Exception should not happen: "+e.getMessage());
+ }
+
+
+ assertNotNull(result);
+ assertEquals(expected, result);
+ }
+}
diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java
new file mode 100644
index 00000000..bea917a4
--- /dev/null
+++ b/library/src/test/java/org/mustangproject/ZUGFeRD/VisualizationTest.java
@@ -0,0 +1,69 @@
+
+/** **********************************************************************
+ *
+ * Copyright 2019 Jochen Staerk
+ *
+ * Use is subject to license terms.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *********************************************************************** */
+package org.mustangproject.ZUGFeRD;
+
+import org.junit.FixMethodOrder;
+import org.junit.runners.MethodSorters;
+import org.mustangproject.CII.CIIToUBL;
+
+import javax.xml.transform.TransformerException;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class VisualizationTest extends ResourceCase {
+
+ public void testVisualizationBasic() {
+
+ // the writing part
+ CIIToUBL c2u = new CIIToUBL();
+ String sourceFilename = "factur-x.xml";
+ File input = 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(input.getAbsolutePath()).replace("\r","").replace("\n","");
+
+ File expectedResult=getResourceAsFile("factur-x.html");
+ expected = new String(Files.readAllBytes(expectedResult.toPath()), StandardCharsets.UTF_8).replace("\r","").replace("\n","");
+ // remove linebreaks as well...
+
+ } catch (TransformerException e) {
+ fail("Exception should not happen: "+e.getMessage());
+ } catch (IOException e) {
+ fail("Exception should not happen: "+e.getMessage());
+ }
+
+
+
+ assertNotNull(result);
+ // Reading ZUGFeRD
+ assertEquals(expected, result);
+ }
+}
diff --git a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java
index ac94775d..a584e8dc 100644
--- a/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java
+++ b/library/src/test/java/org/mustangproject/ZUGFeRD/XRTest.java
@@ -31,6 +31,7 @@ import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.util.Date;
import static org.xmlunit.assertj.XmlAssert.assertThat;
@@ -43,22 +44,13 @@ public class XRTest extends TestCase {
public void testXRExport() {
// the writing part
-
- String orgname = "Test company";
- String number = "123";
- String amountStr = "1.00";
- BigDecimal amount = new BigDecimal(amountStr);
- Invoice i = new Invoice().setDueDate(new Date()).setIssueDate(new Date()).setDeliveryDate(new Date())
- .setSender(new TradeParty(orgname,"teststr","55232","teststadt","DE").addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test","+49123456789","test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890","COBADEFXXX")))
- .setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE"))
- .setReferenceNumber("991-01484-64")//leitweg-id
- // not using any VAT, this is also a test of zero-rated goods:
- .setNumber(number).addItem(new Item(new Product("Testprodukt", "", "C62", BigDecimal.ZERO), amount, new BigDecimal(1.0)));
+ TradeParty recipient = new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE");
+ Invoice i = createInvoice(recipient);
ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
zf2p.setProfile(Profiles.getByName("XRechnung"));
zf2p.generateXML(i);
- String theXML = new String(zf2p.getXML());
+ String theXML = new String(zf2p.getXML(), StandardCharsets.UTF_8);
assertTrue(theXML.contains("Abrechnungszeitraum:
+ Vorausgegangene Rechnungen:
+ Abrechnungszeitraum:
+ Eigenschaften des Artikels:
+ Abrechnungszeitraum:
+ Eigenschaften des Artikels:
+ Abrechnungszeitraum:
+ Eigenschaften des Artikels:
+