Skip to content

Commit

Permalink
OpenPeppol eDEC Specifications
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-kumar committed Mar 18, 2022
1 parent 938b0a1 commit 96be12a
Show file tree
Hide file tree
Showing 10 changed files with 582 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ public interface Period {
Date getTo();

default boolean isCurrent(Date date) {
return (getFrom() == null || date.after(getFrom())) && (getTo() == null || date.before(getTo()));
return (getFrom() == null || isFromPeriodValid(date)) && (getTo() == null || isToPeriodValid(date));
}

default boolean isFromPeriodValid(Date date) {
return (getFrom().equals(date) || getFrom().before(date));
}

default boolean isToPeriodValid(Date date) {
return (getTo().equals(date) || getTo().after(date));
}

default boolean isCurrent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ public class HeaderTest {
public void simple() {
Header header = Header.newInstance()
.sender(ParticipantIdentifier.of("9908:987654325"))
.receiver(ParticipantIdentifier.of("9908:123456785"))
.process(ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii04:ver1.0"))
.documentType(DocumentTypeIdentifier.of("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice" +
"##urn:www.cenbii.eu:transaction:biicoretrdm010:ver1.0:#urn:www.peppol.eu:bis:peppol4a:ver1.0::2.0"))
.instanceType(InstanceType.of("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2", "Invoice", "2.0"))
.receiver(ParticipantIdentifier.of("9908:923829644"))
.process(ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0"))
.documentType(DocumentTypeIdentifier.of("urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2::CreditNote" +
"##urn:www.cenbii.eu:transaction:biitrns014:ver2.0:extended:urn:www.peppol.eu:bis:peppol5a:ver2.0::2.1"))
.instanceType(InstanceType.of("urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2", "CreditNote", "2.1"))
.creationTimestamp(new Date())
.identifier(InstanceIdentifier.generateUUID());

Header header2 = Header.newInstance()
.sender(ParticipantIdentifier.of("9908:987654325"))
.receiver(ParticipantIdentifier.of("9908:123456785"))
.process(ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii04:ver1.0"))
.documentType(DocumentTypeIdentifier.of("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice" +
"##urn:www.cenbii.eu:transaction:biicoretrdm010:ver1.0:#urn:www.peppol.eu:bis:peppol4a:ver1.0::2.0"))
.instanceType(InstanceType.of("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2", "Invoice", "2.0"))
.receiver(ParticipantIdentifier.of("9908:923829644"))
.process(ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0", Scheme.of("cenbii-procid-ubl")))
.documentType(DocumentTypeIdentifier.of("urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2::CreditNote" +
"##urn:www.cenbii.eu:transaction:biitrns014:ver2.0:extended:urn:www.peppol.eu:bis:peppol5a:ver2.0::2.1"))
.instanceType(InstanceType.of("urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2", "CreditNote", "2.1"))
.creationTimestamp(header.getCreationTimestamp())
.identifier(InstanceIdentifier.of(header.getIdentifier().getIdentifier()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Getter
public enum PeppolIcd implements Icd {

// As per latest code list release v7.3 from 2020-11-16 : https://docs.peppol.eu/edelivery/codelists/
// The latest code list release is v8.0 from 2022-01-20: https://docs.peppol.eu/edelivery/codelists/

// Internationally approved ICDs
FR_SIRENE("FR:SIRENE", "0002", "Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.)"),
Expand Down Expand Up @@ -72,11 +72,17 @@ public enum PeppolIcd implements Icd {
IT_VAT("IT:VAT", "9906", "Ufficio responsabile gestione partite IVA"),
IT_CF("IT:CF", "9907", "TAX Authority"),
NO_ORGNR("NO:ORGNR", "9908", "The Brønnøysund Register Centre"),
@Deprecated
NO_VAT("NO:VAT", "9909", "Enhetsregisteret ved Bronnoysundregisterne"),
HU_VAT("HU:VAT", "9910", "Hungarian VAT number"),
@Deprecated
EU_VAT("EU:VAT", "9912", "National ministries of Economy"),
EU_REID("EU:REID", "9913", "Business Registers Network"),
AT_VAT("AT:VAT", "9914", "Österreichische Umsatzsteuer-Identifikationsnummer"),
AT_GOV("AT:GOV", "9915", "Österreichisches Verwaltungs bzw. Organisationskennzeichen"),
@Deprecated
AT_CID("AT:CID", "9916", "Firmenidentifikationsnummer der Statistik Austria"),
@Deprecated
IS_KT("IS:KT", "9917", "Icelandic National Registry"),
IBAN("IBAN", "9918", "SOCIETY FOR WORLDWIDE INTERBANK FINANCIAL, TELECOMMUNICATION S.W.I.F.T"),
AT_KUR("AT:KUR", "9919", "Kennziffer des Unternehmensregisters"),
Expand Down Expand Up @@ -118,6 +124,7 @@ public enum PeppolIcd implements Icd {
@Deprecated
NL_ION("NL:OIN", "9954", "Dutch Originator's Identification Number"),
SE_VAT("SE:VAT", "9955", "Swedish VAT number"),
@Deprecated
BE_CBE("BE:CBE", "9956", "Belgian Crossroad Bank of Enterprises"),
FR_VAT("FR:VAT", "9957", "French VAT number"),
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,132 @@ public void documentIdentifiers() throws Exception {
assertEquals(result.size(), 9);
}

@Test
public void rejectNoLongerActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void processActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();


ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0));
}

@Test
public void rejectNotYetActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void missingBothServiceActivationDateAndServiceExpirationDate() throws Exception {
// Still valid : CANNOT reject messages if both ServiceActivationDate and ServiceExpirationDate values are missing
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0));
}

@Test
public void missingServiceActivationDateButServiceExpirationDateIsValid() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0));
}

@Test
public void missingServiceExpirationDateButServiceActivationDateIsValid() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0));
}

@Test
public void missingServiceActivationDateAndInvalidServiceExpirationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void missingServiceExpirationDateAndInvalidServiceActivationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void inValidServiceExpirationDateAndServiceActivationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void serviceMetadata() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,132 @@ public void busdoxServiceMetadata() throws Exception {
);
}

