add tests for ShopController

This commit is contained in:
Denis Savosin
2024-09-25 12:44:40 +07:00
parent 208b2a604b
commit 9b975b0aeb
8 changed files with 72 additions and 29 deletions

View File

@@ -14,11 +14,9 @@ import org.springframework.web.bind.annotation.RestController
class ShopController (
@field:Autowired private val shopProvider: ShopProvider,
) {
@GetMapping(value = ["/shop/common-info"], produces = ["application/json"] )
@GetMapping(value = ["/shop/common-info"], produces = ["application/json"])
@ResponseBody
fun commonInfo(response: HttpServletResponse): String {
response.contentType = "application/json"
val shop = shopProvider.getRandomShop()
if (shop == null) {

View File

@@ -19,7 +19,7 @@ fun renderProductTable(): String {
}
}
val products = getProducts()
val products = getInnerProducts()
for ((i, product) in products.withIndex()) {
tr {
td (color = getCellColor(0, i+1)) {

View File

@@ -0,0 +1,11 @@
package com.example.demo.provider.html
data class InnerProduct(val description: String, val price: Double, val popularity: Int)
fun getInnerProducts(): Set<InnerProduct> {
return setOf(
InnerProduct("one", 12.0, 12),
InnerProduct("two", 13.0, 20),
InnerProduct("three", 14.0, 50)
)
}

View File

@@ -1,11 +0,0 @@
package com.example.demo.provider.html
data class Product(val description: String, val price: Double, val popularity: Int)
fun getProducts(): Set<Product> {
return setOf(
Product("one", 12.0, 12),
Product("two", 13.0, 20),
Product("three", 14.0, 50)
)
}