Skip to content
Snippets Groups Projects
Commit bd5d1471 authored by Jörg Bolay's avatar Jörg Bolay
Browse files

fix sonarqube findings

parent a7e292cf
Branches
Tags
1 merge request!6OZG-4095 Testcase deleteMessage implementiert
package de.ozgcloud.nachrichten.postfach.osiv2.transfer;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
......@@ -28,22 +26,14 @@ public record PostfachApiFacadeService(
}
public Stream<PostfachNachricht> receiveMessages() {
// TODO fetch message by guid and map to PostfachNachricht
var response = messageExchangeApi.receiveMessages(100, 0)
.block();
LOG.info("receive-message-guids: {}", String.join(", ",
response.getMessages().stream().map(message -> message.getGuid().toString()).toList()));
var response = messageExchangeApi.receiveMessages(100, 0).block();
var stream = response.getMessages().stream()
.map(message -> fetchMessageByGuid(message));
return stream;
return response.getMessages().stream().map(this::fetchMessageByGuid);
}
PostfachNachricht fetchMessageByGuid(final MessageExchangeReceiveMessage message) {
var messageReply = messageExchangeApi.getMessage(message.getGuid()).block();
var postfachNachricht = responseMapper.toPostfachNachricht(messageReply);
return PostfachNachricht.builder().build();
return responseMapper.toPostfachNachricht(messageReply);
}
}
package de.ozgcloud.nachrichten.postfach.osiv2.transfer;
import static de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachAddressTestFactory.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.UUID;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
......@@ -107,6 +104,28 @@ class PostfachApiFacadeServiceTest {
verify(messageExchangeApi).getMessage(any());
}
@Test
void shouldCallResponseMapper(){
var replyMono = Mono.just(replyMessage);
when(messageExchangeApi.getMessage(any())).thenReturn(replyMono);
when(responseMapper.toPostfachNachricht(any())).thenReturn(PostfachNachrichtTestFactory.create());
postfachApiFacadeService.fetchMessageByGuid(receiveMessage);
verify(responseMapper).toPostfachNachricht(any());
}
@Test
void shouldReturnPostfachNachricht(){
var replyMono = Mono.just(replyMessage);
when(messageExchangeApi.getMessage(any())).thenReturn(replyMono);
when(responseMapper.toPostfachNachricht(any())).thenReturn(PostfachNachrichtTestFactory.create());
var postfachNachricht = postfachApiFacadeService.fetchMessageByGuid(receiveMessage);
assertThat(postfachNachricht).isInstanceOf(PostfachNachricht.class);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment