Skip to content
Snippets Groups Projects
Commit ef2fd3b3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3371 improve test

parent fea71a9e
Branches
Tags
No related merge requests found
......@@ -33,6 +33,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
import java.util.stream.Collectors;
import org.assertj.core.api.InstanceOfAssertFactories;
import org.assertj.core.util.Arrays;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
......@@ -43,6 +44,7 @@ import org.mockito.Spy;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.client.ExpectedCount;
import org.springframework.test.web.client.MockRestServiceServer;
......@@ -57,6 +59,7 @@ import de.itvsh.ozg.mail.postfach.PostfachBadRequestException;
import de.itvsh.ozg.mail.postfach.PostfachNachricht;
import de.itvsh.ozg.mail.postfach.PostfachNachrichtTestFactory;
import de.itvsh.ozg.mail.postfach.PostfachServerProcessException;
import lombok.val;
public class OsiPostfachRemoteServiceTest {
......@@ -144,11 +147,15 @@ public class OsiPostfachRemoteServiceTest {
@Test
void shouldHaveAttachment() {
when(mapper.toPostfachNachricht(any())).thenReturn(PostfachNachrichtTestFactory.create());
val messages = Arrays.array(MessageTestFactory.create());
doReturn(ResponseEntity.ok().body(messages)).when(restTemplate).exchange(TEST_URL, HttpMethod.GET, null, Message[].class);
when(mapper.toPostfachNachricht(messages[0])).thenReturn(PostfachNachrichtTestFactory.create());
var messages = service.getAllMessages();
var postfachNachrichten = service.getAllMessages();
assertThat(messages).hasSize(1).first().extracting(PostfachNachricht::getAttachments, InstanceOfAssertFactories.LIST).hasSize(1)
assertThat(postfachNachrichten).hasSize(1).first()
.extracting(PostfachNachricht::getAttachments, InstanceOfAssertFactories.LIST)
.hasSize(1)
.usingRecursiveComparison().isEqualTo(PostfachNachrichtTestFactory.ATTACHMENTS);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment