Skip to content
Snippets Groups Projects

#1070 Fix Invalid XML Validation

Merged Martin Vogel requested to merge bugfix/1070-invalid-xml-validation into main
1 file
+ 1
1
Compare changes
  • Side-by-side
  • Inline
@@ -63,7 +63,7 @@ public class SenderClientIT extends IntegrationTestBase {
}
@Test
void testSendAndConfirmCycle() throws IOException {
void testSendAndConfirmCycleWithJsonData() throws IOException {
// Given
final ApplicationConfig config = getConfigWithCredentialsFromEnvironment("TESTING", true);
@@ -71,7 +71,7 @@ public class SenderClientIT extends IntegrationTestBase {
final String submissionData = getResourceAsString("/submission_data.json");
final var submission = SendableSubmission.Builder()
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID")))
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID_JSON_DATA")))
.setServiceType("urn:de:fim:leika:leistung:99400048079000", "Test Service")
.setJsonData(submissionData, URI.create("https://schema.fitko.de/fim/s00000114_1.1.schema.json"))
.addAttachment(Attachment.fromPath(Path.of("src/test/resources/attachment.txt"), "text/plain"))
@@ -99,6 +99,43 @@ public class SenderClientIT extends IntegrationTestBase {
assertThat(new String(receivedSubmission.getAttachments().get(0).getDataAsBytes()), is("Test attachment"));
}
@Test
void testSendAndConfirmCycleWithXmlData() throws IOException {
// Given
final ApplicationConfig config = getConfigWithCredentialsFromEnvironment("TESTING", true);
final String submissionData = getResourceAsString("/submission_data.xml");
final var submission = SendableSubmission.Builder()
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID_XML_DATA")))
.setServiceType("urn:de:fim:leika:leistung:99400048079000", "Test Service")
.setXmlData(submissionData, URI.create("urn:de:fim:leika:leistung:99400048079000"))
.addAttachment(Attachment.fromPath(Path.of("src/test/resources/attachment.txt"), "text/plain"))
.addAttachment(Attachment.fromByteArray("attachment data".getBytes(), "text/plain"))
.addAttachment(Attachment.fromString("attachment data", "text/plain"))
.setReplyChannel(ReplyChannel.fromDeMail("test@mail.org"))
.build();
final var sentSubmission = ClientFactory.getSenderClient(config).send(submission);
assertNotNull(sentSubmission);
// When
final ReceivedSubmission receivedSubmission =
ClientFactory.getSubscriberClient(config)
.requestSubmission(sentSubmission.getSubmissionId());
// Then
assertNotNull(receivedSubmission);
assertThat(receivedSubmission.getDataAsString(), is(submissionData));
assertThat(receivedSubmission.getDataSchemaUri(), is(URI.create("urn:de:fim:leika:leistung:99400048079000")));
assertThat(receivedSubmission.getDataMimeType(), is("application/xml"));
assertThat(receivedSubmission.getAttachments(), hasSize(3));
assertThat(receivedSubmission.getMetadata().getReplyChannel(), is(ReplyChannel.fromDeMail("test@mail.org")));
assertThat(new String(receivedSubmission.getAttachments().get(0).getDataAsBytes()), is("Test attachment"));
}
@Test
void testSubmissionDataValidationFromLocalSchemaFile(@TempDir final Path tempDir) throws IOException {
@@ -114,7 +151,7 @@ public class SenderClientIT extends IntegrationTestBase {
final URI submissionDataSchemaUri = URI.create("https://schema.fitko.de/fim/s00000114_1.1.schema.json");
final var submission = SendableSubmission.Builder()
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID")))
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID_JSON_DATA")))
.setServiceType("urn:de:fim:leika:leistung:99400048079000", "Test Service")
.setJsonData(submissionData, submissionDataSchemaUri)
.addAttachment(Attachment.fromPath(Path.of("src/test/resources/attachment.txt"), "text/plain"))
@@ -135,7 +172,7 @@ public class SenderClientIT extends IntegrationTestBase {
// Given
final ApplicationConfig config = getConfigWithCredentialsFromEnvironment("TESTING", true);
final UUID destinationId = UUID.fromString(System.getenv("TEST_DESTINATION_ID"));
final UUID destinationId = UUID.fromString(System.getenv("TEST_DESTINATION_ID_JSON_DATA"));
final CryptoService cryptoService = new JWECryptoService(new HashService());
final SenderClient senderClient = ClientFactory.getSenderClient(config);
@@ -213,7 +250,7 @@ public class SenderClientIT extends IntegrationTestBase {
// When
final var submission = SendableSubmission.Builder()
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID")))
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID_JSON_DATA")))
.setServiceType("urn:de:fim:leika:leistung:99400048079000", "Test Service")
.setJsonData(getResourceAsString("/submission_data.json"), URI.create("https://schema.fitko.de/fim/s00000114_1.1.schema.json"))
.build();
@@ -236,7 +273,7 @@ public class SenderClientIT extends IntegrationTestBase {
final SenderClient senderClient = ClientFactory.getSenderClient(config);
final var submission = SendableSubmission.Builder()
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID")))
.setDestination(UUID.fromString(System.getenv("TEST_DESTINATION_ID_JSON_DATA")))
.setServiceType("urn:de:fim:leika:leistung:99400048079000", "Test Service")
.setJsonData(submissionData, URI.create("https://schema.fitko.de/fim/s00000114_1.1.schema.json"))
.addAttachment(Attachment.fromPath(Path.of("src/test/resources/attachment.txt"), "plain/text"))
Loading