Skip to content

Commit

Permalink
Merge pull request #39 from digitalservicebund/sonarcube-issues
Browse files Browse the repository at this point in the history
only log egvp client exceptions in callback controller
  • Loading branch information
ekl176 authored Jan 15, 2025
2 parents 8295565 + a277d42 commit 42c263d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
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

0 comments on commit 42c263d

Please sign in to comment.