add openapi auto generation

some responses refactoring
This commit is contained in:
Denis Savosin
2024-10-03 12:41:33 +07:00
parent e89c1d99fb
commit 9ded10a9ac
11 changed files with 80 additions and 29 deletions

View File

@@ -83,8 +83,10 @@ class ProductControllerTest(@Autowired val mockMvc: MockMvc): BaseUnitTest() {
@Test
fun getProducts_success() {
val now = OffsetDateTime.now()
val pageRequest = PageRequest.of(1, 2, Sort.by(Sort.Direction.DESC, "createdAt"))
whenever(productService.findAll(
PageRequest.of(1, 2, Sort.by(Sort.Direction.DESC, "createdAt")),
pageRequest,
)) doReturn PageImpl(listOf(Product(
id = 12,
guid = UUID.randomUUID(),
@@ -96,7 +98,7 @@ class ProductControllerTest(@Autowired val mockMvc: MockMvc): BaseUnitTest() {
deletedAt = null,
)))
mockMvc.get("/api/product?page=1&size=2&sort=created_at,desc")
mockMvc.get("/api/product?page=1&size=2&sort=createdAt,desc")
.andExpect { status { status { isOk() } } }
.andExpect { content { contentType(MediaType.APPLICATION_JSON) } }
.andExpect { jsonPath("\$.meta.total") { value(1) } }