Skip to content
Snippets Groups Projects
Commit c2ba658d authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-4095 stage: Keep basic test

parent 16045a5a
No related branches found
No related tags found
1 merge request!13Ozg 4095 abrufen stage test
Pipeline #1624 passed
......@@ -2,12 +2,9 @@ package de.ozgcloud.nachrichten.postfach.osiv2;
import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
......@@ -21,17 +18,16 @@ import de.ozgcloud.nachrichten.postfach.PostfachNachricht;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.DummyStringBasedIdentifier;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachAddressTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory;
import lombok.SneakyThrows;
@SpringBootTest(classes = TestApplication.class)
@ActiveProfiles({ "stage", "itcase" })
@EnabledIfEnvironmentVariable(named = "SH_STAGE_CLIENT_SECRET", matches = ".+")
public class OsiPostfachRemoteServiceRemoteITCase {
class OsiPostfachRemoteServiceRemoteITCase {
@Autowired
private OsiPostfachRemoteService osiPostfachRemoteService;
private List<String> initialMessageIds;
@DynamicPropertySource
static void dynamicProperties(DynamicPropertyRegistry registry) {
registry.add(
......@@ -56,25 +52,6 @@ public class OsiPostfachRemoteServiceRemoteITCase {
throw new IllegalArgumentException("Proxy host and port not found in '%s'".formatted(text));
}
List<String> fetchPostfachMessagesIds() {
return osiPostfachRemoteService.getAllMessages()
.map(PostfachNachricht::getMessageId)
.toList();
}
@BeforeEach
void setup() {
initialMessageIds = fetchPostfachMessagesIds();
assertThat(initialMessageIds).doesNotContainNull();
}
@AfterEach
void validateMessagesBackAtOriginalState() {
var currentGuids = fetchPostfachMessagesIds();
assertThat(currentGuids).containsExactlyElementsOf(initialMessageIds);
}
private PostfachNachricht createNachricht() {
return PostfachNachrichtTestFactory.createBuilder()
.replyOption(PostfachNachricht.ReplyOption.POSSIBLE)
......@@ -86,26 +63,31 @@ public class OsiPostfachRemoteServiceRemoteITCase {
.build();
}
@DisplayName("should send and receive message without attachment")
@DisplayName("should not fail sending message")
@Test
void shouldSendAndReceiveMessage() {
@SneakyThrows
void shouldNotFailSendingMessage() {
var nachricht = createNachricht();
osiPostfachRemoteService.sendMessage(nachricht);
assertThatCode(() -> osiPostfachRemoteService.sendMessage(nachricht))
.doesNotThrowAnyException();
}
@DisplayName("should receive messages")
@Test
void shouldReceiveMessages() {
var messages = osiPostfachRemoteService.getAllMessages().toList();
assertThat(messages).isNotEmpty();
var newMessages = messages.stream()
.filter(m -> !initialMessageIds.contains(m.getMessageId()))
.toList();
assertThat(newMessages).hasSize(1);
var newMessage = newMessages.getFirst();
assertThat(newMessage.getSubject()).isEqualTo(nachricht.getSubject());
assertThat(newMessage.getMailBody()).isEqualTo(nachricht.getMailBody());
assertThat(newMessage.getPostfachAddress())
.isEqualTo(nachricht.getPostfachAddress());
assertThat(messages)
.isNotEmpty()
.extracting(PostfachNachricht::getMessageId)
.doesNotContainNull();
}
osiPostfachRemoteService.deleteMessage(newMessage.getMessageId());
@DisplayName("should delete message")
@Test
void shouldDeleteMessage() {
assertThatCode(() -> osiPostfachRemoteService.deleteMessage("5dd65c1e-bd41-4c3d-bf98-be769ca341dc"))
.doesNotThrowAnyException();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment