Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only log egvp client exceptions in callback controller #39

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import de.bund.digitalservice.a2j.service.subscriber.SubscriberService;
import dev.fitko.fitconnect.api.domain.model.callback.NewSubmissionsCallback;
import dev.fitko.fitconnect.api.domain.model.submission.SubmissionForPickup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -17,13 +19,15 @@ public SubscriberController(SubscriberService service) {
this.service = service;
}

private static final Logger logger = LoggerFactory.getLogger(SubscriberController.class);

@PostMapping("callbacks/fit-connect")
public void newSubmission(@RequestBody NewSubmissionsCallback callback) {
for (SubmissionForPickup submissionForPickup : callback.getSubmissions()) {
try {
service.pickUpSubmission(submissionForPickup);
} catch (EgvpClientException e) {
throw new RuntimeException(e.getMessage());
logger.error("unable to propagate submission {}", submissionForPickup.getSubmissionId(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Component
public class MessagesInTransitInMemoryRepository implements MessagesInTransitRepository {
public Set<MessageInTransit> messages = new HashSet<>();
private final Set<MessageInTransit> messages = new HashSet<>();

public Set<MessageInTransit> getAll() {
return messages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void retrieveDeliveryStatus() {
try {
MessageDeliveryStatusResponse response =
this.client.checkMessageStatus(m.userId(), m.customId());

if (response.delivered()) {
deliveredMessages.add(m);
// TODO send confirmation file to user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private <T> T invoke(Operation<T> operation) throws EgvpClientException {
serverErrorException.getStatusCode().toString(), serverErrorException);
} catch (RestClientException ex) {

throw new EgvpClientException(ex.getMessage().toString(), ex);
throw new EgvpClientException(ex.getMessage(), ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// only extend with SpringExtension to avoid loading the whole Application context
@ExtendWith(SpringExtension.class)
@Tag("integration")
public class EgvpClientIntegrationTest {
class EgvpClientIntegrationTest {

private EgvpClient client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void shouldSecureCallbackWithAuthorization() throws EgvpClientException {
}

@Test
void shouldSecureCallbackWithoutAuthorization() throws EgvpClientException {
void shouldSecureCallbackWithoutAuthorization() {
when(senderClient.validateCallback(any(), any(), any(), any()))
.thenReturn(ValidationResult.error("invalid callback"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ExtendWith(SpringExtension.class)
public class EgvpOutboxServiceTest {
class EgvpOutboxServiceTest {

@MockBean private EgvpClient egvpClient;

@Test
public void sendMessageTest() throws EgvpClientException {
void sendMessageTest() throws EgvpClientException {
MessagesInTransitRepository repo = new MessagesInTransitInMemoryRepository();
EgvpOutboxService service = new EgvpOutboxService(egvpClient, repo);

Expand All @@ -40,7 +40,7 @@ public void sendMessageTest() throws EgvpClientException {
}

@Test
public void retrieveDeliveredMessage() throws EgvpClientException {
void retrieveDeliveredMessage() throws EgvpClientException {
MessagesInTransitRepository repo = new MessagesInTransitInMemoryRepository();
repo.add(new MessageInTransit("userId", "customId", "mailboxId"));

Expand All @@ -54,7 +54,7 @@ public void retrieveDeliveredMessage() throws EgvpClientException {
}

@Test
public void keepPendingMessagesInTransit() throws EgvpClientException {
void keepPendingMessagesInTransit() throws EgvpClientException {
MessagesInTransitRepository repo = new MessagesInTransitInMemoryRepository();
MessageInTransit msg = new MessageInTransit("userId", "customId", "mailboxId");
repo.add(msg);
Expand All @@ -68,7 +68,7 @@ public void keepPendingMessagesInTransit() throws EgvpClientException {
}

@Test
public void deleteInTransitMessagesOnFailure() throws EgvpClientException {
void deleteInTransitMessagesOnFailure() throws EgvpClientException {
MessagesInTransitRepository repo = new MessagesInTransitInMemoryRepository();
MessageInTransit msg = new MessageInTransit("userId", "customId", "mailboxId");
repo.add(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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.io.IOException;
import java.util.UUID;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -35,7 +34,7 @@ void setup() {
}

@Test
void testPickUpSubmission() throws IOException, EgvpClientException {
void testPickUpSubmission() throws EgvpClientException {
when(client.requestSubmission(submissionForPickup)).thenReturn(receivedSubmission);
UUID caseId = UUID.randomUUID();
when(receivedSubmission.getSubmissionId()).thenReturn(UUID.randomUUID());
Expand Down
Loading