Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fit-connect/sdk-java
1 result
Show changes
......@@ -3,21 +3,34 @@ package dev.fitko.fitconnect.integrationtests;
import dev.fitko.fitconnect.api.config.ApplicationConfig;
import dev.fitko.fitconnect.api.domain.model.submission.SubmissionForPickup;
import dev.fitko.fitconnect.client.factory.ClientFactory;
import dev.fitko.fitconnect.client.sender.model.Attachment;
import dev.fitko.fitconnect.client.sender.model.SendableSubmission;
import dev.fitko.fitconnect.client.subscriber.ReceivedSubmission;
import dev.fitko.fitconnect.integrationtests.condition.EnableIfEnvironmentVariablesAreSet;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@EnableIfEnvironmentVariablesAreSet
public class SubscriberClientIT extends IntegrationTestBase {
@BeforeEach
public void cleanup(){
cleanupTestSubmissions();
}
@Test
void testListSubmissionsForDestination() {
......@@ -46,8 +59,8 @@ public class SubscriberClientIT extends IntegrationTestBase {
final var sentSubmissionOne = senderClient.send(submissionOne);
final var sentSubmissionTwo = senderClient.send(submissionTwo);
Assertions.assertNotNull(sentSubmissionOne);
Assertions.assertNotNull(sentSubmissionTwo);
assertNotNull(sentSubmissionOne);
assertNotNull(sentSubmissionTwo);
// When
final Set<SubmissionForPickup> submissions = subscriberClient.getAvailableSubmissionsForDestination(destinationId);
......@@ -57,10 +70,44 @@ public class SubscriberClientIT extends IntegrationTestBase {
final List<UUID> submissionIds = submissions.stream().map(SubmissionForPickup::getSubmissionId).collect(Collectors.toList());
MatcherAssert.assertThat(submissionIds, Matchers.hasItems(sentSubmissionOne.getSubmissionId(), sentSubmissionTwo.getSubmissionId()));
assertThat(submissionIds, Matchers.hasItems(sentSubmissionOne.getSubmissionId(), sentSubmissionTwo.getSubmissionId()));
// remove by confirming
subscriberClient.requestSubmission(sentSubmissionOne.getSubmissionId()).acceptSubmission();
subscriberClient.requestSubmission(sentSubmissionTwo.getSubmissionId()).acceptSubmission();
}
@Test
void testReceiveSingleSubmission() {
// Given
final ApplicationConfig config = getConfigWithCredentialsFromEnvironment("TESTING", true);
final var senderClient = ClientFactory.getSenderClient(config);
final var subscriberClient = ClientFactory.getSubscriberClient(config);
final UUID destinationId = UUID.fromString(System.getenv("TEST_DESTINATION_ID"));
final String leikaKey = "urn:de:fim:leika:leistung:99400048079000";
final String serviceName = "Test Service";
final var submission = SendableSubmission.Builder()
.setDestination(destinationId)
.setServiceType(leikaKey, serviceName)
.setJsonData("{ \"data\": \"Beispiel Fachdaten 1\" }")
.addAttachment(Attachment.fromString("foo", "plain/text"))
.build();
final var sentSubmission = senderClient.send(submission);
assertNotNull(sentSubmission);
// When
final ReceivedSubmission receivedSubmission = subscriberClient.requestSubmission(sentSubmission.getSubmissionId());
// Then
assertNotNull(receivedSubmission);
assertThat(receivedSubmission.getAttachments(), hasSize(1));
assertThat(receivedSubmission.getAttachments().get(0).getDataAString(StandardCharsets.UTF_8), is("foo"));
assertThat(receivedSubmission.getDataAsString(), is("{ \"data\": \"Beispiel Fachdaten 1\" }"));
}
}
......@@ -66,10 +66,10 @@
<jackson-annotations.version>2.14.2</jackson-annotations.version>
<lombock.version>1.18.26</lombock.version>
<logback.version>1.4.6</logback.version>
<slf4j.version>2.0.6</slf4j.version>
<slf4j.version>2.0.7</slf4j.version>
<jcommander.version>1.82</jcommander.version>
<apache-tika.version>2.7.0</apache-tika.version>
<spring-web.version>5.3.25</spring-web.version>
<spring-web.version>5.3.26</spring-web.version>
<snakeyaml.version>2.0</snakeyaml.version>
<open-csv.version>5.7.1</open-csv.version>
<json-schema-validator.version>1.0.78</json-schema-validator.version>
......