Skip to content
Snippets Groups Projects
Commit 5f86dfb1 authored by Krzysztof Witukiewicz's avatar Krzysztof Witukiewicz
Browse files

OZG-6706 OZG-7499 Test response of BescheidController.getAttachments()

parent ef5924ac
Branches
Tags
1 merge request!7Ozg 6706 anbindung bescheid schnittstelle
...@@ -28,6 +28,7 @@ import static org.mockito.Mockito.*; ...@@ -28,6 +28,7 @@ import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
...@@ -37,12 +38,14 @@ import org.junit.jupiter.api.Test; ...@@ -37,12 +38,14 @@ import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Spy; import org.mockito.Spy;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel; import org.springframework.hateoas.EntityModel;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import de.ozgcloud.alfa.common.binaryfile.BinaryFileController; import de.ozgcloud.alfa.common.binaryfile.BinaryFileController;
import de.ozgcloud.alfa.common.file.OzgFileTestFactory;
import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory; import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -127,6 +130,7 @@ class BescheidControllerTest { ...@@ -127,6 +130,7 @@ class BescheidControllerTest {
@BeforeEach @BeforeEach
void mock() { void mock() {
when(bescheidService.getBescheid(any())).thenReturn(BescheidTestFactory.create()); when(bescheidService.getBescheid(any())).thenReturn(BescheidTestFactory.create());
when(binaryFileController.getFiles(any())).thenReturn(CollectionModel.of(List.of(EntityModel.of(OzgFileTestFactory.create()))));
} }
@SneakyThrows @SneakyThrows
...@@ -153,6 +157,30 @@ class BescheidControllerTest { ...@@ -153,6 +157,30 @@ class BescheidControllerTest {
response.andExpect(status().isOk()); response.andExpect(status().isOk());
} }
@SneakyThrows
@Test
void shouldHaveAttachmentName() {
var response = doRequest();
response.andExpect(jsonPath("$.content[0].name").value(OzgFileTestFactory.NAME));
}
@SneakyThrows
@Test
void shouldHaveAttachmentSize() {
var response = doRequest();
response.andExpect(jsonPath("$.content[0].size").value(OzgFileTestFactory.SIZE));
}
@SneakyThrows
@Test
void shouldHaveAttachmentContentType() {
var response = doRequest();
response.andExpect(jsonPath("$.content[0].contentType").value(OzgFileTestFactory.CONTENT_TYPE));
}
@SneakyThrows @SneakyThrows
private ResultActions doRequest() { private ResultActions doRequest() {
return mockMvc.perform( return mockMvc.perform(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment