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
Branches
Tags
1 merge request!13Ozg 4095 abrufen stage test
Pipeline #1624 passed
...@@ -2,12 +2,9 @@ package de.ozgcloud.nachrichten.postfach.osiv2; ...@@ -2,12 +2,9 @@ package de.ozgcloud.nachrichten.postfach.osiv2;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
...@@ -21,17 +18,16 @@ import de.ozgcloud.nachrichten.postfach.PostfachNachricht; ...@@ -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.DummyStringBasedIdentifier;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachAddressTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachAddressTestFactory;
import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory; import de.ozgcloud.nachrichten.postfach.osiv2.factory.PostfachNachrichtTestFactory;
import lombok.SneakyThrows;
@SpringBootTest(classes = TestApplication.class) @SpringBootTest(classes = TestApplication.class)
@ActiveProfiles({ "stage", "itcase" }) @ActiveProfiles({ "stage", "itcase" })
@EnabledIfEnvironmentVariable(named = "SH_STAGE_CLIENT_SECRET", matches = ".+") @EnabledIfEnvironmentVariable(named = "SH_STAGE_CLIENT_SECRET", matches = ".+")
public class OsiPostfachRemoteServiceRemoteITCase { class OsiPostfachRemoteServiceRemoteITCase {
@Autowired @Autowired
private OsiPostfachRemoteService osiPostfachRemoteService; private OsiPostfachRemoteService osiPostfachRemoteService;
private List<String> initialMessageIds;
@DynamicPropertySource @DynamicPropertySource
static void dynamicProperties(DynamicPropertyRegistry registry) { static void dynamicProperties(DynamicPropertyRegistry registry) {
registry.add( registry.add(
...@@ -56,25 +52,6 @@ public class OsiPostfachRemoteServiceRemoteITCase { ...@@ -56,25 +52,6 @@ public class OsiPostfachRemoteServiceRemoteITCase {
throw new IllegalArgumentException("Proxy host and port not found in '%s'".formatted(text)); 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() { private PostfachNachricht createNachricht() {
return PostfachNachrichtTestFactory.createBuilder() return PostfachNachrichtTestFactory.createBuilder()
.replyOption(PostfachNachricht.ReplyOption.POSSIBLE) .replyOption(PostfachNachricht.ReplyOption.POSSIBLE)
...@@ -86,26 +63,31 @@ public class OsiPostfachRemoteServiceRemoteITCase { ...@@ -86,26 +63,31 @@ public class OsiPostfachRemoteServiceRemoteITCase {
.build(); .build();
} }
@DisplayName("should send and receive message without attachment") @DisplayName("should not fail sending message")
@Test @Test
void shouldSendAndReceiveMessage() { @SneakyThrows
void shouldNotFailSendingMessage() {
var nachricht = createNachricht(); var nachricht = createNachricht();
osiPostfachRemoteService.sendMessage(nachricht); assertThatCode(() -> osiPostfachRemoteService.sendMessage(nachricht))
.doesNotThrowAnyException();
}
@DisplayName("should receive messages")
@Test
void shouldReceiveMessages() {
var messages = osiPostfachRemoteService.getAllMessages().toList(); var messages = osiPostfachRemoteService.getAllMessages().toList();
assertThat(messages).isNotEmpty();
var newMessages = messages.stream() assertThat(messages)
.filter(m -> !initialMessageIds.contains(m.getMessageId())) .isNotEmpty()
.toList(); .extracting(PostfachNachricht::getMessageId)
assertThat(newMessages).hasSize(1); .doesNotContainNull();
var newMessage = newMessages.getFirst(); }
assertThat(newMessage.getSubject()).isEqualTo(nachricht.getSubject());
assertThat(newMessage.getMailBody()).isEqualTo(nachricht.getMailBody());
assertThat(newMessage.getPostfachAddress())
.isEqualTo(nachricht.getPostfachAddress());
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