@Test
public void rejectNoLongerActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void processActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();


ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0));
}

@Test
public void rejectNotYetActiveEndpoints() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-923829644.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void missingBothServiceActivationDateAndServiceExpirationDate() throws Exception {
// Still valid : CANNOT reject messages if both ServiceActivationDate and ServiceExpirationDate values are missing
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0));
}

@Test
public void missingServiceActivationDateButServiceExpirationDateIsValid() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0));
}

@Test
public void missingServiceExpirationDateButServiceActivationDateIsValid() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-12345678.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

assertNotNull(serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0));
}

@Test
public void missingServiceActivationDateAndInvalidServiceExpirationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_1_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void missingServiceExpirationDateAndInvalidServiceActivationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS2_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void inValidServiceExpirationDateAndServiceActivationDate() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
getClass().getResourceAsStream("/busdox-servicemetadata-9908-98765432.xml"))).getContent();

ProcessIdentifier processIdentifier = ProcessIdentifier.of("urn:www.cenbii.eu:profile:bii05:ver2.0");
ServiceInformation<Endpoint> serviceInformation = result.getServiceInformation();

try {
serviceInformation.getEndpoint(processIdentifier, TransportProfile.PEPPOL_AS4_2_0);
fail("Expected exception.");
} catch (EndpointNotFoundException e) {
// Expected
}
}

@Test
public void serviceMetadataRedirect() throws Exception {
ServiceMetadata result = reader.parseServiceMetadata(new FetcherResponse(
Expand Down
Loading

0 comments on commit 96be12a

Please sign in to comment.