mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
fix tests caused by streaming changes (#6137)
This commit is contained in:
+9
-7
@@ -1,9 +1,9 @@
|
|||||||
package stirling.software.SPDF.model.api.converters;
|
package stirling.software.SPDF.model.api.converters;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.mock.web.MockMultipartFile;
|
import org.springframework.mock.web.MockMultipartFile;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
import org.springframework.test.web.servlet.MvcResult;
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
@@ -70,14 +71,15 @@ class ConvertPDFToMarkdownTest {
|
|||||||
"application/pdf",
|
"application/pdf",
|
||||||
new byte[] {1, 2, 3});
|
new byte[] {1, 2, 3});
|
||||||
|
|
||||||
mvc.perform(multipart("/api/v1/convert/pdf/markdown").file(file))
|
MvcResult asyncResult =
|
||||||
|
mvc.perform(multipart("/api/v1/convert/pdf/markdown").file(file))
|
||||||
|
.andExpect(request().asyncStarted())
|
||||||
|
.andReturn();
|
||||||
|
|
||||||
|
mvc.perform(asyncDispatch(asyncResult))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type", "text/markdown"))
|
.andExpect(header().string("Content-Type", "text/markdown"))
|
||||||
.andExpect(
|
.andExpect(content().bytes(md));
|
||||||
result -> {
|
|
||||||
byte[] actual = result.getResponse().getContentAsByteArray();
|
|
||||||
assertArrayEquals(md, actual);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Verify that exactly one instance was created
|
// Verify that exactly one instance was created
|
||||||
assert construction.constructed().size() == 1;
|
assert construction.constructed().size() == 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user