├── src ├── test │ ├── resources │ │ ├── .gitkeep │ │ └── dummy.xml │ ├── .DS_Store │ └── java │ │ ├── .DS_Store │ │ └── org │ │ └── openknowledgehub │ │ ├── transformer │ │ └── sepa │ │ │ ├── TransferTransformerTest.java │ │ │ └── DirectDebitTransformerTest.java │ │ ├── api │ │ ├── assertions │ │ │ ├── SepaTransferAssert.java │ │ │ ├── DirectDebitDocumentDataAssert.java │ │ │ ├── XmlAssert.java │ │ │ ├── SepaTransferPaymentAssert.java │ │ │ ├── JSepaAssertions.java │ │ │ ├── MandateAssert.java │ │ │ ├── AccountIdentificationAssert.java │ │ │ └── DirectDebitPaymentAssert.java │ │ └── objects │ │ │ ├── MandateTestProvider.java │ │ │ ├── TestObjects.java │ │ │ ├── SepaTransferTestProvider.java │ │ │ ├── AccountIdentificationTestProvider.java │ │ │ └── DirectDebitTestProvider.java │ │ ├── data │ │ ├── configuration │ │ │ ├── LocalDateAdapterTest.java │ │ │ └── LocalDateTimeAdapterTest.java │ │ ├── transfer │ │ │ ├── SepaTransferPaymentTest.java │ │ │ ├── SepaTransferDocumentDataTest.java │ │ │ └── SepaTransferPaymentBuilderTest.java │ │ └── common │ │ │ └── AccountIdentificationTest.java │ │ └── util │ │ └── JSepaContentSanitizerTest.java ├── .DS_Store └── main │ ├── .DS_Store │ └── java │ ├── .DS_Store │ └── org │ └── openknowledgehub │ ├── data │ ├── SepaXmlDocument.java │ ├── directdebit │ │ ├── MandateType.java │ │ ├── MandateBuilder.java │ │ ├── DirectDebitDocumentBuilder.java │ │ ├── Mandate.java │ │ └── DirectDebitPaymentBuilder.java │ ├── configuration │ │ ├── LocalDateAdapter.java │ │ └── LocalDateTimeAdapter.java │ ├── transfer │ │ ├── SepaTransferPayment.java │ │ ├── SepaTransferDocumentBuilder.java │ │ ├── SepaTransferPaymentBuilder.java │ │ └── SepaTransferDocumentData.java │ └── common │ │ ├── AccountIdentificationBuilder.java │ │ └── AccountIdentification.java │ ├── dsl │ ├── AccountEndSelect.java │ ├── MandateEndSelect.java │ ├── TransformXml.java │ ├── AccountIbanSelect.java │ ├── AccountBicSelect.java │ ├── AccountStartSelect.java │ ├── DirectDebitAmountSelect.java │ ├── TransferAmountSelect.java │ ├── TransferToSelect.java │ ├── TransferStartSelect.java │ ├── AccountIdentifierSelect.java │ ├── MandateSupplier.java │ ├── DirectDebitDebitorSelect.java │ ├── DirectDebitMandateSelect.java │ ├── DirectDebitStartSelect.java │ ├── TransferEndToEndSelect.java │ ├── MandateStartSelect.java │ ├── AccountSupplier.java │ ├── TransferDateSelect.java │ ├── DirectDebitDateTimeSelect.java │ ├── DirectDebitPaymentIdentificationSelect.java │ ├── TransferEndSelect.java │ ├── AccountIdentificationSelect.java │ ├── DirectDebitEndSelect.java │ ├── impl │ │ ├── common │ │ │ ├── AccountStartSelectImpl.java │ │ │ ├── AccountEndSelectImpl.java │ │ │ ├── AccountBicSelectImpl.java │ │ │ ├── AccountIbanSelectImpl.java │ │ │ └── AccountIdentifierSelectImpl.java │ │ ├── directdebit │ │ │ ├── MandateEndSelectImpl.java │ │ │ ├── MandateStartSelectImpl.java │ │ │ ├── DirectDebitStartSelectImpl.java │ │ │ ├── DirectDebitAmountSelectImpl.java │ │ │ ├── DirectDebitMandateSelectImpl.java │ │ │ ├── DirectDebitDebitorSelectImpl.java │ │ │ ├── DirectDebitDateTimeSelectImpl.java │ │ │ ├── DirectDebitPaymentIdentificationSelectImpl.java │ │ │ └── DirectDebitEndSelectImpl.java │ │ └── transfer │ │ │ ├── TransferDateSelectImpl.java │ │ │ ├── TransferStartSelectImpl.java │ │ │ ├── TransferToSelectImpl.java │ │ │ ├── TransferEndToEndSelectImpl.java │ │ │ ├── TransferAmountSelectImpl.java │ │ │ └── TransferEndSelectImpl.java │ └── DSL.java │ ├── exception │ ├── JSepaValidationException.java │ └── JSepaException.java │ ├── transformer │ ├── JSepaTransformer.java │ └── sepa │ │ ├── TransferTransformer.java │ │ ├── DirectDebitTransformer.java │ │ └── AbstractJSepaTransformer.java │ └── util │ ├── JSepaValidator.java │ └── JSepaContentSanitizer.java ├── .DS_Store ├── .gitignore ├── .github └── workflows │ ├── deploy.yml │ ├── development.yml │ └── main.yml ├── LICENSE.txt └── README.md /src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/.DS_Store -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/src/.DS_Store -------------------------------------------------------------------------------- /src/main/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/src/main/.DS_Store -------------------------------------------------------------------------------- /src/test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/src/test/.DS_Store -------------------------------------------------------------------------------- /src/main/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/src/main/java/.DS_Store -------------------------------------------------------------------------------- /src/test/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenKnowledgeHub/jSEPA/HEAD/src/test/java/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /nbproject/ 3 | /build/ 4 | /dist/ 5 | /src/main/resources/bankdata.* 6 | .DS_STORE 7 | 8 | #VS Code 9 | .classpath 10 | .project 11 | .settings 12 | 13 | #IntelliJ 14 | .idea/ 15 | *.iml -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to the Maven Central Repository 2 | on: 3 | release: 4 | types: [ created ] 5 | workflow_dispatch: 6 | 7 | jobs: 8 | package: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - name: Set up Maven Central Repository 13 | uses: actions/setup-java@v4 14 | with: 15 | distribution: 'temurin' 16 | java-version: '17' 17 | server-id: central 18 | server-username: MAVEN_USERNAME 19 | server-password: MAVEN_PASSWORD 20 | gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 21 | gpg-passphrase: MAVEN_GPG_PASSPHRASE 22 | - name: Publish jSEPA to Maven Central 23 | run: mvn --batch-mode -Psign,publish clean deploy 24 | env: 25 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} 26 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} 27 | MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/transformer/sepa/TransferTransformerTest.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.transformer.sepa; 2 | 3 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 4 | 5 | import org.openknowledgehub.api.objects.TestObjects; 6 | import org.openknowledgehub.data.transfer.SepaTransferDocumentData; 7 | import org.openknowledgehub.transformer.JSepaTransformer; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @DisplayName("Test Transfer transformer") 13 | class TransferTransformerTest { 14 | 15 | JSepaTransformer underTest; 16 | 17 | @BeforeEach 18 | void setUp() { 19 | underTest = new TransferTransformer(); 20 | } 21 | 22 | @Test 23 | @DisplayName("Should transform valid SepaTransferDocumentData") 24 | void testTransform() { 25 | final var transformedXml = 26 | underTest.transform(TestObjects.transfer().document().defaultDocument()); 27 | 28 | jSepaAssertThat(transformedXml).isNotNull().isInAValidTransferShape(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/transformer/sepa/DirectDebitTransformerTest.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.transformer.sepa; 2 | 3 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 4 | 5 | import org.openknowledgehub.api.objects.TestObjects; 6 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentData; 7 | import org.openknowledgehub.transformer.JSepaTransformer; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.DisplayName; 10 | import org.junit.jupiter.api.Test; 11 | 12 | @DisplayName("Test DirectDebit transformer") 13 | class DirectDebitTransformerTest { 14 | 15 | JSepaTransformer underTest; 16 | 17 | @BeforeEach 18 | void setUp() { 19 | underTest = new DirectDebitTransformer(); 20 | } 21 | 22 | @Test 23 | @DisplayName("Should transform valid DirectDebitDocumentData") 24 | void testTransform() { 25 | final var transformedXml = 26 | underTest.transform(TestObjects.directDebit().document().defaultDocument()); 27 | 28 | jSepaAssertThat(transformedXml).isNotNull().isInAValidDirectDebitShape(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright © 2021-2025 OpenKnowledgeHub. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/SepaXmlDocument.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data; 24 | 25 | public interface SepaXmlDocument {} 26 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/SepaTransferAssert.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.api.assertions; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.openknowledgehub.data.transfer.SepaTransferDocumentData; 6 | import java.time.LocalDateTime; 7 | import org.assertj.core.api.AbstractAssert; 8 | 9 | public class SepaTransferAssert 10 | extends AbstractAssert { 11 | protected SepaTransferAssert(SepaTransferDocumentData sepaTransferDocumentData) { 12 | super(sepaTransferDocumentData, SepaTransferAssert.class); 13 | } 14 | 15 | public SepaTransferAssert hasMessageId(String expectedMessageId) { 16 | assertThat(actual.getMessageId()).isEqualTo(expectedMessageId); 17 | 18 | return this; 19 | } 20 | 21 | public SepaTransferAssert hasDateOfExecution(LocalDateTime expectedDateOfExecution) { 22 | assertThat(actual.getDateOfExecution()).isEqualTo(expectedDateOfExecution); 23 | 24 | return this; 25 | } 26 | 27 | public SepaTransferAssert isEmpty() { 28 | assertThat(actual.getCreationTime()).isNull(); 29 | assertThat(actual.getPayer()).isNull(); 30 | assertThat(actual.getMessageId()).isNull(); 31 | assertThat(actual.getDateOfExecution()).isNull(); 32 | assertThat(actual.getPayments()).isNull(); 33 | 34 | return this; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountEndSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface AccountEndSelect extends AccountSupplier{} 26 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/MandateEndSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface MandateEndSelect extends MandateSupplier {} 26 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransformXml.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface TransformXml { 26 | String toXml(); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountIbanSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface AccountIbanSelect { 26 | AccountEndSelect iban(String iban); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountBicSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | 26 | public interface AccountBicSelect { 27 | 28 | AccountIbanSelect bic(String bic); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountStartSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface AccountStartSelect { 26 | AccountIdentifierSelect name(String name); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitAmountSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitAmountSelect { 26 | DirectDebitDebitorSelect receive(double amount); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferAmountSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | 26 | public interface TransferAmountSelect { 27 | TransferEndToEndSelect amount(double amount); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferToSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface TransferToSelect { 26 | TransferAmountSelect to(AccountSupplier accountSupplier); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferStartSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface TransferStartSelect { 26 | TransferDateSelect from(AccountSupplier accountSupplier); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountIdentifierSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface AccountIdentifierSelect { 26 | 27 | AccountBicSelect identification(String identification); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/MandateSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import org.openknowledgehub.data.directdebit.Mandate; 26 | 27 | public interface MandateSupplier { 28 | Mandate get(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitDebitorSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitDebitorSelect { 26 | DirectDebitDateTimeSelect from(AccountSupplier accountSupplier); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitMandateSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitMandateSelect { 26 | DirectDebitEndSelect overMandate(MandateSupplier mandateSupplier); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitStartSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitStartSelect { 26 | 27 | DirectDebitAmountSelect creditor(AccountSupplier accountSupplier); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferEndToEndSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface TransferEndToEndSelect { 26 | 27 | TransferEndSelect withEndToEndIdentifier(String endToEndIdentifier); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/MandateStartSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import java.time.LocalDate; 26 | 27 | public interface MandateStartSelect { 28 | MandateEndSelect issuedAt(LocalDate issuedAt); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountSupplier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | 27 | public interface AccountSupplier { 28 | AccountIdentification get(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferDateSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import java.time.LocalDateTime; 26 | 27 | public interface TransferDateSelect { 28 | TransferToSelect on(LocalDateTime localDateTime); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitDateTimeSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import java.time.LocalDate; 26 | 27 | public interface DirectDebitDateTimeSelect { 28 | DirectDebitPaymentIdentificationSelect on(LocalDate directDebitDueAt); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitPaymentIdentificationSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitPaymentIdentificationSelect { 26 | DirectDebitMandateSelect withPaymentIdentification(String paymentIdentification); 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/TransferEndSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface TransferEndSelect extends TransformXml { 26 | TransferEndSelect withReasonForPayment(String reasonForPayment); 27 | 28 | TransferToSelect and(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/exception/JSepaValidationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.exception; 24 | 25 | public class JSepaValidationException extends JSepaException { 26 | public JSepaValidationException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/AccountIdentificationSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface AccountIdentificationSelect { 26 | String getName(); 27 | 28 | String getIdentifier(); 29 | 30 | String getBic(); 31 | 32 | String getIban(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DirectDebitEndSelect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | public interface DirectDebitEndSelect extends TransformXml { 26 | DirectDebitEndSelect withReasonForPayment(String reasonForPayment); 27 | 28 | DirectDebitAmountSelect and(); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/exception/JSepaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.exception; 24 | 25 | public class JSepaException extends RuntimeException { 26 | public JSepaException(String message) { 27 | super(message); 28 | } 29 | 30 | public JSepaException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/DirectDebitDocumentDataAssert.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.api.assertions; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | 5 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentData; 6 | import java.time.LocalDateTime; 7 | import java.time.temporal.ChronoUnit; 8 | import org.assertj.core.api.AbstractAssert; 9 | import org.assertj.core.data.TemporalUnitWithinOffset; 10 | 11 | public class DirectDebitDocumentDataAssert 12 | extends AbstractAssert { 13 | protected DirectDebitDocumentDataAssert(DirectDebitDocumentData directDebitDocumentData) { 14 | super(directDebitDocumentData, DirectDebitDocumentDataAssert.class); 15 | } 16 | 17 | public DirectDebitDocumentDataAssert isEmpty() { 18 | assertThat(actual.getCreationTime()).isNull(); 19 | assertThat(actual.getMessageId()).isNull(); 20 | assertThat(actual.getCreditor()).isNull(); 21 | assertThat(actual.getPayments()).isNull(); 22 | assertThat(actual.getPaymentMethod()).isNull(); 23 | 24 | return this; 25 | } 26 | 27 | public DirectDebitDocumentDataAssert hasMessageId(String expectedMessageId) { 28 | assertThat(actual.getMessageId()).isEqualTo(expectedMessageId); 29 | 30 | return this; 31 | } 32 | 33 | public DirectDebitDocumentDataAssert hasCreationTimeCloseToNow() { 34 | assertThat(actual.getCreationTime()) 35 | .isCloseTo(LocalDateTime.now(), new TemporalUnitWithinOffset(500, ChronoUnit.MILLIS)); 36 | 37 | return this; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/transformer/JSepaTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.transformer; 24 | 25 | import org.openknowledgehub.data.SepaXmlDocument; 26 | import org.openknowledgehub.exception.JSepaException; 27 | 28 | public interface JSepaTransformer { 29 | 30 | String transform(I sourceDocument) throws JSepaException; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/directdebit/MandateType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.directdebit; 24 | 25 | import jakarta.xml.bind.annotation.XmlEnum; 26 | import jakarta.xml.bind.annotation.XmlEnumValue; 27 | 28 | @XmlEnum 29 | public enum MandateType { 30 | @XmlEnumValue("FRST") 31 | FIRST, 32 | 33 | @XmlEnumValue("RCUR") 34 | RECURRING, 35 | 36 | @XmlEnumValue("FNAL") 37 | FINAL, 38 | 39 | @XmlEnumValue("OOFF") 40 | ONE_OFF, 41 | 42 | @XmlEnumValue("RPRE") 43 | REPRESENTED 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/common/AccountStartSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.common; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentificationBuilder; 26 | import org.openknowledgehub.dsl.AccountIdentifierSelect; 27 | import org.openknowledgehub.dsl.AccountStartSelect; 28 | 29 | public class AccountStartSelectImpl implements AccountStartSelect { 30 | 31 | @Override 32 | public AccountIdentifierSelect name(String name) { 33 | return new AccountIdentifierSelectImpl(AccountIdentificationBuilder.withName(name)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/objects/MandateTestProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.objects; 24 | 25 | import org.openknowledgehub.data.directdebit.Mandate; 26 | import org.openknowledgehub.data.directdebit.MandateType; 27 | import java.time.LocalDate; 28 | 29 | public class MandateTestProvider { 30 | public static final String MANDATE_ID = "MandateId"; 31 | public static final LocalDate ISSUED_AT = LocalDate.of(2019, 1, 1); 32 | public static final MandateType MANDATE_TYPE = MandateType.ONE_OFF; 33 | 34 | public Mandate defaultMandate() { 35 | return new Mandate(MANDATE_ID, ISSUED_AT, MANDATE_TYPE); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/objects/TestObjects.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.objects; 24 | 25 | public class TestObjects { 26 | 27 | public static AccountIdentificationTestProvider accountIdentification() { 28 | return new AccountIdentificationTestProvider(); 29 | } 30 | 31 | public static MandateTestProvider mandate() { 32 | return new MandateTestProvider(); 33 | } 34 | 35 | public static DirectDebitTestProvider directDebit() { 36 | return new DirectDebitTestProvider(); 37 | } 38 | 39 | public static SepaTransferTestProvider transfer() { 40 | return new SepaTransferTestProvider(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/MandateEndSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.Mandate; 26 | import org.openknowledgehub.data.directdebit.MandateBuilder; 27 | import org.openknowledgehub.dsl.MandateEndSelect; 28 | 29 | public class MandateEndSelectImpl implements MandateEndSelect { 30 | 31 | private final MandateBuilder mandateBuilder; 32 | 33 | public MandateEndSelectImpl(MandateBuilder mandateBuilder) { 34 | this.mandateBuilder = mandateBuilder; 35 | } 36 | 37 | @Override 38 | public Mandate get() { 39 | return mandateBuilder.build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/transformer/sepa/TransferTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.transformer.sepa; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentData; 26 | 27 | public final class TransferTransformer extends AbstractJSepaTransformer { 28 | 29 | private static final String XSLT_PAIN_001_001_12 = "/transform/transform_pain.001.001.12.xslt"; 30 | 31 | @Override 32 | protected Class getSepaDocumentType() { 33 | return SepaTransferDocumentData.class; 34 | } 35 | 36 | @Override 37 | protected String getXsltFileName() { 38 | return XSLT_PAIN_001_001_12; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/transformer/sepa/DirectDebitTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.transformer.sepa; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentData; 26 | 27 | public final class DirectDebitTransformer 28 | extends AbstractJSepaTransformer { 29 | 30 | private static final String XSLT_PAIN_008_001_11 = "/transform/transform_pain.008.001.11.xslt"; 31 | 32 | @Override 33 | protected Class getSepaDocumentType() { 34 | return DirectDebitDocumentData.class; 35 | } 36 | 37 | @Override 38 | protected String getXsltFileName() { 39 | return XSLT_PAIN_008_001_11; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/common/AccountEndSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.common; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.data.common.AccountIdentificationBuilder; 27 | import org.openknowledgehub.dsl.AccountEndSelect; 28 | 29 | class AccountEndSelectImpl implements AccountEndSelect { 30 | 31 | private final AccountIdentificationBuilder accountIdentificationBuilder; 32 | 33 | AccountEndSelectImpl(AccountIdentificationBuilder accountIdentificationBuilder) { 34 | this.accountIdentificationBuilder = accountIdentificationBuilder; 35 | } 36 | 37 | @Override 38 | public AccountIdentification get() { 39 | return this.accountIdentificationBuilder.build(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/XmlAssert.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.api.assertions; 2 | 3 | 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.Reader; 7 | import java.io.StringReader; 8 | import java.util.Objects; 9 | import javax.xml.transform.stream.StreamSource; 10 | import javax.xml.validation.Schema; 11 | import javax.xml.validation.SchemaFactory; 12 | import org.assertj.core.api.AbstractStringAssert; 13 | import org.xml.sax.SAXException; 14 | 15 | public class XmlAssert extends AbstractStringAssert { 16 | 17 | private final SchemaFactory schemaFactory; 18 | 19 | protected XmlAssert(String actual) { 20 | super(actual, XmlAssert.class); 21 | 22 | schemaFactory = SchemaFactory.newDefaultInstance(); 23 | } 24 | 25 | public XmlAssert isInAValidDirectDebitShape() { 26 | Schema schema = createSchemaForXsd("/xsd/pain.008.001.11.xsd"); 27 | 28 | return validateXml(actual, schema); 29 | } 30 | 31 | public XmlAssert isInAValidTransferShape() { 32 | Schema schema = createSchemaForXsd("/xsd/pain.001.001.12.xsd"); 33 | 34 | return validateXml(actual, schema); 35 | } 36 | 37 | private XmlAssert validateXml(String xml, Schema schema) { 38 | if (Objects.isNull(schema)) { 39 | return this; 40 | } 41 | 42 | try (Reader inputXml = new StringReader(xml)) { 43 | schema.newValidator().validate(new StreamSource(inputXml)); 44 | } catch (SAXException | IOException e) { 45 | failWithMessage("Validation of given xml failed. Message: " + e.getMessage()); 46 | } 47 | 48 | return this; 49 | } 50 | 51 | private Schema createSchemaForXsd(String xsd) { 52 | try (InputStream transformFileStream = XmlAssert.class.getResourceAsStream(xsd)) { 53 | 54 | return schemaFactory.newSchema(new StreamSource(transformFileStream)); 55 | } catch (IOException | SAXException e) { 56 | failWithMessage("Schema creation failed. Message: " + e.getMessage()); 57 | } 58 | 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/common/AccountBicSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.common; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentificationBuilder; 26 | import org.openknowledgehub.dsl.AccountBicSelect; 27 | import org.openknowledgehub.dsl.AccountIbanSelect; 28 | 29 | class AccountBicSelectImpl implements AccountBicSelect { 30 | 31 | private final AccountIdentificationBuilder accountIdentificationBuilder; 32 | 33 | AccountBicSelectImpl(AccountIdentificationBuilder accountIdentificationBuilder) { 34 | this.accountIdentificationBuilder = accountIdentificationBuilder; 35 | } 36 | 37 | @Override 38 | public AccountIbanSelect bic(String bic) { 39 | accountIdentificationBuilder.withBic(bic); 40 | 41 | return new AccountIbanSelectImpl(accountIdentificationBuilder); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/common/AccountIbanSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.common; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentificationBuilder; 26 | import org.openknowledgehub.dsl.AccountEndSelect; 27 | import org.openknowledgehub.dsl.AccountIbanSelect; 28 | 29 | class AccountIbanSelectImpl implements AccountIbanSelect { 30 | 31 | private final AccountIdentificationBuilder accountIdentificationBuilder; 32 | 33 | AccountIbanSelectImpl(AccountIdentificationBuilder accountIdentificationBuilder) { 34 | this.accountIdentificationBuilder = accountIdentificationBuilder; 35 | } 36 | 37 | @Override 38 | public AccountEndSelect iban(String iban) { 39 | this.accountIdentificationBuilder.withIban(iban); 40 | 41 | return new AccountEndSelectImpl(this.accountIdentificationBuilder); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferDateSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.dsl.TransferDateSelect; 27 | import org.openknowledgehub.dsl.TransferToSelect; 28 | import java.time.LocalDateTime; 29 | 30 | class TransferDateSelectImpl implements TransferDateSelect { 31 | 32 | private final SepaTransferDocumentBuilder documentBuilder; 33 | 34 | TransferDateSelectImpl(SepaTransferDocumentBuilder documentBuilder) { 35 | this.documentBuilder = documentBuilder; 36 | } 37 | 38 | @Override 39 | public TransferToSelect on(LocalDateTime localDateTime) { 40 | this.documentBuilder.withDateOfExecution(localDateTime); 41 | 42 | return new TransferToSelectImpl(this.documentBuilder); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/development.yml: -------------------------------------------------------------------------------- 1 | name: Development Github Actions 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | - '!main' 8 | 9 | jobs: 10 | compile: 11 | runs-on: ubuntu-latest 12 | timeout-minutes: 60 13 | steps: 14 | - uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 0 17 | - name: Setup Java environment 18 | uses: actions/setup-java@v4 19 | with: 20 | distribution: 'temurin' 21 | java-version: '17' 22 | - name: Cache Maven packages 23 | uses: actions/cache@v4 24 | with: 25 | path: ~/.m2 26 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 27 | restore-keys: ${{ runner.os }}-m2 28 | - name: Compile jSEPA 29 | run: mvn --batch-mode clean test-compile 30 | - name: Upload artefacts 31 | uses: actions/upload-artifact@v4 32 | if: success() 33 | with: 34 | name: jSEPA-compile 35 | retention-days: 1 36 | path: "./target/*" 37 | 38 | verify: 39 | needs: compile 40 | runs-on: ubuntu-latest 41 | timeout-minutes: 60 42 | steps: 43 | - uses: actions/checkout@v4 44 | with: 45 | fetch-depth: 0 46 | - name: Setup Java environment 47 | uses: actions/setup-java@v4 48 | with: 49 | distribution: 'temurin' 50 | java-version: '17' 51 | - name: Cache Maven packages 52 | uses: actions/cache@v4 53 | with: 54 | path: ~/.m2 55 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 56 | restore-keys: ${{ runner.os }}-m2 57 | - name: Download artefacts 58 | uses: actions/download-artifact@v4 59 | with: 60 | name: jSEPA-compile 61 | path: ./target/ 62 | - name: Verify jSEPA 63 | run: mvn --batch-mode verify 64 | - name: Upload artefacts 65 | uses: actions/upload-artifact@v4 66 | if: always() 67 | with: 68 | name: jSEPA-verify 69 | path: "./target/*" -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/configuration/LocalDateAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.configuration; 24 | 25 | import jakarta.xml.bind.annotation.adapters.XmlAdapter; 26 | import java.time.LocalDate; 27 | import java.time.format.DateTimeFormatter; 28 | import java.util.Objects; 29 | 30 | public class LocalDateAdapter extends XmlAdapter { 31 | 32 | private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; 33 | 34 | @Override 35 | public LocalDate unmarshal(String input) { 36 | if (Objects.isNull(input)) { 37 | return null; 38 | } 39 | 40 | return LocalDate.parse(input, formatter); 41 | } 42 | 43 | @Override 44 | public String marshal(LocalDate input) { 45 | if (Objects.isNull(input)) { 46 | return null; 47 | } 48 | 49 | return input.format(formatter); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferStartSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.dsl.AccountSupplier; 27 | import org.openknowledgehub.dsl.TransferDateSelect; 28 | import org.openknowledgehub.dsl.TransferStartSelect; 29 | 30 | public class TransferStartSelectImpl implements TransferStartSelect { 31 | private final SepaTransferDocumentBuilder documentBuilder; 32 | 33 | public TransferStartSelectImpl(String messageId) { 34 | this.documentBuilder = SepaTransferDocumentBuilder.create(messageId); 35 | } 36 | 37 | @Override 38 | public TransferDateSelect from(AccountSupplier accountSupplier) { 39 | this.documentBuilder.withPayer(accountSupplier.get()); 40 | return new TransferDateSelectImpl(this.documentBuilder); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/configuration/LocalDateTimeAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.configuration; 24 | 25 | import jakarta.xml.bind.annotation.adapters.XmlAdapter; 26 | import java.time.LocalDateTime; 27 | import java.time.format.DateTimeFormatter; 28 | import java.util.Objects; 29 | 30 | public class LocalDateTimeAdapter extends XmlAdapter { 31 | 32 | private static final DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME; 33 | 34 | @Override 35 | public LocalDateTime unmarshal(String input) { 36 | if (Objects.isNull(input)) { 37 | return null; 38 | } 39 | 40 | return LocalDateTime.parse(input, formatter); 41 | } 42 | 43 | @Override 44 | public String marshal(LocalDateTime input) { 45 | if (Objects.isNull(input)) { 46 | return null; 47 | } 48 | 49 | return input.format(formatter); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/common/AccountIdentifierSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.common; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentificationBuilder; 26 | import org.openknowledgehub.dsl.AccountBicSelect; 27 | import org.openknowledgehub.dsl.AccountIdentifierSelect; 28 | 29 | class AccountIdentifierSelectImpl implements AccountIdentifierSelect { 30 | 31 | private final AccountIdentificationBuilder accountIdentificationBuilder; 32 | 33 | AccountIdentifierSelectImpl(AccountIdentificationBuilder accountIdentificationBuilder) { 34 | this.accountIdentificationBuilder = accountIdentificationBuilder; 35 | } 36 | 37 | @Override 38 | public AccountBicSelect identification(String identification) { 39 | this.accountIdentificationBuilder.withIdentifier(identification); 40 | 41 | return new AccountBicSelectImpl(this.accountIdentificationBuilder); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/util/JSepaValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.util; 24 | 25 | import java.util.Objects; 26 | import java.util.regex.Pattern; 27 | import org.apache.commons.validator.routines.IBANValidator; 28 | 29 | public class JSepaValidator { 30 | 31 | private static final IBANValidator IBAN_VALIDATOR = IBANValidator.getInstance(); 32 | 33 | private JSepaValidator() {} 34 | 35 | private static final Pattern BIC_PATTERN = 36 | Pattern.compile("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$"); 37 | 38 | public static boolean isValidBic(String bic) { 39 | if (Objects.isNull(bic) || bic.isBlank()) { 40 | return false; 41 | } 42 | return BIC_PATTERN.matcher(bic).matches(); 43 | } 44 | 45 | public static boolean isValidIban(String iban) { 46 | if (Objects.isNull(iban) || iban.isBlank()) { 47 | return false; 48 | } 49 | return IBAN_VALIDATOR.isValid(iban); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/objects/SepaTransferTestProvider.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.api.objects; 2 | 3 | import org.openknowledgehub.data.transfer.SepaTransferDocumentData; 4 | import org.openknowledgehub.data.transfer.SepaTransferPayment; 5 | import org.openknowledgehub.data.transfer.SepaTransferPaymentBuilder; 6 | import java.math.BigDecimal; 7 | import java.time.LocalDateTime; 8 | import java.util.List; 9 | 10 | public class SepaTransferTestProvider { 11 | 12 | public static final String MESSAGE_ID = "MessageId"; 13 | public static final LocalDateTime DATE_OF_EXECUTION = LocalDateTime.now().plusWeeks(2); 14 | 15 | public SepaTransferPaymentTestProvider payment() { 16 | return new SepaTransferPaymentTestProvider(); 17 | } 18 | 19 | public SepaTransferDocumentTestProvider document() { 20 | return new SepaTransferDocumentTestProvider(); 21 | } 22 | 23 | public static class SepaTransferDocumentTestProvider { 24 | public SepaTransferDocumentData defaultDocument() { 25 | return new SepaTransferDocumentData( 26 | TestObjects.accountIdentification().defaultAccount(), 27 | MESSAGE_ID, 28 | DATE_OF_EXECUTION, 29 | List.of(TestObjects.transfer().payment().defaultPayment())); 30 | } 31 | } 32 | 33 | public static class SepaTransferPaymentTestProvider { 34 | 35 | public static final BigDecimal AMOUNT = new BigDecimal("20.09"); 36 | public static final String END_TO_END_ID = "EndToEndId"; 37 | public static final String REASON_FOR_PAYMENT = "Transfer reason"; 38 | 39 | public SepaTransferPaymentBuilder defaultBuilder() { 40 | return SepaTransferPaymentBuilder.withPayment() 41 | .withAmount(AMOUNT) 42 | .withEndToEndId(END_TO_END_ID) 43 | .withPayee(TestObjects.accountIdentification().defaultAccount()) 44 | .withReasonForPayment(REASON_FOR_PAYMENT); 45 | } 46 | 47 | public SepaTransferPayment defaultPayment() { 48 | return new SepaTransferPayment( 49 | AMOUNT, 50 | TestObjects.accountIdentification().defaultAccount(), 51 | REASON_FOR_PAYMENT, 52 | END_TO_END_ID); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/MandateStartSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.MandateBuilder; 26 | import org.openknowledgehub.data.directdebit.MandateType; 27 | import org.openknowledgehub.dsl.MandateEndSelect; 28 | import org.openknowledgehub.dsl.MandateStartSelect; 29 | import java.time.LocalDate; 30 | 31 | public class MandateStartSelectImpl implements MandateStartSelect { 32 | private final MandateBuilder mandateBuilder; 33 | 34 | public MandateStartSelectImpl(String mandateIdentifier, MandateType type) { 35 | this.mandateBuilder = MandateBuilder.withMandate(mandateIdentifier); 36 | this.mandateBuilder.withMandateType(type); 37 | } 38 | 39 | @Override 40 | public MandateEndSelect issuedAt(LocalDate issuedAt) { 41 | this.mandateBuilder.withMandateIssuedAt(issuedAt); 42 | 43 | return new MandateEndSelectImpl(mandateBuilder); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitStartSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.dsl.AccountSupplier; 27 | import org.openknowledgehub.dsl.DirectDebitStartSelect; 28 | import org.openknowledgehub.dsl.DirectDebitAmountSelect; 29 | 30 | public class DirectDebitStartSelectImpl implements DirectDebitStartSelect { 31 | 32 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 33 | 34 | public DirectDebitStartSelectImpl(String messageId) { 35 | directDebitDocumentBuilder = DirectDebitDocumentBuilder.create(messageId); 36 | } 37 | 38 | @Override 39 | public DirectDebitAmountSelect creditor(AccountSupplier accountSupplier) { 40 | this.directDebitDocumentBuilder.withCreditor(accountSupplier.get()); 41 | 42 | return new DirectDebitAmountSelectImpl(this.directDebitDocumentBuilder); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferToSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.data.transfer.SepaTransferPaymentBuilder; 27 | import org.openknowledgehub.dsl.AccountSupplier; 28 | import org.openknowledgehub.dsl.TransferAmountSelect; 29 | import org.openknowledgehub.dsl.TransferToSelect; 30 | 31 | class TransferToSelectImpl implements TransferToSelect { 32 | 33 | private final SepaTransferDocumentBuilder documentBuilder; 34 | 35 | TransferToSelectImpl(SepaTransferDocumentBuilder documentBuilder) { 36 | this.documentBuilder = documentBuilder; 37 | } 38 | 39 | @Override 40 | public TransferAmountSelect to(AccountSupplier accountSupplier) { 41 | SepaTransferPaymentBuilder sepaTransferPaymentBuilder = 42 | SepaTransferPaymentBuilder.withPayment(); 43 | 44 | sepaTransferPaymentBuilder.withPayee(accountSupplier.get()); 45 | 46 | return new TransferAmountSelectImpl(this.documentBuilder, sepaTransferPaymentBuilder); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/objects/AccountIdentificationTestProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.objects; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | 27 | public class AccountIdentificationTestProvider { 28 | public static final String NAME = "AccountId"; 29 | public static final String IDENTIFICATION = "Identification"; 30 | public static final String BIC = "BYLADEM1001"; 31 | public static final String IBAN = "DE89370400440532013000"; 32 | 33 | public static final String SPANISH_NAME = "Another_AccountId"; 34 | public static final String SPANISH_IDENTIFICATION = "Anther_Identification"; 35 | public static final String SPANISH_BIC = "CAIXESBBXXX"; 36 | public static final String SPANISH_IBAN = "ES9121000418450200051332"; 37 | 38 | public AccountIdentification defaultAccount() { 39 | return new AccountIdentification(NAME, IDENTIFICATION, BIC, IBAN); 40 | } 41 | 42 | public AccountIdentification spanish() { 43 | return new AccountIdentification( 44 | SPANISH_NAME, SPANISH_IDENTIFICATION, SPANISH_BIC, SPANISH_IBAN); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferEndToEndSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.data.transfer.SepaTransferPaymentBuilder; 27 | import org.openknowledgehub.dsl.TransferEndSelect; 28 | import org.openknowledgehub.dsl.TransferEndToEndSelect; 29 | 30 | public class TransferEndToEndSelectImpl implements TransferEndToEndSelect { 31 | 32 | private final SepaTransferDocumentBuilder documentBuilder; 33 | private final SepaTransferPaymentBuilder paymentBuilder; 34 | 35 | public TransferEndToEndSelectImpl( 36 | SepaTransferDocumentBuilder documentBuilder, SepaTransferPaymentBuilder paymentBuilder) { 37 | this.documentBuilder = documentBuilder; 38 | this.paymentBuilder = paymentBuilder; 39 | } 40 | 41 | @Override 42 | public TransferEndSelect withEndToEndIdentifier(String endToEndIdentifier) { 43 | paymentBuilder.withEndToEndId(endToEndIdentifier); 44 | 45 | return new TransferEndSelectImpl(documentBuilder, paymentBuilder); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferAmountSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.data.transfer.SepaTransferPaymentBuilder; 27 | import org.openknowledgehub.dsl.TransferAmountSelect; 28 | import org.openknowledgehub.dsl.TransferEndToEndSelect; 29 | import java.math.BigDecimal; 30 | 31 | class TransferAmountSelectImpl implements TransferAmountSelect { 32 | 33 | private final SepaTransferDocumentBuilder documentBuilder; 34 | private final SepaTransferPaymentBuilder paymentBuilder; 35 | 36 | TransferAmountSelectImpl( 37 | SepaTransferDocumentBuilder documentBuilder, SepaTransferPaymentBuilder paymentBuilder) { 38 | this.documentBuilder = documentBuilder; 39 | this.paymentBuilder = paymentBuilder; 40 | } 41 | 42 | @Override 43 | public TransferEndToEndSelect amount(double amount) { 44 | this.paymentBuilder.withAmount(BigDecimal.valueOf(amount)); 45 | 46 | return new TransferEndToEndSelectImpl(documentBuilder, paymentBuilder) {}; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/SepaTransferPaymentAssert.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.api.assertions; 2 | 3 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.AMOUNT; 4 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.END_TO_END_ID; 5 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.REASON_FOR_PAYMENT; 6 | import static org.assertj.core.api.Assertions.assertThat; 7 | 8 | import org.openknowledgehub.api.objects.TestObjects; 9 | import org.openknowledgehub.data.transfer.SepaTransferPayment; 10 | import java.math.BigDecimal; 11 | import org.assertj.core.api.AbstractAssert; 12 | 13 | public class SepaTransferPaymentAssert 14 | extends AbstractAssert { 15 | protected SepaTransferPaymentAssert(SepaTransferPayment sepaTransferPayment) { 16 | super(sepaTransferPayment, SepaTransferPaymentAssert.class); 17 | } 18 | 19 | public SepaTransferPaymentAssert hasDefaultTestValues() { 20 | assertThat(actual.getAmount()).isEqualTo(AMOUNT); 21 | assertThat(actual.getPayee()).isEqualTo(TestObjects.accountIdentification().defaultAccount()); 22 | assertThat(actual.getReasonForPayment()).isEqualTo(REASON_FOR_PAYMENT); 23 | assertThat(actual.getEndToEndId()).isEqualTo(END_TO_END_ID); 24 | 25 | return this; 26 | } 27 | 28 | public SepaTransferPaymentAssert hasAmount(BigDecimal expectedAmount) { 29 | assertThat(actual.getAmount()).isEqualTo(expectedAmount); 30 | 31 | return this; 32 | } 33 | 34 | public SepaTransferPaymentAssert hasEndToEndId(String expectedEndToEndId) { 35 | assertThat(actual.getEndToEndId()).isEqualTo(expectedEndToEndId); 36 | 37 | return this; 38 | } 39 | 40 | public SepaTransferPaymentAssert hasReasonForPayment(String expectedReasonForPayment) { 41 | assertThat(actual.getReasonForPayment()).isEqualTo(expectedReasonForPayment); 42 | 43 | return this; 44 | } 45 | 46 | public SepaTransferPaymentAssert isEmpty() { 47 | assertThat(actual.getAmount()).isNull(); 48 | assertThat(actual.getPayee()).isNull(); 49 | assertThat(actual.getReasonForPayment()).isNull(); 50 | assertThat(actual.getEndToEndId()).isNull(); 51 | 52 | return this; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/directdebit/MandateBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.directdebit; 24 | 25 | import java.time.LocalDate; 26 | import java.util.Objects; 27 | 28 | public class MandateBuilder { 29 | private String mandateId; 30 | private LocalDate mandateIssuedAt; 31 | private MandateType mandateType; 32 | 33 | private MandateBuilder() {} 34 | 35 | public static MandateBuilder withMandate(String mandateId) { 36 | Objects.requireNonNull(mandateId); 37 | 38 | MandateBuilder builder = new MandateBuilder(); 39 | builder.mandateId = mandateId; 40 | 41 | return builder; 42 | } 43 | 44 | public MandateBuilder withMandateIssuedAt(LocalDate mandateIssuedAt) { 45 | Objects.requireNonNull(mandateIssuedAt); 46 | this.mandateIssuedAt = mandateIssuedAt; 47 | return this; 48 | } 49 | 50 | public MandateBuilder withMandateType(MandateType mandateType) { 51 | Objects.requireNonNull(mandateType); 52 | this.mandateType = mandateType; 53 | return this; 54 | } 55 | 56 | public Mandate build() { 57 | return new Mandate(mandateId, mandateIssuedAt, mandateType); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitAmountSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.DirectDebitDebitorSelect; 28 | import org.openknowledgehub.dsl.DirectDebitAmountSelect; 29 | import java.math.BigDecimal; 30 | 31 | public class DirectDebitAmountSelectImpl implements DirectDebitAmountSelect { 32 | 33 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 34 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 35 | 36 | public DirectDebitAmountSelectImpl(DirectDebitDocumentBuilder directDebitDocumentBuilder) { 37 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 38 | this.directDebitPaymentBuilder = DirectDebitPaymentBuilder.withPayment(); 39 | } 40 | 41 | @Override 42 | public DirectDebitDebitorSelect receive(double amount) { 43 | this.directDebitPaymentBuilder.withAmount(BigDecimal.valueOf(amount)); 44 | 45 | return new DirectDebitDebitorSelectImpl( 46 | this.directDebitDocumentBuilder, this.directDebitPaymentBuilder); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/util/JSepaContentSanitizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.util; 24 | 25 | import java.util.Objects; 26 | import java.util.regex.Pattern; 27 | 28 | public class JSepaContentSanitizer { 29 | 30 | private static final String ALLOWED_CHARS_REGEXP = "[^a-zA-Z0-9 &*$%/?:().,'+-]"; 31 | private static final Pattern ALLOWED_CHARS_PATTERN = Pattern.compile(ALLOWED_CHARS_REGEXP); 32 | 33 | private final String sepaString; 34 | private final Integer maxLength; 35 | 36 | private JSepaContentSanitizer(String sepaString, Integer maxLength) { 37 | this.sepaString = Objects.nonNull(sepaString) ? sepaString : ""; 38 | this.maxLength = maxLength; 39 | } 40 | 41 | public static JSepaContentSanitizer of(String sepaString) { 42 | return new JSepaContentSanitizer(sepaString, null); 43 | } 44 | 45 | public JSepaContentSanitizer withMaxLength(int maxLength) { 46 | return new JSepaContentSanitizer(this.sepaString, maxLength); 47 | } 48 | 49 | public String sanitize() { 50 | String sanitized = ALLOWED_CHARS_PATTERN.matcher(sepaString).replaceAll(" ").trim(); 51 | return (Objects.nonNull(maxLength) && sanitized.length() > maxLength) 52 | ? sanitized.substring(0, maxLength) 53 | : sanitized; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitMandateSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.DirectDebitEndSelect; 28 | import org.openknowledgehub.dsl.DirectDebitMandateSelect; 29 | import org.openknowledgehub.dsl.MandateSupplier; 30 | 31 | public class DirectDebitMandateSelectImpl implements DirectDebitMandateSelect { 32 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 33 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 34 | 35 | public DirectDebitMandateSelectImpl( 36 | DirectDebitDocumentBuilder directDebitDocumentBuilder, 37 | DirectDebitPaymentBuilder directDebitPaymentBuilder) { 38 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 39 | this.directDebitPaymentBuilder = directDebitPaymentBuilder; 40 | } 41 | 42 | @Override 43 | public DirectDebitEndSelect overMandate(MandateSupplier mandateSupplier) { 44 | this.directDebitPaymentBuilder.withMandate(mandateSupplier.get()); 45 | 46 | return new DirectDebitEndSelectImpl(this.directDebitDocumentBuilder, this.directDebitPaymentBuilder); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitDebitorSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.AccountSupplier; 28 | import org.openknowledgehub.dsl.DirectDebitDebitorSelect; 29 | import org.openknowledgehub.dsl.DirectDebitDateTimeSelect; 30 | 31 | public class DirectDebitDebitorSelectImpl implements DirectDebitDebitorSelect { 32 | 33 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 34 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 35 | 36 | public DirectDebitDebitorSelectImpl( 37 | DirectDebitDocumentBuilder directDebitDocumentBuilder, 38 | DirectDebitPaymentBuilder directDebitPaymentBuilder) { 39 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 40 | this.directDebitPaymentBuilder = directDebitPaymentBuilder; 41 | } 42 | 43 | @Override 44 | public DirectDebitDateTimeSelect from(AccountSupplier accountSupplier) { 45 | this.directDebitPaymentBuilder.withDebitor(accountSupplier.get()); 46 | return new DirectDebitDateTimeSelectImpl( 47 | this.directDebitDocumentBuilder, this.directDebitPaymentBuilder); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitDateTimeSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.DirectDebitPaymentIdentificationSelect; 28 | import org.openknowledgehub.dsl.DirectDebitDateTimeSelect; 29 | 30 | import java.time.LocalDate; 31 | 32 | public class DirectDebitDateTimeSelectImpl implements DirectDebitDateTimeSelect { 33 | 34 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 35 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 36 | 37 | public DirectDebitDateTimeSelectImpl(DirectDebitDocumentBuilder directDebitDocumentBuilder, DirectDebitPaymentBuilder directDebitPaymentBuilder) { 38 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 39 | this.directDebitPaymentBuilder = directDebitPaymentBuilder; 40 | } 41 | 42 | @Override 43 | public DirectDebitPaymentIdentificationSelect on(LocalDate directDebitDueAt) { 44 | this.directDebitPaymentBuilder.withDirectDebitDueAt(directDebitDueAt); 45 | 46 | return new DirectDebitPaymentIdentificationSelectImpl(this.directDebitDocumentBuilder, this.directDebitPaymentBuilder); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitPaymentIdentificationSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.DirectDebitMandateSelect; 28 | import org.openknowledgehub.dsl.DirectDebitPaymentIdentificationSelect; 29 | 30 | public class DirectDebitPaymentIdentificationSelectImpl implements DirectDebitPaymentIdentificationSelect { 31 | 32 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 33 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 34 | 35 | public DirectDebitPaymentIdentificationSelectImpl( 36 | DirectDebitDocumentBuilder directDebitDocumentBuilder, 37 | DirectDebitPaymentBuilder directDebitPaymentBuilder) { 38 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 39 | this.directDebitPaymentBuilder = directDebitPaymentBuilder; 40 | } 41 | 42 | @Override 43 | public DirectDebitMandateSelect withPaymentIdentification(String paymentIdentification) { 44 | this.directDebitPaymentBuilder.withIdentification(paymentIdentification); 45 | 46 | return new DirectDebitMandateSelectImpl( 47 | this.directDebitDocumentBuilder, this.directDebitPaymentBuilder); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/transfer/TransferEndSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.transfer; 24 | 25 | import org.openknowledgehub.data.transfer.SepaTransferDocumentBuilder; 26 | import org.openknowledgehub.data.transfer.SepaTransferPaymentBuilder; 27 | import org.openknowledgehub.dsl.TransferEndSelect; 28 | import org.openknowledgehub.dsl.TransferToSelect; 29 | import org.openknowledgehub.transformer.sepa.TransferTransformer; 30 | 31 | public class TransferEndSelectImpl implements TransferEndSelect { 32 | 33 | private final SepaTransferDocumentBuilder documentBuilder; 34 | private final SepaTransferPaymentBuilder paymentBuilder; 35 | 36 | public TransferEndSelectImpl( 37 | SepaTransferDocumentBuilder documentBuilder, SepaTransferPaymentBuilder paymentBuilder) { 38 | this.documentBuilder = documentBuilder; 39 | this.paymentBuilder = paymentBuilder; 40 | } 41 | 42 | @Override 43 | public TransferEndSelect withReasonForPayment(String reasonForPayment) { 44 | paymentBuilder.withReasonForPayment(reasonForPayment); 45 | 46 | return new TransferEndSelectImpl(documentBuilder, paymentBuilder); 47 | } 48 | 49 | @Override 50 | public TransferToSelect and() { 51 | this.documentBuilder.addPayment(paymentBuilder); 52 | return new TransferToSelectImpl(this.documentBuilder); 53 | } 54 | 55 | @Override 56 | public String toXml() { 57 | this.documentBuilder.addPayment(paymentBuilder); 58 | return new TransferTransformer().transform(this.documentBuilder.build()); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/DSL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl; 24 | 25 | import org.openknowledgehub.data.directdebit.MandateType; 26 | import org.openknowledgehub.dsl.impl.common.AccountStartSelectImpl; 27 | import org.openknowledgehub.dsl.impl.directdebit.DirectDebitStartSelectImpl; 28 | import org.openknowledgehub.dsl.impl.directdebit.MandateStartSelectImpl; 29 | import org.openknowledgehub.dsl.impl.transfer.TransferStartSelectImpl; 30 | 31 | public final class DSL { 32 | 33 | private DSL() {} 34 | 35 | public static TransferStartSelect transfer(String messageId) { 36 | return new TransferStartSelectImpl(messageId); 37 | } 38 | 39 | public static DirectDebitStartSelect directDebit(String messageId) { 40 | return new DirectDebitStartSelectImpl(messageId); 41 | } 42 | 43 | public static AccountStartSelect account() { 44 | return new AccountStartSelectImpl(); 45 | } 46 | 47 | public static MandateStartSelect oneTimeMandate(String mandateIdentifier) { 48 | return new MandateStartSelectImpl(mandateIdentifier, MandateType.ONE_OFF); 49 | } 50 | 51 | public static MandateStartSelect firstUseOfMandate(String mandateIdentifier) { 52 | return new MandateStartSelectImpl(mandateIdentifier, MandateType.FIRST); 53 | } 54 | 55 | public static MandateStartSelect lastUseOfMandate(String mandateIdentifier) { 56 | return new MandateStartSelectImpl(mandateIdentifier, MandateType.FINAL); 57 | } 58 | 59 | public static MandateStartSelect recurrentMandate(String mandateIdentifier) { 60 | return new MandateStartSelectImpl(mandateIdentifier, MandateType.RECURRING); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/resources/dummy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | messageId 5 | 2025-03-18T13:40:51.374393101 6 | 1 7 | 5.56 8 | 9 | AccountId 10 | 11 | 12 | 13 | identification 14 | DD 15 | 2021-01-01 16 | 17 | AccountId 18 | 19 | 20 | 21 | DE89370400440532013000 22 | 23 | 24 | 25 | 26 | BYLADEM1001 27 | 28 | 29 | 30 | 31 | MandateId 32 | 33 | 34 | 35 | CORE 36 | 37 | 38 | CORE 39 | 40 | OOFF 41 | 42 | 5.56 43 | 44 | 45 | MandateId 46 | 2019-01-01 47 | 48 | 49 | 50 | 51 | 52 | Identification 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | BYLADEM1001 61 | 62 | 63 | 64 | AccountId 65 | 66 | 67 | 68 | DE89370400440532013000 69 | 70 | 71 | 72 | Invoice XXX 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/dsl/impl/directdebit/DirectDebitEndSelectImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.dsl.impl.directdebit; 24 | 25 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentBuilder; 26 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 27 | import org.openknowledgehub.dsl.DirectDebitAmountSelect; 28 | import org.openknowledgehub.dsl.DirectDebitEndSelect; 29 | import org.openknowledgehub.transformer.sepa.DirectDebitTransformer; 30 | 31 | public class DirectDebitEndSelectImpl implements DirectDebitEndSelect { 32 | private final DirectDebitDocumentBuilder directDebitDocumentBuilder; 33 | private final DirectDebitPaymentBuilder directDebitPaymentBuilder; 34 | 35 | public DirectDebitEndSelectImpl( 36 | DirectDebitDocumentBuilder directDebitDocumentBuilder, 37 | DirectDebitPaymentBuilder directDebitPaymentBuilder) { 38 | this.directDebitDocumentBuilder = directDebitDocumentBuilder; 39 | this.directDebitPaymentBuilder = directDebitPaymentBuilder; 40 | } 41 | 42 | @Override 43 | public DirectDebitEndSelect withReasonForPayment(String reasonForPayment) { 44 | this.directDebitPaymentBuilder.withReasonForPayment(reasonForPayment); 45 | return this; 46 | } 47 | 48 | @Override 49 | public DirectDebitAmountSelect and() { 50 | this.directDebitDocumentBuilder.addPayment(this.directDebitPaymentBuilder); 51 | 52 | return new DirectDebitAmountSelectImpl(this.directDebitDocumentBuilder); 53 | } 54 | 55 | @Override 56 | public String toXml() { 57 | this.directDebitDocumentBuilder.addPayment(this.directDebitPaymentBuilder); 58 | return new DirectDebitTransformer().transform(this.directDebitDocumentBuilder.build()); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/configuration/LocalDateAdapterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.configuration; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | import java.time.LocalDate; 28 | import org.junit.jupiter.api.BeforeEach; 29 | import org.junit.jupiter.api.DisplayName; 30 | import org.junit.jupiter.api.Test; 31 | 32 | @DisplayName("Test the LocalDate XML adapter") 33 | class LocalDateAdapterTest { 34 | 35 | private final LocalDate testDate = LocalDate.of(2020, 1, 1); 36 | private final String testDateString = "2020-01-01"; 37 | 38 | LocalDateAdapter underTest; 39 | 40 | @BeforeEach 41 | void setUp() { 42 | underTest = new LocalDateAdapter(); 43 | } 44 | 45 | @Test 46 | @DisplayName("Should marshal a LocalDate") 47 | void testMarshalLocalDate() { 48 | final var marshalledDate = underTest.marshal(testDate); 49 | 50 | assertThat(marshalledDate).isNotNull().isNotBlank().isEqualTo(testDateString); 51 | } 52 | 53 | @Test 54 | @DisplayName("Should marshal null without failing") 55 | void testMarshalLocalDateNull() { 56 | final var marshalledDate = underTest.marshal(null); 57 | 58 | assertThat(marshalledDate).isNull(); 59 | } 60 | 61 | @Test 62 | @DisplayName("Should unmarshal a LocalDate") 63 | void testUnmarshalLocalDate() { 64 | final var unmarshalledDate = underTest.unmarshal(testDateString); 65 | 66 | assertThat(unmarshalledDate).isNotNull().isEqualTo(testDate); 67 | } 68 | 69 | @Test 70 | @DisplayName("Should unmarshal null without failing") 71 | void testUnmarshalLocalDateNull() { 72 | final var unmarshalledDate = underTest.unmarshal(null); 73 | 74 | assertThat(unmarshalledDate).isNull(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/JSepaAssertions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.assertions; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentData; 27 | import org.openknowledgehub.data.directdebit.DirectDebitPayment; 28 | import org.openknowledgehub.data.directdebit.Mandate; 29 | import org.openknowledgehub.data.transfer.SepaTransferDocumentData; 30 | import org.openknowledgehub.data.transfer.SepaTransferPayment; 31 | 32 | public class JSepaAssertions { 33 | private JSepaAssertions() {} 34 | 35 | public static MandateAssert jSepaAssertThat(Mandate mandate) { 36 | return new MandateAssert(mandate); 37 | } 38 | 39 | public static AccountIdentificationAssert jSepaAssertThat( 40 | AccountIdentification accountIdentification) { 41 | return new AccountIdentificationAssert(accountIdentification); 42 | } 43 | 44 | public static DirectDebitPaymentAssert jSepaAssertThat(DirectDebitPayment directDebitPayment) { 45 | return new DirectDebitPaymentAssert(directDebitPayment); 46 | } 47 | 48 | public static SepaTransferAssert jSepaAssertThat(SepaTransferDocumentData transferDocumentData) { 49 | return new SepaTransferAssert(transferDocumentData); 50 | } 51 | 52 | public static SepaTransferPaymentAssert jSepaAssertThat(SepaTransferPayment sepaTransferPayment) { 53 | return new SepaTransferPaymentAssert(sepaTransferPayment); 54 | } 55 | 56 | public static DirectDebitDocumentDataAssert jSepaAssertThat( 57 | DirectDebitDocumentData directDebitDocumentData) { 58 | return new DirectDebitDocumentDataAssert(directDebitDocumentData); 59 | } 60 | 61 | public static XmlAssert jSepaAssertThat(String xmlContent) { 62 | return new XmlAssert(xmlContent); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/configuration/LocalDateTimeAdapterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.configuration; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | import java.time.LocalDateTime; 28 | import org.junit.jupiter.api.BeforeEach; 29 | import org.junit.jupiter.api.DisplayName; 30 | import org.junit.jupiter.api.Test; 31 | 32 | @DisplayName("Test the LocalDateTime XML adapter") 33 | class LocalDateTimeAdapterTest { 34 | 35 | private final LocalDateTime testDateTime = LocalDateTime.of(2020, 1, 1, 10, 5, 0); 36 | private final String testDateTimeString = "2020-01-01T10:05:00"; 37 | 38 | LocalDateTimeAdapter underTest; 39 | 40 | @BeforeEach 41 | void setUp() { 42 | underTest = new LocalDateTimeAdapter(); 43 | } 44 | 45 | @Test 46 | @DisplayName("Should marshal a LocalDateTime") 47 | void testMarshalLocalDateTime() { 48 | final var marshalledDateTime = underTest.marshal(testDateTime); 49 | 50 | assertThat(marshalledDateTime).isNotNull().isNotBlank().isEqualTo(testDateTimeString); 51 | } 52 | 53 | @Test 54 | @DisplayName("Should marshal null without failing") 55 | void testMarshalLocalDateTimeNull() { 56 | final var marshalledDateTime = underTest.marshal(null); 57 | 58 | assertThat(marshalledDateTime).isNull(); 59 | } 60 | 61 | @Test 62 | @DisplayName("Should unmarshal a LocalDateTime") 63 | void testUnmarshalLocalDateTime() { 64 | final var unmarshalledDateTime = underTest.unmarshal(testDateTimeString); 65 | 66 | assertThat(unmarshalledDateTime).isNotNull().isEqualTo(testDateTime); 67 | } 68 | 69 | @Test 70 | @DisplayName("Should unmarshal null without failing") 71 | void testUnmarshalLocalDateTimeNull() { 72 | final var unmarshalledDateTime = underTest.unmarshal(null); 73 | 74 | assertThat(unmarshalledDateTime).isNull(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/MandateAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.assertions; 24 | 25 | import static org.openknowledgehub.api.objects.MandateTestProvider.ISSUED_AT; 26 | import static org.openknowledgehub.api.objects.MandateTestProvider.MANDATE_ID; 27 | import static org.openknowledgehub.api.objects.MandateTestProvider.MANDATE_TYPE; 28 | import static org.assertj.core.api.Assertions.assertThat; 29 | 30 | import org.openknowledgehub.data.directdebit.Mandate; 31 | import org.openknowledgehub.data.directdebit.MandateType; 32 | import java.time.LocalDate; 33 | import org.assertj.core.api.AbstractAssert; 34 | 35 | public class MandateAssert extends AbstractAssert { 36 | protected MandateAssert(Mandate mandate) { 37 | super(mandate, MandateAssert.class); 38 | } 39 | 40 | public MandateAssert isEmpty() { 41 | assertThat(actual.getMandateId()).isNull(); 42 | assertThat(actual.getMandateIssuedAt()).isNull(); 43 | assertThat(actual.getMandateType()).isNull(); 44 | 45 | return this; 46 | } 47 | 48 | public MandateAssert hasDefaultTestValues() { 49 | assertThat(actual.getMandateId()).isEqualTo(MANDATE_ID); 50 | assertThat(actual.getMandateIssuedAt()).isEqualTo(ISSUED_AT); 51 | assertThat(actual.getMandateType()).isEqualTo(MANDATE_TYPE); 52 | 53 | return this; 54 | } 55 | 56 | public MandateAssert hasMandateId(String expectedMandateId) { 57 | assertThat(actual.getMandateId()).isEqualTo(expectedMandateId); 58 | 59 | return this; 60 | } 61 | 62 | public MandateAssert isFromType(MandateType expectedType) { 63 | assertThat(actual.getMandateType()).isEqualTo(expectedType); 64 | 65 | return this; 66 | } 67 | 68 | public MandateAssert wasIssuedAt(LocalDate expectedIssuedAt) { 69 | assertThat(actual.getMandateIssuedAt()).isEqualTo(expectedIssuedAt); 70 | 71 | return this; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/AccountIdentificationAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.assertions; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | import org.openknowledgehub.api.objects.AccountIdentificationTestProvider; 28 | import org.openknowledgehub.data.common.AccountIdentification; 29 | import org.assertj.core.api.AbstractAssert; 30 | 31 | public class AccountIdentificationAssert 32 | extends AbstractAssert { 33 | protected AccountIdentificationAssert(AccountIdentification accountIdentification) { 34 | super(accountIdentification, AccountIdentificationAssert.class); 35 | } 36 | 37 | public AccountIdentificationAssert isEmpty() { 38 | assertThat(actual.getName()).isNull(); 39 | assertThat(actual.getIdentifier()).isNull(); 40 | assertThat(actual.getBic()).isNull(); 41 | assertThat(actual.getIban()).isNull(); 42 | 43 | return this; 44 | } 45 | 46 | public AccountIdentificationAssert hasDefaultTestValues() { 47 | hasName(AccountIdentificationTestProvider.NAME); 48 | hasIdentifier(AccountIdentificationTestProvider.IDENTIFICATION); 49 | hasIban(AccountIdentificationTestProvider.IBAN); 50 | hasBic(AccountIdentificationTestProvider.BIC); 51 | 52 | return this; 53 | } 54 | 55 | public AccountIdentificationAssert hasName(String name) { 56 | assertThat(name).isEqualTo(actual.getName()); 57 | 58 | return this; 59 | } 60 | 61 | public AccountIdentificationAssert hasIdentifier(String identifier) { 62 | assertThat(identifier).isEqualTo(actual.getIdentifier()); 63 | 64 | return this; 65 | } 66 | 67 | public AccountIdentificationAssert hasIban(String iban) { 68 | assertThat(iban).isEqualTo(actual.getIban()); 69 | 70 | return this; 71 | } 72 | 73 | public AccountIdentificationAssert hasBic(String bic) { 74 | assertThat(bic).isEqualTo(actual.getBic()); 75 | 76 | return this; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/directdebit/DirectDebitDocumentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.directdebit; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.exception.JSepaValidationException; 27 | import org.openknowledgehub.util.JSepaContentSanitizer; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.Objects; 31 | 32 | public class DirectDebitDocumentBuilder { 33 | 34 | private String messageId; 35 | 36 | private AccountIdentification creditor; 37 | 38 | private List payments; 39 | 40 | private DirectDebitDocumentBuilder() {} 41 | 42 | public static DirectDebitDocumentBuilder create(String messageId) { 43 | if (Objects.isNull(messageId)) { 44 | throw new JSepaValidationException("'messageId' cannot be null"); 45 | } 46 | 47 | if (messageId.isBlank()) { 48 | throw new JSepaValidationException("'messageId' cannot be empty"); 49 | } 50 | 51 | DirectDebitDocumentBuilder builder = new DirectDebitDocumentBuilder(); 52 | builder.messageId = JSepaContentSanitizer.of(messageId).withMaxLength(35).sanitize(); 53 | 54 | return builder; 55 | } 56 | 57 | public DirectDebitDocumentBuilder withCreditor(AccountIdentification creditor) { 58 | if (Objects.isNull(creditor)) { 59 | throw new JSepaValidationException("'creditor' cannot be null"); 60 | } 61 | 62 | this.creditor = creditor; 63 | 64 | return this; 65 | } 66 | 67 | public DirectDebitDocumentBuilder addPayment(DirectDebitPaymentBuilder paymentBuilder) { 68 | if (Objects.isNull(paymentBuilder)) { 69 | throw new JSepaValidationException("'paymentBuilder' cannot be null"); 70 | } 71 | 72 | if (Objects.isNull(this.payments)) { 73 | this.payments = new ArrayList<>(); 74 | } 75 | 76 | this.payments.add(paymentBuilder.build()); 77 | 78 | return this; 79 | } 80 | 81 | public DirectDebitDocumentData build() { 82 | return new DirectDebitDocumentData(messageId, creditor, payments); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/transfer/SepaTransferPayment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.transfer; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.exception.JSepaValidationException; 27 | import jakarta.xml.bind.annotation.XmlAccessType; 28 | import jakarta.xml.bind.annotation.XmlAccessorType; 29 | import jakarta.xml.bind.annotation.XmlElement; 30 | import jakarta.xml.bind.annotation.XmlRootElement; 31 | import java.math.BigDecimal; 32 | import java.util.Objects; 33 | 34 | @XmlRootElement(name = "Payment") 35 | @XmlAccessorType(XmlAccessType.FIELD) 36 | public class SepaTransferPayment { 37 | 38 | @XmlElement(name = "Amount") 39 | private final BigDecimal amount; 40 | 41 | @XmlElement(name = "Payee") 42 | private final AccountIdentification payee; 43 | 44 | @XmlElement(name = "ReasonForPayment") 45 | private final String reasonForPayment; 46 | 47 | @XmlElement(name = "EndToEndId") 48 | private final String endToEndId; 49 | 50 | public SepaTransferPayment() { 51 | this.amount = null; 52 | this.payee = null; 53 | this.reasonForPayment = null; 54 | this.endToEndId = null; 55 | } 56 | 57 | public SepaTransferPayment( 58 | BigDecimal amount, AccountIdentification payee, String reasonForPayment, String endToEndId) { 59 | 60 | if (Objects.isNull(amount)) { 61 | throw new JSepaValidationException("SepaTransferPayment 'amount' cannot be null"); 62 | } 63 | 64 | if (Objects.isNull(payee)) { 65 | throw new JSepaValidationException("SepaTransferPayment 'payee' cannot be null"); 66 | } 67 | 68 | if (Objects.isNull(endToEndId)) { 69 | throw new JSepaValidationException("SepaTransferPayment 'endToEndId' cannot be null"); 70 | } 71 | 72 | this.amount = amount; 73 | this.payee = payee; 74 | this.reasonForPayment = reasonForPayment; 75 | this.endToEndId = endToEndId; 76 | } 77 | 78 | public BigDecimal getAmount() { 79 | return amount; 80 | } 81 | 82 | public AccountIdentification getPayee() { 83 | return payee; 84 | } 85 | 86 | public String getReasonForPayment() { 87 | return reasonForPayment; 88 | } 89 | 90 | public String getEndToEndId() { 91 | return endToEndId; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/transfer/SepaTransferDocumentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.transfer; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.exception.JSepaValidationException; 27 | import java.time.LocalDateTime; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.Objects; 31 | 32 | public class SepaTransferDocumentBuilder { 33 | 34 | private AccountIdentification payer; 35 | private String messageId; 36 | private LocalDateTime dateOfExecution; 37 | private List payments; 38 | 39 | private SepaTransferDocumentBuilder() {} 40 | 41 | public static SepaTransferDocumentBuilder create(String messageId) { 42 | if (Objects.isNull(messageId)) { 43 | throw new JSepaValidationException("'messageId' cannot be null"); 44 | } 45 | 46 | if (messageId.isBlank()) { 47 | throw new JSepaValidationException("'messageId' cannot be empty"); 48 | } 49 | 50 | SepaTransferDocumentBuilder builder = new SepaTransferDocumentBuilder(); 51 | builder.messageId = messageId; 52 | 53 | return builder; 54 | } 55 | 56 | public SepaTransferDocumentBuilder withPayer(AccountIdentification payer) { 57 | if (Objects.isNull(payer)) { 58 | throw new JSepaValidationException("'payer' cannot be null"); 59 | } 60 | 61 | this.payer = payer; 62 | 63 | return this; 64 | } 65 | 66 | public SepaTransferDocumentBuilder withDateOfExecution(LocalDateTime dateOfExecution) { 67 | if (Objects.isNull(dateOfExecution)) { 68 | throw new JSepaValidationException("'dateOfExecution' cannot be null"); 69 | } 70 | 71 | this.dateOfExecution = dateOfExecution; 72 | 73 | return this; 74 | } 75 | 76 | public SepaTransferDocumentBuilder addPayment(SepaTransferPaymentBuilder paymentBuilder) { 77 | if (Objects.isNull(paymentBuilder)) { 78 | throw new JSepaValidationException("'paymentBuilder' cannot be null"); 79 | } 80 | 81 | if (Objects.isNull(this.payments)) { 82 | this.payments = new ArrayList<>(); 83 | } 84 | 85 | this.payments.add(paymentBuilder.build()); 86 | 87 | return this; 88 | } 89 | 90 | public SepaTransferDocumentData build() { 91 | return new SepaTransferDocumentData(payer, messageId, dateOfExecution, payments); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # jSEPA 2 | 3 | [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=OpenKnowledgeHub_jSEPA&metric=bugs)](https://sonarcloud.io/summary/new_code?id=OpenKnowledgeHub_jSEPA) 4 | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=OpenKnowledgeHub_jSEPA&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=OpenKnowledgeHub_jSEPA) 5 | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=OpenKnowledgeHub_jSEPA&metric=coverage)](https://sonarcloud.io/summary/new_code?id=OpenKnowledgeHub_jSEPA) 6 | [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=OpenKnowledgeHub_jSEPA&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=OpenKnowledgeHub_jSEPA) 7 | --- 8 | 9 | A java library to create valid PAIN.008.001.11 SEPA direct debit and PAIN.001.001.12 SEPA transfer XML documents. 10 | 11 | Strings are sanitized according to SEPA rules. 12 | 13 | ## Usage 14 | 15 | ### Creation of pain.008.001.11 direct debit xml documents 16 | 17 | To create a direct debit initialisation XML document you simple start at the `DSL.directDebit()` point and the DSL will 18 | guide you through the steps: 19 | 20 | ```java 21 | public String generateXml() { 22 | DSL.directDebit("MessageId") 23 | .creditor( 24 | DSL.account() 25 | .name("Creditor Name") 26 | .identification("Creditor Identification") 27 | .bic("BYLADEM1001") 28 | .iban("DE02120300000000202051")) 29 | .receive(550) 30 | .from( 31 | DSL.account() 32 | .name("Debitor Name") 33 | .identification("Debitor Identification") 34 | .bic("BYLADEM1001") 35 | .iban("DE02120300000000203051")) 36 | .on(LocalDate.now().plusWeeks(1)) 37 | .withPaymentIdentification("PaymentIdentification") 38 | .overMandate(DSL.oneTimeMandate("Mandate Identifier").issuedAt(LocalDate.now())) 39 | .toXml(); 40 | } 41 | ``` 42 | 43 | ### Creation of pain.001.001.12 bank transfer xml documents 44 | 45 | Creating bank transfer XML document works as simple as the direct debit ones. This time start at the `DSL.transfer()` 46 | entry point and the DSL will guide you through the steps: 47 | 48 | ```java 49 | public String generateXml() { 50 | DSL.transfer("MessageId") 51 | .from( 52 | DSL.account() 53 | .name("Payer Name") 54 | .identification("Payer Identification") 55 | .bic("BYLADEM1001") 56 | .iban("DE02120300000000202051")) 57 | .on(LocalDateTime.now().plusWeeks(1)) 58 | .to( 59 | DSL.account() 60 | .name("Payee Name") 61 | .identification("Payee Identification") 62 | .bic("BYLADEM1001") 63 | .iban("DE02120300000000203051")) 64 | .amount(125) 65 | .withEndToEndIdentifier("End to end identification") 66 | .toXml(); 67 | } 68 | ``` 69 | 70 | ## Compiling 71 | 72 | Just checkout the repository and run `mvn clean install`. A `.jar` file will be created in the `target/` directory. 73 | 74 | ## Credits 75 | 76 | This library was originally written by Robert Becker and is now maintained by Jelmen 77 | Guhlke . 78 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Main Github Actions 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | compile: 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 60 14 | steps: 15 | - uses: actions/checkout@v4 16 | with: 17 | fetch-depth: 0 18 | - name: Setup Java environment 19 | uses: actions/setup-java@v4 20 | with: 21 | distribution: 'temurin' 22 | java-version: '17' 23 | - name: Cache Maven packages 24 | uses: actions/cache@v4 25 | with: 26 | path: ~/.m2 27 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 28 | restore-keys: ${{ runner.os }}-m2 29 | - name: Compile jSEPA 30 | run: mvn --batch-mode clean test-compile 31 | - name: Upload artefacts 32 | uses: actions/upload-artifact@v4 33 | if: success() 34 | with: 35 | name: jSEPA-compile 36 | retention-days: 1 37 | path: "./target/*" 38 | 39 | verify-with-coverage: 40 | needs: compile 41 | runs-on: ubuntu-latest 42 | timeout-minutes: 60 43 | steps: 44 | - uses: actions/checkout@v4 45 | with: 46 | fetch-depth: 0 47 | - name: Setup Java environment 48 | uses: actions/setup-java@v4 49 | with: 50 | distribution: 'temurin' 51 | java-version: '17' 52 | - name: Cache Maven packages 53 | uses: actions/cache@v4 54 | with: 55 | path: ~/.m2 56 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 57 | restore-keys: ${{ runner.os }}-m2 58 | - name: Download artefacts 59 | uses: actions/download-artifact@v4 60 | with: 61 | name: jSEPA-compile 62 | path: ./target/ 63 | - name: Verify jSEPA with coverage 64 | run: mvn --batch-mode -Psonar verify 65 | - name: Upload artefacts 66 | uses: actions/upload-artifact@v4 67 | if: always() 68 | with: 69 | name: jSEPA-verify 70 | path: "./target/*" 71 | 72 | report-sonar: 73 | needs: verify-with-coverage 74 | runs-on: ubuntu-latest 75 | timeout-minutes: 60 76 | steps: 77 | - uses: actions/checkout@v4 78 | with: 79 | fetch-depth: 0 80 | - name: Setup Java environment 81 | uses: actions/setup-java@v4 82 | with: 83 | distribution: 'temurin' 84 | java-version: '17' 85 | - name: Cache Maven packages 86 | uses: actions/cache@v4 87 | with: 88 | path: ~/.m2 89 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 90 | restore-keys: ${{ runner.os }}-m2 91 | - name: Cache SonarQube packages 92 | uses: actions/cache@v4 93 | with: 94 | path: ~/.sonar/cache 95 | key: ${{ runner.os }}-sonar 96 | restore-keys: ${{ runner.os }}-sonar 97 | - name: Download artefacts 98 | uses: actions/download-artifact@v4 99 | with: 100 | name: jSEPA-verify 101 | path: ./target/ 102 | - name: Report to SonarCloud 103 | env: 104 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 105 | run: mvn --batch-mode -Psonar sonar:sonar 106 | - name: Upload artefacts 107 | uses: actions/upload-artifact@v4 108 | if: always() 109 | with: 110 | name: jSEPA-sonar 111 | path: "./target/*" -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/directdebit/Mandate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.directdebit; 24 | 25 | import org.openknowledgehub.data.configuration.LocalDateAdapter; 26 | import jakarta.xml.bind.annotation.XmlAccessType; 27 | import jakarta.xml.bind.annotation.XmlAccessorType; 28 | import jakarta.xml.bind.annotation.XmlElement; 29 | import jakarta.xml.bind.annotation.XmlRootElement; 30 | import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 31 | import java.time.LocalDate; 32 | import java.util.Objects; 33 | 34 | @XmlRootElement(name = "Mandate") 35 | @XmlAccessorType(XmlAccessType.FIELD) 36 | public class Mandate { 37 | @XmlElement(name = "Identification") 38 | private final String mandateId; 39 | 40 | @XmlElement(name = "IssuedAt") 41 | @XmlJavaTypeAdapter(LocalDateAdapter.class) 42 | private final LocalDate mandateIssuedAt; 43 | 44 | @XmlElement(name = "Type") 45 | private final MandateType mandateType; 46 | 47 | /** Default constructor for JAX-B only. You should no used programmatically */ 48 | public Mandate() { 49 | this.mandateId = null; 50 | this.mandateIssuedAt = null; 51 | this.mandateType = null; 52 | } 53 | 54 | public Mandate(String mandateId, LocalDate mandateIssuedAt, MandateType mandateType) { 55 | this.mandateId = mandateId; 56 | this.mandateIssuedAt = mandateIssuedAt; 57 | this.mandateType = mandateType; 58 | } 59 | 60 | public String getMandateId() { 61 | return mandateId; 62 | } 63 | 64 | public LocalDate getMandateIssuedAt() { 65 | return mandateIssuedAt; 66 | } 67 | 68 | public MandateType getMandateType() { 69 | return mandateType; 70 | } 71 | 72 | @Override 73 | public boolean equals(Object o) { 74 | if (o == null || getClass() != o.getClass()) return false; 75 | Mandate mandate = (Mandate) o; 76 | return Objects.equals(mandateId, mandate.mandateId) 77 | && Objects.equals(mandateIssuedAt, mandate.mandateIssuedAt) 78 | && mandateType == mandate.mandateType; 79 | } 80 | 81 | @Override 82 | public int hashCode() { 83 | return Objects.hash(mandateId, mandateIssuedAt, mandateType); 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "Mandate{" 89 | + "mandateId='" 90 | + mandateId 91 | + '\'' 92 | + ", mandateIssuedAt=" 93 | + mandateIssuedAt 94 | + ", mandateType=" 95 | + mandateType 96 | + '}'; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/objects/DirectDebitTestProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.objects; 24 | 25 | import static org.openknowledgehub.api.objects.TestObjects.accountIdentification; 26 | import static org.openknowledgehub.api.objects.TestObjects.mandate; 27 | 28 | import org.openknowledgehub.data.directdebit.DirectDebitDocumentData; 29 | import org.openknowledgehub.data.directdebit.DirectDebitPayment; 30 | import org.openknowledgehub.data.directdebit.DirectDebitPaymentBuilder; 31 | import java.math.BigDecimal; 32 | import java.time.LocalDate; 33 | import java.util.List; 34 | 35 | public class DirectDebitTestProvider { 36 | 37 | public static final String MESSAGE_IDENTIFICATION = "messageId"; 38 | 39 | public DirectDebitPaymentTestProvider payment() { 40 | return new DirectDebitPaymentTestProvider(); 41 | } 42 | 43 | public DirectDebitDocumentDataTestProvider document() { 44 | return new DirectDebitDocumentDataTestProvider(); 45 | } 46 | 47 | public static class DirectDebitDocumentDataTestProvider { 48 | public DirectDebitDocumentData defaultDocument() { 49 | return new DirectDebitDocumentData( 50 | MESSAGE_IDENTIFICATION, 51 | TestObjects.accountIdentification().defaultAccount(), 52 | List.of(TestObjects.directDebit().payment().defaultPayment())); 53 | } 54 | } 55 | 56 | public static class DirectDebitPaymentTestProvider { 57 | public static final String PAYMENT_IDENTIFICATION = "identification"; 58 | public static final String REASON_FOR_PAYMENT = "Invoice XXX"; 59 | public static final LocalDate DUE_AT = LocalDate.of(2021, 1, 1); 60 | public static final BigDecimal AMOUNT = BigDecimal.valueOf(5.56); 61 | 62 | public DirectDebitPaymentBuilder defaultBuilder() { 63 | return DirectDebitPaymentBuilder.withPayment() 64 | .withIdentification(PAYMENT_IDENTIFICATION) 65 | .withDirectDebitDueAt(DUE_AT) 66 | .withAmount(AMOUNT) 67 | .withMandate(mandate().defaultMandate()) 68 | .withReasonForPayment(REASON_FOR_PAYMENT) 69 | .withDebitor(accountIdentification().defaultAccount()); 70 | } 71 | 72 | public DirectDebitPayment defaultPayment() { 73 | return new DirectDebitPayment( 74 | PAYMENT_IDENTIFICATION, 75 | AMOUNT, 76 | accountIdentification().defaultAccount(), 77 | REASON_FOR_PAYMENT, 78 | DUE_AT, 79 | mandate().defaultMandate()); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/transfer/SepaTransferPaymentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.transfer; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.exception.JSepaValidationException; 27 | import org.openknowledgehub.util.JSepaContentSanitizer; 28 | import java.math.BigDecimal; 29 | import java.math.RoundingMode; 30 | import java.util.Objects; 31 | 32 | public class SepaTransferPaymentBuilder { 33 | 34 | private BigDecimal amount; 35 | private AccountIdentification payee; 36 | private String reasonForPayment; 37 | private String endToEndId; 38 | 39 | private SepaTransferPaymentBuilder() {} 40 | 41 | public static SepaTransferPaymentBuilder withPayment() { 42 | return new SepaTransferPaymentBuilder(); 43 | } 44 | 45 | public SepaTransferPaymentBuilder withAmount(BigDecimal amount) { 46 | if (Objects.isNull(amount)) { 47 | throw new JSepaValidationException("'amount' cannot be null"); 48 | } 49 | 50 | if (amount.compareTo(BigDecimal.ZERO) <= 0) { 51 | throw new JSepaValidationException("'amount' should be greater than 0"); 52 | } 53 | 54 | this.amount = amount.setScale(2, RoundingMode.HALF_UP); 55 | 56 | return this; 57 | } 58 | 59 | public SepaTransferPaymentBuilder withPayee(AccountIdentification payee) { 60 | if (Objects.isNull(payee)) { 61 | throw new JSepaValidationException("'payee' cannot be null"); 62 | } 63 | 64 | this.payee = payee; 65 | 66 | return this; 67 | } 68 | 69 | public SepaTransferPaymentBuilder withReasonForPayment(String reasonForPayment) { 70 | if (Objects.isNull(reasonForPayment)) { 71 | throw new JSepaValidationException("'reasonForPayment' cannot be null"); 72 | } 73 | 74 | if (reasonForPayment.isBlank()) { 75 | throw new JSepaValidationException("'reasonForPayment' cannot be empty"); 76 | } 77 | 78 | this.reasonForPayment = JSepaContentSanitizer.of(reasonForPayment).sanitize(); 79 | 80 | return this; 81 | } 82 | 83 | public SepaTransferPaymentBuilder withEndToEndId(String endToEndId) { 84 | if (Objects.isNull(endToEndId)) { 85 | throw new JSepaValidationException("'endToEndId' cannot be null"); 86 | } 87 | 88 | if (endToEndId.isBlank()) { 89 | throw new JSepaValidationException("'endToEndId' cannot be empty"); 90 | } 91 | 92 | this.endToEndId = endToEndId; 93 | 94 | return this; 95 | } 96 | 97 | public SepaTransferPayment build() { 98 | return new SepaTransferPayment(amount, payee, reasonForPayment, endToEndId); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/transfer/SepaTransferPaymentTest.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.data.transfer; 2 | 3 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 4 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.AMOUNT; 5 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.END_TO_END_ID; 6 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.REASON_FOR_PAYMENT; 7 | import static org.openknowledgehub.api.objects.TestObjects.accountIdentification; 8 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 9 | 10 | import org.openknowledgehub.data.common.AccountIdentification; 11 | import org.openknowledgehub.exception.JSepaValidationException; 12 | import java.math.BigDecimal; 13 | import java.util.stream.Stream; 14 | import org.junit.jupiter.api.DisplayName; 15 | import org.junit.jupiter.api.Test; 16 | import org.junit.jupiter.params.ParameterizedTest; 17 | import org.junit.jupiter.params.provider.Arguments; 18 | import org.junit.jupiter.params.provider.MethodSource; 19 | 20 | @DisplayName("Test SepaTransferPayment data class") 21 | class SepaTransferPaymentTest { 22 | 23 | @Test 24 | @DisplayName("Should create a valid SepaTransferPayment") 25 | void testCreate() { 26 | final var createdPayment = 27 | new SepaTransferPayment( 28 | AMOUNT, accountIdentification().defaultAccount(), REASON_FOR_PAYMENT, END_TO_END_ID); 29 | 30 | jSepaAssertThat(createdPayment) 31 | .isNotNull() 32 | .hasAmount(AMOUNT) 33 | .hasReasonForPayment(REASON_FOR_PAYMENT) 34 | .hasEndToEndId(END_TO_END_ID); 35 | 36 | jSepaAssertThat(createdPayment.getPayee()).hasDefaultTestValues(); 37 | } 38 | 39 | @Test 40 | @DisplayName("Should create an empty SepaTransferPayment for JAX-B") 41 | void testCreateEmpty() { 42 | final var createdPayment = new SepaTransferPayment(); 43 | 44 | jSepaAssertThat(createdPayment).isNotNull().isEmpty(); 45 | } 46 | 47 | @Test 48 | @DisplayName("Should allow with null reason for payment") 49 | void testCreateWithNullReasonForPayment() { 50 | final var createdPayment = 51 | new SepaTransferPayment( 52 | AMOUNT, accountIdentification().defaultAccount(), null, END_TO_END_ID); 53 | 54 | jSepaAssertThat(createdPayment) 55 | .isNotNull() 56 | .hasAmount(AMOUNT) 57 | .hasReasonForPayment(null) 58 | .hasEndToEndId(END_TO_END_ID); 59 | 60 | jSepaAssertThat(createdPayment.getPayee()).hasDefaultTestValues(); 61 | } 62 | 63 | @ParameterizedTest 64 | @MethodSource("provideNullTestArguments") 65 | @DisplayName("Should not allow null values") 66 | void testCreateWithNullValues( 67 | final BigDecimal givenAmount, 68 | final AccountIdentification givenPayee, 69 | final String givenEndToEndId, 70 | final String expectedErrorMessage) { 71 | 72 | assertThatThrownBy( 73 | () -> 74 | new SepaTransferPayment( 75 | givenAmount, givenPayee, REASON_FOR_PAYMENT, givenEndToEndId)) 76 | .isInstanceOf(JSepaValidationException.class) 77 | .hasMessage(expectedErrorMessage); 78 | } 79 | 80 | private static Stream provideNullTestArguments() { 81 | return Stream.of( 82 | Arguments.of( 83 | null, 84 | accountIdentification().defaultAccount(), 85 | END_TO_END_ID, 86 | "SepaTransferPayment 'amount' cannot be null"), 87 | Arguments.of(AMOUNT, null, END_TO_END_ID, "SepaTransferPayment 'payee' cannot be null"), 88 | Arguments.of( 89 | AMOUNT, 90 | accountIdentification().defaultAccount(), 91 | null, 92 | "SepaTransferPayment 'endToEndId' cannot be null")); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/common/AccountIdentificationBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.common; 24 | 25 | import org.openknowledgehub.exception.JSepaValidationException; 26 | import org.openknowledgehub.util.JSepaContentSanitizer; 27 | import org.openknowledgehub.util.JSepaValidator; 28 | import java.util.Objects; 29 | 30 | public class AccountIdentificationBuilder { 31 | 32 | private String name; 33 | private String identifier; 34 | private String bic; 35 | private String iban; 36 | 37 | private AccountIdentificationBuilder() {} 38 | 39 | public static AccountIdentificationBuilder withName(String name) { 40 | if (Objects.isNull(name)) { 41 | throw new JSepaValidationException("'name' cannot be null"); 42 | } 43 | 44 | if (name.isBlank()) { 45 | throw new JSepaValidationException("'name' cannot be empty"); 46 | } 47 | 48 | AccountIdentificationBuilder builder = new AccountIdentificationBuilder(); 49 | 50 | builder.name = JSepaContentSanitizer.of(name).withMaxLength(70).sanitize(); 51 | 52 | return builder; 53 | } 54 | 55 | public AccountIdentificationBuilder withIdentifier(String identifier) { 56 | if (Objects.isNull(identifier)) { 57 | throw new JSepaValidationException("'identifier' cannot be null"); 58 | } 59 | 60 | if (identifier.isBlank()) { 61 | throw new JSepaValidationException("'identifier' cannot be empty"); 62 | } 63 | 64 | this.identifier = identifier; 65 | 66 | return this; 67 | } 68 | 69 | public AccountIdentificationBuilder withBic(String bic) { 70 | if (Objects.isNull(bic)) { 71 | throw new JSepaValidationException("'bic' cannot be null"); 72 | } 73 | 74 | if (bic.isBlank()) { 75 | throw new JSepaValidationException("'bic' cannot be empty"); 76 | } 77 | 78 | if (!JSepaValidator.isValidBic(bic)) { 79 | throw new JSepaValidationException("'bic' is not in a valid shape"); 80 | } 81 | 82 | this.bic = bic; 83 | 84 | return this; 85 | } 86 | 87 | public AccountIdentificationBuilder withIban(String iban) { 88 | if (Objects.isNull(iban)) { 89 | throw new JSepaValidationException("'iban' cannot be null"); 90 | } 91 | 92 | if (iban.isBlank()) { 93 | throw new JSepaValidationException("'iban' cannot be empty"); 94 | } 95 | 96 | if (!JSepaValidator.isValidIban(iban)) { 97 | throw new JSepaValidationException("'iban' is not in a valid shape"); 98 | } 99 | 100 | this.iban = iban; 101 | 102 | return this; 103 | } 104 | 105 | public AccountIdentification build() { 106 | return new AccountIdentification(name, identifier, bic, iban); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/directdebit/DirectDebitPaymentBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.directdebit; 24 | 25 | import org.openknowledgehub.data.common.AccountIdentification; 26 | import org.openknowledgehub.exception.JSepaException; 27 | import org.openknowledgehub.util.JSepaContentSanitizer; 28 | import java.math.BigDecimal; 29 | import java.math.RoundingMode; 30 | import java.time.LocalDate; 31 | import java.util.Objects; 32 | 33 | public class DirectDebitPaymentBuilder { 34 | 35 | private String identification; 36 | private BigDecimal amount; 37 | private AccountIdentification debitor; 38 | private String reasonForPayment; 39 | private LocalDate directDebitDueAt; 40 | private Mandate mandate; 41 | 42 | private DirectDebitPaymentBuilder() {} 43 | 44 | public static DirectDebitPaymentBuilder withPayment() { 45 | return new DirectDebitPaymentBuilder(); 46 | } 47 | 48 | public DirectDebitPaymentBuilder withAmount(BigDecimal amount) { 49 | Objects.requireNonNull(amount); 50 | 51 | if (amount.compareTo(BigDecimal.ZERO) < 0) { 52 | throw new JSepaException("Payment amount must be greater than zero"); 53 | } 54 | 55 | this.amount = amount.setScale(2, RoundingMode.HALF_UP); 56 | 57 | return this; 58 | } 59 | 60 | public DirectDebitPaymentBuilder withDebitor(AccountIdentification identification) { 61 | Objects.requireNonNull(identification); 62 | 63 | this.debitor = identification; 64 | 65 | return this; 66 | } 67 | 68 | public DirectDebitPaymentBuilder withIdentification(String identification) { 69 | Objects.requireNonNull(identification); 70 | 71 | if (identification.isEmpty()) { 72 | throw new JSepaException("Identification cannot be empty"); 73 | } 74 | 75 | this.identification = JSepaContentSanitizer.of(identification).sanitize(); 76 | 77 | return this; 78 | } 79 | 80 | public DirectDebitPaymentBuilder withMandate(Mandate mandate) { 81 | Objects.requireNonNull(mandate); 82 | 83 | this.mandate = mandate; 84 | return this; 85 | } 86 | 87 | public DirectDebitPaymentBuilder withDirectDebitDueAt(LocalDate directDebitDueAt) { 88 | Objects.requireNonNull(directDebitDueAt); 89 | 90 | this.directDebitDueAt = directDebitDueAt; 91 | 92 | return this; 93 | } 94 | 95 | public DirectDebitPaymentBuilder withReasonForPayment(String reasonForPayment) { 96 | Objects.requireNonNull(reasonForPayment); 97 | 98 | this.reasonForPayment = JSepaContentSanitizer.of(reasonForPayment).sanitize(); 99 | 100 | return this; 101 | } 102 | 103 | public DirectDebitPayment build() { 104 | return new DirectDebitPayment( 105 | identification, amount, debitor, reasonForPayment, directDebitDueAt, mandate); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/util/JSepaContentSanitizerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.util; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | import org.junit.jupiter.api.DisplayName; 28 | import org.junit.jupiter.api.Test; 29 | 30 | @DisplayName("Test JSepa content sanitizer") 31 | class JSepaContentSanitizerTest { 32 | 33 | @Test 34 | @DisplayName("Should remain all allowed chars") 35 | void testSanitizeAllAllowedCharsRemain() { 36 | final String givenInput = "Hello123 &*$%/?:().,'+-"; 37 | 38 | final String sanitizedContent = JSepaContentSanitizer.of(givenInput).sanitize(); 39 | 40 | assertThat(sanitizedContent).isEqualTo(givenInput); 41 | } 42 | 43 | @Test 44 | @DisplayName("Should replace forbidden chars") 45 | void testSanitizeRemovesForbiddenChars() { 46 | final String givenInput = "Hello@#World!€"; 47 | final String expectedOutput = "Hello World"; 48 | 49 | final String sanitizedContent = JSepaContentSanitizer.of(givenInput).sanitize(); 50 | 51 | assertThat(sanitizedContent).isEqualTo(expectedOutput); 52 | } 53 | 54 | @Test 55 | @DisplayName("Should cut of too long content") 56 | void testSanitizeWithMaxLength() { 57 | final String givenInput = "Hello World 123456"; 58 | final int maxLength = 10; 59 | final String expectedOutput = "Hello Worl"; 60 | 61 | final String sanitizedContent = 62 | JSepaContentSanitizer.of(givenInput).withMaxLength(maxLength).sanitize(); 63 | 64 | assertThat(sanitizedContent).isEqualTo(expectedOutput); 65 | } 66 | 67 | @Test 68 | @DisplayName("Should do nothing on empty String") 69 | void testSanitizeEmptyString() { 70 | final String givenInput = ""; 71 | 72 | final String sanitizedContent = JSepaContentSanitizer.of(givenInput).sanitize(); 73 | 74 | assertThat(sanitizedContent).isEmpty(); 75 | } 76 | 77 | @Test 78 | @DisplayName("Should return empty String if content is null") 79 | void testSanitizeNullInput() { 80 | final String sanitizedContent = JSepaContentSanitizer.of(null).sanitize(); 81 | 82 | assertThat(sanitizedContent).isEmpty(); 83 | } 84 | 85 | @Test 86 | @DisplayName("Should replace all forbidden chars") 87 | void testSanitizeOnlyForbiddenChars() { 88 | final String givenInput = "@#€§!"; 89 | 90 | final String sanitizedContent = JSepaContentSanitizer.of(givenInput).sanitize(); 91 | 92 | assertThat(sanitizedContent).isEmpty(); 93 | } 94 | 95 | @Test 96 | @DisplayName("Should preserve whitespaces") 97 | void testSanitizeWhitespacePreserved() { 98 | final String givenInput = "Hello World"; 99 | 100 | final String sanitizedContent = JSepaContentSanitizer.of(givenInput).sanitize(); 101 | 102 | assertThat(sanitizedContent).isEqualTo(givenInput); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/transformer/sepa/AbstractJSepaTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.transformer.sepa; 24 | 25 | import org.openknowledgehub.data.SepaXmlDocument; 26 | import org.openknowledgehub.exception.JSepaException; 27 | import org.openknowledgehub.transformer.JSepaTransformer; 28 | import jakarta.xml.bind.JAXBContext; 29 | import jakarta.xml.bind.JAXBException; 30 | import jakarta.xml.bind.util.JAXBSource; 31 | import java.io.IOException; 32 | import java.io.InputStream; 33 | import java.io.StringWriter; 34 | import javax.xml.transform.Source; 35 | import javax.xml.transform.Transformer; 36 | import javax.xml.transform.TransformerException; 37 | import javax.xml.transform.TransformerFactory; 38 | import javax.xml.transform.stream.StreamResult; 39 | import javax.xml.transform.stream.StreamSource; 40 | 41 | public abstract class AbstractJSepaTransformer 42 | implements JSepaTransformer { 43 | 44 | private final TransformerFactory transformerFactory; 45 | 46 | protected AbstractJSepaTransformer() { 47 | transformerFactory = TransformerFactory.newDefaultInstance(); 48 | } 49 | 50 | protected abstract Class getSepaDocumentType(); 51 | 52 | protected abstract String getXsltFileName(); 53 | 54 | @Override 55 | public String transform(I sourceDocument) throws JSepaException { 56 | Transformer transformer = createTransformer(); 57 | Source inputXml = createSource(createContext(), sourceDocument); 58 | 59 | return transformInput(transformer, inputXml); 60 | } 61 | 62 | private JAXBContext createContext() { 63 | try { 64 | return JAXBContext.newInstance(getSepaDocumentType()); 65 | } catch (JAXBException exception) { 66 | throw new JSepaException("Could not create a new JAXBContext", exception); 67 | } 68 | } 69 | 70 | private Transformer createTransformer() { 71 | try (InputStream transformFileStream = 72 | DirectDebitTransformer.class.getResourceAsStream(getXsltFileName())) { 73 | 74 | return transformerFactory.newTransformer(new StreamSource(transformFileStream)); 75 | } catch (IOException | TransformerException exception) { 76 | throw new JSepaException("Could not create a new Transformer", exception); 77 | } 78 | } 79 | 80 | private Source createSource(JAXBContext context, I sourceDocument) { 81 | try { 82 | return new JAXBSource(context, sourceDocument); 83 | } catch (JAXBException exception) { 84 | throw new JSepaException("Could not create a new JAXBSource", exception); 85 | } 86 | } 87 | 88 | private String transformInput(Transformer transformer, Source source) { 89 | try (StringWriter resultWriter = new StringWriter()) { 90 | transformer.transform(source, new StreamResult(resultWriter)); 91 | 92 | return resultWriter.toString(); 93 | } catch (IOException | TransformerException exception) { 94 | throw new JSepaException("Could not transform source XML", exception); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/common/AccountIdentification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.common; 24 | 25 | import org.openknowledgehub.dsl.AccountIdentificationSelect; 26 | import org.openknowledgehub.exception.JSepaValidationException; 27 | import jakarta.xml.bind.annotation.XmlElement; 28 | import java.util.Objects; 29 | 30 | public class AccountIdentification implements AccountIdentificationSelect { 31 | 32 | @XmlElement(name = "Name") 33 | private final String name; 34 | 35 | @XmlElement(name = "Identifier") 36 | private final String identifier; 37 | 38 | @XmlElement(name = "Bic") 39 | private final String bic; 40 | 41 | @XmlElement(name = "Iban") 42 | private final String iban; 43 | 44 | /** Default constructor for JAX-B only. You should no used programmatically */ 45 | public AccountIdentification() { 46 | this.name = null; 47 | this.identifier = null; 48 | this.bic = null; 49 | this.iban = null; 50 | } 51 | 52 | public AccountIdentification(String name, String identifier, String bic, String iban) { 53 | if (Objects.isNull(name)) { 54 | throw new JSepaValidationException("AccountIdentifier 'name' cannot be null"); 55 | } 56 | 57 | if (Objects.isNull(identifier)) { 58 | throw new JSepaValidationException("AccountIdentifier 'identifier' cannot be null"); 59 | } 60 | 61 | if (Objects.isNull(bic)) { 62 | throw new JSepaValidationException("AccountIdentifier 'bic' cannot be null"); 63 | } 64 | 65 | if (Objects.isNull(iban)) { 66 | throw new JSepaValidationException("AccountIdentifier 'iban' cannot be null"); 67 | } 68 | 69 | this.name = name; 70 | this.identifier = identifier; 71 | this.bic = bic; 72 | this.iban = iban; 73 | } 74 | 75 | @Override 76 | public String getName() { 77 | return name; 78 | } 79 | 80 | @Override 81 | public String getIdentifier() { 82 | return identifier; 83 | } 84 | 85 | @Override 86 | public String getBic() { 87 | return bic; 88 | } 89 | 90 | @Override 91 | public String getIban() { 92 | return iban; 93 | } 94 | 95 | @Override 96 | public boolean equals(Object o) { 97 | if (o == null || getClass() != o.getClass()) return false; 98 | AccountIdentification that = (AccountIdentification) o; 99 | return Objects.equals(name, that.name) 100 | && Objects.equals(identifier, that.identifier) 101 | && Objects.equals(bic, that.bic) 102 | && Objects.equals(iban, that.iban); 103 | } 104 | 105 | @Override 106 | public int hashCode() { 107 | return Objects.hash(name, identifier, bic, iban); 108 | } 109 | 110 | @Override 111 | public String toString() { 112 | return "AccountIdentification{" 113 | + "name='" 114 | + name 115 | + '\'' 116 | + ", identifier='" 117 | + identifier 118 | + '\'' 119 | + '}'; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/common/AccountIdentificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.common; 24 | 25 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 26 | import static org.openknowledgehub.api.objects.AccountIdentificationTestProvider.BIC; 27 | import static org.openknowledgehub.api.objects.AccountIdentificationTestProvider.IBAN; 28 | import static org.openknowledgehub.api.objects.AccountIdentificationTestProvider.IDENTIFICATION; 29 | import static org.openknowledgehub.api.objects.AccountIdentificationTestProvider.NAME; 30 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 31 | 32 | import org.openknowledgehub.exception.JSepaValidationException; 33 | import java.util.stream.Stream; 34 | import org.junit.jupiter.api.DisplayName; 35 | import org.junit.jupiter.api.Test; 36 | import org.junit.jupiter.params.ParameterizedTest; 37 | import org.junit.jupiter.params.provider.Arguments; 38 | import org.junit.jupiter.params.provider.MethodSource; 39 | 40 | @DisplayName("Test the AccountIdentification data class") 41 | class AccountIdentificationTest { 42 | 43 | @Test 44 | @DisplayName("Should create a valid AccountIdentification") 45 | void testCreate() { 46 | final var createdAccountIdentification = 47 | new AccountIdentification(NAME, IDENTIFICATION, BIC, IBAN); 48 | 49 | jSepaAssertThat(createdAccountIdentification) 50 | .hasName(NAME) 51 | .hasIdentifier(IDENTIFICATION) 52 | .hasBic(BIC) 53 | .hasIban(IBAN); 54 | } 55 | 56 | @Test 57 | @DisplayName("Should create an empty AccountIdentification for JAX-B") 58 | void testCreateEmptyAccountIdentification() { 59 | final var createdAccountIdentification = new AccountIdentification(); 60 | 61 | jSepaAssertThat(createdAccountIdentification).isEmpty(); 62 | } 63 | 64 | @ParameterizedTest 65 | @MethodSource("provideNullTestArguments") 66 | @DisplayName("Should not allow null values") 67 | void testCreateWithNullValues( 68 | final String givenName, 69 | final String givenIdentification, 70 | final String givenBic, 71 | final String givenIban, 72 | final String expectedErrorMessage) { 73 | 74 | assertThatThrownBy( 75 | () -> new AccountIdentification(givenName, givenIdentification, givenBic, givenIban)) 76 | .isInstanceOf(JSepaValidationException.class) 77 | .hasMessage(expectedErrorMessage); 78 | } 79 | 80 | private static Stream provideNullTestArguments() { 81 | return Stream.of( 82 | Arguments.of( 83 | null, IDENTIFICATION, BIC, IBAN, "AccountIdentifier 'name' cannot be null"), 84 | Arguments.of(NAME, null, BIC, IBAN, "AccountIdentifier 'identifier' cannot be null"), 85 | Arguments.of( 86 | NAME, IDENTIFICATION, null, IBAN, "AccountIdentifier 'bic' cannot be null"), 87 | Arguments.of( 88 | NAME, IDENTIFICATION, BIC, null, "AccountIdentifier 'iban' cannot be null")); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/api/assertions/DirectDebitPaymentAssert.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.api.assertions; 24 | 25 | import static org.assertj.core.api.Assertions.assertThat; 26 | 27 | import org.openknowledgehub.api.objects.DirectDebitTestProvider; 28 | import org.openknowledgehub.api.objects.TestObjects; 29 | import org.openknowledgehub.data.common.AccountIdentification; 30 | import org.openknowledgehub.data.directdebit.DirectDebitPayment; 31 | import org.openknowledgehub.data.directdebit.Mandate; 32 | import java.math.BigDecimal; 33 | import java.time.LocalDate; 34 | import org.assertj.core.api.AbstractAssert; 35 | 36 | public class DirectDebitPaymentAssert 37 | extends AbstractAssert { 38 | protected DirectDebitPaymentAssert(DirectDebitPayment directDebitPayment) { 39 | super(directDebitPayment, DirectDebitPaymentAssert.class); 40 | } 41 | 42 | public DirectDebitPaymentAssert hasDefaultTestValues() { 43 | hasAmount(DirectDebitTestProvider.DirectDebitPaymentTestProvider.AMOUNT); 44 | hasIdentification( 45 | DirectDebitTestProvider.DirectDebitPaymentTestProvider.PAYMENT_IDENTIFICATION); 46 | hasDebitor(TestObjects.accountIdentification().defaultAccount()); 47 | hasReasonForPayment(DirectDebitTestProvider.DirectDebitPaymentTestProvider.REASON_FOR_PAYMENT); 48 | hasDueAt(DirectDebitTestProvider.DirectDebitPaymentTestProvider.DUE_AT); 49 | hasMandate(TestObjects.mandate().defaultMandate()); 50 | 51 | return this; 52 | } 53 | 54 | public DirectDebitPaymentAssert isEmpty() { 55 | assertThat(actual.getIdentification()).isNull(); 56 | assertThat(actual.getAmount()).isNull(); 57 | assertThat(actual.getAmount()).isNull(); 58 | assertThat(actual.getReasonForPayment()).isNull(); 59 | assertThat(actual.getCurrency()).isNull(); 60 | assertThat(actual.getMandate()).isNull(); 61 | 62 | return this; 63 | } 64 | 65 | public DirectDebitPaymentAssert hasIdentification(String expectedIdentification) { 66 | assertThat(actual.getIdentification()).isEqualTo(expectedIdentification); 67 | 68 | return this; 69 | } 70 | 71 | public DirectDebitPaymentAssert hasAmount(BigDecimal expectedAmount) { 72 | assertThat(actual.getAmount()).isEqualTo(expectedAmount); 73 | 74 | return this; 75 | } 76 | 77 | public DirectDebitPaymentAssert hasDebitor(AccountIdentification expectedAccountIdentification) { 78 | assertThat(actual.getDebitor()).isEqualTo(expectedAccountIdentification); 79 | 80 | return this; 81 | } 82 | 83 | public DirectDebitPaymentAssert hasReasonForPayment(String reasonForPayment) { 84 | assertThat(actual.getReasonForPayment()).isEqualTo(reasonForPayment); 85 | 86 | return this; 87 | } 88 | 89 | public DirectDebitPaymentAssert hasDueAt(LocalDate expectedDueAt) { 90 | assertThat(actual.getDirectDebitDueAt()).isEqualTo(expectedDueAt); 91 | 92 | return this; 93 | } 94 | 95 | public DirectDebitPaymentAssert hasMandate(Mandate expectedMandate) { 96 | assertThat(actual.getMandate()).isEqualTo(expectedMandate); 97 | 98 | return this; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/org/openknowledgehub/data/transfer/SepaTransferDocumentData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2025 openknowledgehub.org 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 7 | * and associated documentation files (the “Software”), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, 9 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in all copies or 13 | * substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | package org.openknowledgehub.data.transfer; 24 | 25 | import org.openknowledgehub.data.SepaXmlDocument; 26 | import org.openknowledgehub.data.common.AccountIdentification; 27 | import org.openknowledgehub.data.configuration.LocalDateTimeAdapter; 28 | import org.openknowledgehub.exception.JSepaValidationException; 29 | import jakarta.xml.bind.annotation.XmlAccessType; 30 | import jakarta.xml.bind.annotation.XmlAccessorType; 31 | import jakarta.xml.bind.annotation.XmlElement; 32 | import jakarta.xml.bind.annotation.XmlElementWrapper; 33 | import jakarta.xml.bind.annotation.XmlRootElement; 34 | import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 35 | import java.time.LocalDateTime; 36 | import java.util.List; 37 | import java.util.Objects; 38 | 39 | @XmlRootElement(name = "SepaTransferDocumentData") 40 | @XmlAccessorType(XmlAccessType.FIELD) 41 | public class SepaTransferDocumentData implements SepaXmlDocument { 42 | 43 | @XmlElement(name = "CreationDateTime") 44 | @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) 45 | private final LocalDateTime creationTime; 46 | 47 | @XmlElement(name = "Payer") 48 | private final AccountIdentification payer; 49 | 50 | @XmlElement(name = "MessageId") 51 | private final String messageId; 52 | 53 | @XmlElement(name = "DateOfExecution") 54 | @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) 55 | private final LocalDateTime dateOfExecution; 56 | 57 | @XmlElementWrapper(name = "Payments") 58 | @XmlElement(name = "Payment") 59 | private final List payments; 60 | 61 | public SepaTransferDocumentData() { 62 | this.creationTime = null; 63 | this.payer = null; 64 | this.messageId = null; 65 | this.dateOfExecution = null; 66 | this.payments = null; 67 | } 68 | 69 | public SepaTransferDocumentData( 70 | AccountIdentification payer, 71 | String messageId, 72 | LocalDateTime dateOfExecution, 73 | List payments) { 74 | 75 | if (Objects.isNull(payer)) { 76 | throw new JSepaValidationException("SepaTransferDocumentData 'payer' cannot be null"); 77 | } 78 | 79 | if (Objects.isNull(messageId)) { 80 | throw new JSepaValidationException("SepaTransferDocumentData 'messageId' cannot be null"); 81 | } 82 | 83 | if (Objects.isNull(dateOfExecution)) { 84 | throw new JSepaValidationException( 85 | "SepaTransferDocumentData 'dateOfExecution' cannot be null"); 86 | } 87 | 88 | if (Objects.isNull(payments)) { 89 | throw new JSepaValidationException("SepaTransferDocumentData 'payments' cannot be null"); 90 | } 91 | 92 | this.creationTime = LocalDateTime.now(); 93 | this.payer = payer; 94 | this.messageId = messageId; 95 | this.dateOfExecution = dateOfExecution; 96 | this.payments = payments; 97 | } 98 | 99 | public LocalDateTime getCreationTime() { 100 | return creationTime; 101 | } 102 | 103 | public AccountIdentification getPayer() { 104 | return payer; 105 | } 106 | 107 | public String getMessageId() { 108 | return messageId; 109 | } 110 | 111 | public LocalDateTime getDateOfExecution() { 112 | return dateOfExecution; 113 | } 114 | 115 | public List getPayments() { 116 | return payments; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/transfer/SepaTransferDocumentDataTest.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.data.transfer; 2 | 3 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 4 | import static org.openknowledgehub.api.objects.DirectDebitTestProvider.MESSAGE_IDENTIFICATION; 5 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.DATE_OF_EXECUTION; 6 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.MESSAGE_ID; 7 | import static org.openknowledgehub.api.objects.TestObjects.accountIdentification; 8 | import static org.openknowledgehub.api.objects.TestObjects.transfer; 9 | import static org.assertj.core.api.Assertions.assertThat; 10 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 11 | 12 | import org.openknowledgehub.api.objects.TestObjects; 13 | import org.openknowledgehub.data.common.AccountIdentification; 14 | import org.openknowledgehub.exception.JSepaValidationException; 15 | import java.time.LocalDateTime; 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.stream.Stream; 19 | import org.junit.jupiter.api.DisplayName; 20 | import org.junit.jupiter.api.Test; 21 | import org.junit.jupiter.params.ParameterizedTest; 22 | import org.junit.jupiter.params.provider.Arguments; 23 | import org.junit.jupiter.params.provider.MethodSource; 24 | 25 | @DisplayName("Test SepaTransferDocument data class") 26 | class SepaTransferDocumentDataTest { 27 | 28 | @Test 29 | @DisplayName("Should create a valid SepaTransferDocumentData") 30 | void testCreate() { 31 | final var createdDocumentData = 32 | new SepaTransferDocumentData( 33 | TestObjects.accountIdentification().defaultAccount(), 34 | MESSAGE_ID, 35 | DATE_OF_EXECUTION, 36 | List.of(TestObjects.transfer().payment().defaultPayment())); 37 | 38 | jSepaAssertThat(createdDocumentData) 39 | .isNotNull() 40 | .hasMessageId(MESSAGE_ID) 41 | .hasDateOfExecution(DATE_OF_EXECUTION); 42 | 43 | jSepaAssertThat(createdDocumentData.getPayer()).isNotNull().hasDefaultTestValues(); 44 | 45 | assertThat(createdDocumentData.getPayments()).isNotNull().isNotEmpty().hasSize(1); 46 | 47 | jSepaAssertThat(createdDocumentData.getPayments().get(0)).isNotNull().hasDefaultTestValues(); 48 | } 49 | 50 | @Test 51 | @DisplayName("Should create an empty SepaTransferDocumentData for JAX-B") 52 | void testCreateEmpty() { 53 | final var createdDocumentData = new SepaTransferDocumentData(); 54 | 55 | jSepaAssertThat(createdDocumentData).isNotNull().isEmpty(); 56 | } 57 | 58 | @ParameterizedTest 59 | @MethodSource("provideNullTestArguments") 60 | @DisplayName("Should not allow null values") 61 | void testCreateWithNullValues( 62 | final AccountIdentification givenPayer, 63 | final String givenMessageId, 64 | final LocalDateTime givenDateOfExecution, 65 | final List givenPayments, 66 | final String expectedErrorMessage) { 67 | 68 | assertThatThrownBy( 69 | () -> 70 | new SepaTransferDocumentData( 71 | givenPayer, givenMessageId, givenDateOfExecution, givenPayments)) 72 | .isInstanceOf(JSepaValidationException.class) 73 | .hasMessage(expectedErrorMessage); 74 | } 75 | 76 | private static Stream provideNullTestArguments() { 77 | return Stream.of( 78 | Arguments.of( 79 | null, 80 | MESSAGE_IDENTIFICATION, 81 | DATE_OF_EXECUTION, 82 | Collections.singletonList(transfer().payment().defaultPayment()), 83 | "SepaTransferDocumentData 'payer' cannot be null"), 84 | Arguments.of( 85 | accountIdentification().defaultAccount(), 86 | null, 87 | DATE_OF_EXECUTION, 88 | Collections.singletonList(transfer().payment().defaultPayment()), 89 | "SepaTransferDocumentData 'messageId' cannot be null"), 90 | Arguments.of( 91 | accountIdentification().defaultAccount(), 92 | MESSAGE_IDENTIFICATION, 93 | null, 94 | Collections.singletonList(transfer().payment().defaultPayment()), 95 | "SepaTransferDocumentData 'dateOfExecution' cannot be null"), 96 | Arguments.of( 97 | accountIdentification().defaultAccount(), 98 | MESSAGE_IDENTIFICATION, 99 | DATE_OF_EXECUTION, 100 | null, 101 | "SepaTransferDocumentData 'payments' cannot be null")); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/test/java/org/openknowledgehub/data/transfer/SepaTransferPaymentBuilderTest.java: -------------------------------------------------------------------------------- 1 | package org.openknowledgehub.data.transfer; 2 | 3 | import static org.openknowledgehub.api.assertions.JSepaAssertions.jSepaAssertThat; 4 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.AMOUNT; 5 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.END_TO_END_ID; 6 | import static org.openknowledgehub.api.objects.SepaTransferTestProvider.SepaTransferPaymentTestProvider.REASON_FOR_PAYMENT; 7 | import static org.openknowledgehub.api.objects.TestObjects.accountIdentification; 8 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 9 | 10 | import org.openknowledgehub.exception.JSepaValidationException; 11 | import java.math.BigDecimal; 12 | import org.junit.jupiter.api.BeforeEach; 13 | import org.junit.jupiter.api.DisplayName; 14 | import org.junit.jupiter.api.Test; 15 | 16 | @DisplayName("Test SepaTransferPayment builder") 17 | class SepaTransferPaymentBuilderTest { 18 | 19 | SepaTransferPaymentBuilder underTest; 20 | 21 | @BeforeEach 22 | void setup() { 23 | underTest = SepaTransferPaymentBuilder.withPayment(); 24 | } 25 | 26 | @Test 27 | @DisplayName("Should build a valid SepaTransferPayment") 28 | void testBuildValid() { 29 | final var createdPayment = 30 | underTest 31 | .withReasonForPayment(REASON_FOR_PAYMENT) 32 | .withAmount(AMOUNT) 33 | .withEndToEndId(END_TO_END_ID) 34 | .withPayee(accountIdentification().defaultAccount()) 35 | .build(); 36 | 37 | jSepaAssertThat(createdPayment) 38 | .isNotNull() 39 | .hasEndToEndId(END_TO_END_ID) 40 | .hasAmount(AMOUNT) 41 | .hasReasonForPayment(REASON_FOR_PAYMENT); 42 | 43 | jSepaAssertThat(createdPayment.getPayee()).isNotNull().hasDefaultTestValues(); 44 | } 45 | 46 | @Test 47 | @DisplayName("Should not allow to build with null reason for payment") 48 | void testCreateWithNullReasonForPayment() { 49 | assertThatThrownBy(() -> underTest.withReasonForPayment(null)) 50 | .isInstanceOf(JSepaValidationException.class) 51 | .hasMessage("'reasonForPayment' cannot be null"); 52 | } 53 | 54 | @Test 55 | @DisplayName("Should not allow to build with empty reason for payment") 56 | void testCreateWithEmptyReasonForPayment() { 57 | assertThatThrownBy(() -> underTest.withReasonForPayment(" ")) 58 | .isInstanceOf(JSepaValidationException.class) 59 | .hasMessage("'reasonForPayment' cannot be empty"); 60 | } 61 | 62 | @Test 63 | @DisplayName("Should not allow to build with null amount") 64 | void testCreateWithNullAmount() { 65 | assertThatThrownBy(() -> underTest.withAmount(null)) 66 | .isInstanceOf(JSepaValidationException.class) 67 | .hasMessage("'amount' cannot be null"); 68 | } 69 | 70 | @Test 71 | @DisplayName("Should not allow to build with negativ amount") 72 | void testCreateWithNegativAmount() { 73 | final var negativAmount = BigDecimal.valueOf(-3); 74 | 75 | assertThatThrownBy(() -> underTest.withAmount(negativAmount)) 76 | .isInstanceOf(JSepaValidationException.class) 77 | .hasMessage("'amount' should be greater than 0"); 78 | } 79 | 80 | @Test 81 | @DisplayName("Should not allow to build with zero amount") 82 | void testCreateWithZeroAmount() { 83 | final var zeroAmount = BigDecimal.valueOf(0); 84 | 85 | assertThatThrownBy(() -> underTest.withAmount(zeroAmount)) 86 | .isInstanceOf(JSepaValidationException.class) 87 | .hasMessage("'amount' should be greater than 0"); 88 | } 89 | 90 | @Test 91 | @DisplayName("Should not allow to build with null payee") 92 | void testCreateWithNullPayee() { 93 | assertThatThrownBy(() -> underTest.withPayee(null)) 94 | .isInstanceOf(JSepaValidationException.class) 95 | .hasMessage("'payee' cannot be null"); 96 | } 97 | 98 | @Test 99 | @DisplayName("Should not allow to build with null end to end id") 100 | void testCreateWithNullEndToEndId() { 101 | assertThatThrownBy(() -> underTest.withEndToEndId(null)) 102 | .isInstanceOf(JSepaValidationException.class) 103 | .hasMessage("'endToEndId' cannot be null"); 104 | } 105 | 106 | @Test 107 | @DisplayName("Should not allow to build with empty end to end id") 108 | void testCreateWithEmptyEndToEndId() { 109 | assertThatThrownBy(() -> underTest.withEndToEndId(" ")) 110 | .isInstanceOf(JSepaValidationException.class) 111 | .hasMessage("'endToEndId' cannot be empty"); 112 | } 113 | } 114 | --------------------------------------------------------------------------------