Skip to content

Commit

Permalink
Add unit tests for subscriber service
Browse files Browse the repository at this point in the history
  • Loading branch information
zechmeister committed Nov 6, 2024
1 parent 3788d8b commit 3e455e4
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 3e455e4

Please sign in to comment.