From 3e455e452e6c85942358d148da68c5d0404500d1 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 6 Nov 2024 13:57:15 +0100 Subject: [PATCH] Add unit tests for subscriber service --- .../FitConnectSubscriberServiceTest.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/test/java/de/bund/digitalservice/a2j/service/subscriber/FitConnectSubscriberServiceTest.java diff --git a/src/test/java/de/bund/digitalservice/a2j/service/subscriber/FitConnectSubscriberServiceTest.java b/src/test/java/de/bund/digitalservice/a2j/service/subscriber/FitConnectSubscriberServiceTest.java new file mode 100644 index 0000000..866d917 --- /dev/null +++ b/src/test/java/de/bund/digitalservice/a2j/service/subscriber/FitConnectSubscriberServiceTest.java @@ -0,0 +1,42 @@ +package de.bund.digitalservice.a2j.service.subscriber; + +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import dev.fitko.fitconnect.api.domain.model.submission.SubmissionForPickup; +import dev.fitko.fitconnect.api.domain.subscriber.ReceivedSubmission; +import dev.fitko.fitconnect.client.SubscriberClient; +import java.util.List; +import java.util.UUID; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +class FitConnectSubscriberServiceTest { + private SubscriberService service; + + @MockBean SubscriberClient client; + + @Mock ReceivedSubmission receivedSubmission; + @Mock SubmissionForPickup submissionForPickup; + + @BeforeEach + void setup() { + this.service = new FitConnectSubscriberService(client); + } + + @Test + void testPickUpSubmission() { + when(client.requestSubmission(submissionForPickup)).thenReturn(receivedSubmission); + when(receivedSubmission.getSubmissionId()).thenReturn(UUID.randomUUID()); + + service.pickUpSubmission(submissionForPickup); + + verify(client).requestSubmission(submissionForPickup); + verify(receivedSubmission).acceptSubmission(); + } +}