From e1cedcc2f4f389eff31af1ff9620616811230c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20Sta=CC=88rk?= Date: Thu, 6 Aug 2020 16:08:40 +0200 Subject: [PATCH] automated tests for xr 2.0 --- .../validator/XMLValidatorTest.java | 14 +- validator/src/test/resources/invalidXRv2.xml | 193 +++++++++++++++++ validator/src/test/resources/validXRv2.xml | 202 ++++++++++++++++++ 3 files changed, 407 insertions(+), 2 deletions(-) create mode 100644 validator/src/test/resources/invalidXRv2.xml create mode 100644 validator/src/test/resources/validXRv2.xml diff --git a/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java b/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java index 805bbf29..a9419f36 100644 --- a/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java +++ b/validator/src/test/java/org/mustangproject/validator/XMLValidatorTest.java @@ -1,5 +1,7 @@ package org.mustangproject.validator; + import static org.xmlunit.assertj.XmlAssert.assertThat; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -105,8 +107,8 @@ public class XMLValidatorTest extends ResourceCase { .isGreaterThan(1); //2 errors are OK because there is a known bug - assertThat(content).valueByXPath("//error[@type=\"4\"]") - .asString() + assertThat(content).valueByXPath("//error[@type=\"4\"]") + .asString() .contains( "In Deutschland sind die Profile MINIMUM und BASIC WL nur als Buchungshilfe (TypeCode: 751) zugelassen."); @@ -205,6 +207,14 @@ public class XMLValidatorTest extends ResourceCase { String content = xpath.evaluate("/validation/summary/@status", source); assertEquals("valid", content); + tempFile = getResourceAsFile("invalidXRv2.xml"); + xv.setFilename(tempFile.getAbsolutePath()); + xv.validate(); + + source = Input.fromString("" + xv.getXMLResult() + "").build(); + content = xpath.evaluate("/validation/summary/@status", source); + assertEquals("invalid", content); + } catch (IrrecoverableValidationError e) { // ignore, will be in XML output anyway diff --git a/validator/src/test/resources/invalidXRv2.xml b/validator/src/test/resources/invalidXRv2.xml new file mode 100644 index 00000000..43237cd2 --- /dev/null +++ b/validator/src/test/resources/invalidXRv2.xml @@ -0,0 +1,193 @@ + + + + + urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0 + + + + 1234567 + 380 + + 20180413 + + + Invoice Note Description + AAC + + + + + + 1 + + + Beratung + + + + 143.75 + + + + 30 + + + + VAT + S + 19 + + + 4743.75 + + + + + + 2 + + + Beratung + + + + 143.75 + + + + 42 + + + + VAT + S + 19 + + + 6037.5 + + + + + 90000000-03083-12 + + [Seller name] + + GmbH + + + 12345 + [Seller city] + DE + + + ATU123456789 + + + + 138 + [Buyer name] + + GmbH + + + Tina Tester + + 0800 123456 + + + tester@test.de + + + + 98765 + [Buyer city] + DE + + + DE12345ABC + + + + [Seller tax representative name] + + DE + + + DE124567 + + + + ABC123456789 + + + 65002278 + + + + + 68 + [Deliver to party name] + + 98765 + [Deliver to street] + 4. OG + [Deliver to city] + DE + Bayern + + + + + 20180413 + + + + + Deb. 12345 / Fact. 9876543 + EUR + + 74 + [Payee name] + + + 30 + + DE12100200000123456878 + + + + 2048.44 + VAT + 10781.25 + S + 19 + + + + 20180413 + + + 20180413 + + + + + 20180413 + + + + 10781.25 + 10781.25 + 2048.44 + 12829.69 + 12829.69 + + + + diff --git a/validator/src/test/resources/validXRv2.xml b/validator/src/test/resources/validXRv2.xml new file mode 100644 index 00000000..c6d47b05 --- /dev/null +++ b/validator/src/test/resources/validXRv2.xml @@ -0,0 +1,202 @@ + + + + + urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0 + + + + 1234567 + 380 + + 20180413 + + + Invoice Note Description + AAC + + + + + + 1 + + + Beratung + + + + 143.75 + + + + 30 + + + + VAT + S + 19 + + + 4743.75 + + + + + + 2 + + + Beratung + + + + 143.75 + + + + 42 + + + + VAT + S + 19 + + + 6037.5 + + + + + 90000000-03083-12 + + [Seller name] + + GmbH + + + Tim Tester + + 012 3456789 + + + tim.tester@test.com + + + + 12345 + [Seller city] + DE + + + ATU123456789 + + + + 138 + [Buyer name] + + GmbH + + + Tina Tester + + 0800 123456 + + + tester@test.de + + + + 98765 + [Buyer city] + DE + + + DE12345ABC + + + + [Seller tax representative name] + + DE + + + DE124567 + + + + ABC123456789 + + + 65002278 + + + + + 68 + [Deliver to party name] + + 98765 + [Deliver to street] + 4. OG + [Deliver to city] + DE + Bayern + + + + + 20180413 + + + + + Deb. 12345 / Fact. 9876543 + EUR + + 74 + [Payee name] + + + 30 + + DE12100200000123456878 + + + + 2048.44 + VAT + 10781.25 + S + 19 + + + + 20180413 + + + 20180413 + + + + + 20180413 + + + + 10781.25 + 10781.25 + 2048.44 + 12829.69 + 12829.69 + + + +