mirror of
https://github.com/Dannecron/spring-boot-demo.git
synced 2025-12-26 08:42:33 +03:00
db dto = entity
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.github.dannecron.demo.db.repository
|
||||
|
||||
import com.github.dannecron.demo.db.BaseDbTest
|
||||
import com.github.dannecron.demo.db.entity.City
|
||||
import com.github.dannecron.demo.db.entity.CityEntity
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.test.context.jdbc.Sql
|
||||
@@ -12,13 +12,13 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@ContextConfiguration(classes = [CityRepository::class])
|
||||
class CityRepositoryTest : BaseDbTest() {
|
||||
class CityEntityRepositoryTest : BaseDbTest() {
|
||||
|
||||
@Autowired
|
||||
private lateinit var cityRepository: CityRepository
|
||||
|
||||
private val cityGuid = UUID.fromString("21a1a3a8-621a-40f7-b64f-7e118aa241b9")
|
||||
private val city = City(
|
||||
private val cityEntity = CityEntity(
|
||||
id = 1000,
|
||||
guid = cityGuid,
|
||||
name = "Tokyo",
|
||||
@@ -31,7 +31,7 @@ class CityRepositoryTest : BaseDbTest() {
|
||||
@Sql(scripts = ["/sql/insert_city.sql"])
|
||||
fun findByGuid() {
|
||||
val result = cityRepository.findByGuid(cityGuid)
|
||||
assertEquals(city, result)
|
||||
assertEquals(cityEntity, result)
|
||||
|
||||
val emptyResult = cityRepository.findByGuid(UUID.randomUUID())
|
||||
assertNull(emptyResult)
|
||||
@@ -41,7 +41,7 @@ class CityRepositoryTest : BaseDbTest() {
|
||||
@Sql(scripts = ["/sql/insert_city.sql"])
|
||||
fun softDelete() {
|
||||
val deletedAt = OffsetDateTime.parse("2025-01-02T12:10:05+00:00")
|
||||
val expectedCity = city.copy(deletedAt = deletedAt)
|
||||
val expectedCity = cityEntity.copy(deletedAt = deletedAt)
|
||||
|
||||
val result = cityRepository.softDelete(cityGuid, deletedAt)
|
||||
assertEquals(expectedCity, result)
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.dannecron.demo.db.repository
|
||||
|
||||
import com.github.dannecron.demo.db.BaseDbTest
|
||||
import com.github.dannecron.demo.db.entity.Customer
|
||||
import com.github.dannecron.demo.db.entity.CustomerEntity
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.test.context.jdbc.Sql
|
||||
@@ -12,13 +12,13 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@ContextConfiguration(classes = [CustomerRepository::class])
|
||||
class CustomerRepositoryTest : BaseDbTest() {
|
||||
class CustomerEntityRepositoryTest : BaseDbTest() {
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerRepository: CustomerRepository
|
||||
|
||||
private val customerGuid = UUID.fromString("823c50de-4c81-49bd-a69a-2d52be42b728")
|
||||
private val customer = Customer(
|
||||
private val customerEntity = CustomerEntity(
|
||||
id = 1000,
|
||||
guid = customerGuid,
|
||||
name = "Customer",
|
||||
@@ -31,7 +31,7 @@ class CustomerRepositoryTest : BaseDbTest() {
|
||||
@Sql(scripts = ["/sql/insert_city.sql", "/sql/insert_customer.sql"])
|
||||
fun findByGuid() {
|
||||
val result = customerRepository.findByGuid(customerGuid)
|
||||
assertEquals(customer, result)
|
||||
assertEquals(customerEntity, result)
|
||||
|
||||
val emptyResult = customerRepository.findByGuid(UUID.randomUUID())
|
||||
assertNull(emptyResult)
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.dannecron.demo.db.repository
|
||||
|
||||
import com.github.dannecron.demo.db.BaseDbTest
|
||||
import com.github.dannecron.demo.db.entity.order.OrderProduct
|
||||
import com.github.dannecron.demo.db.entity.order.OrderProductEntity
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.test.context.jdbc.Sql
|
||||
@@ -11,13 +11,13 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ContextConfiguration(classes = [OrderProductRepository::class])
|
||||
class OrderProductRepositoryTest : BaseDbTest() {
|
||||
class OrderEntityProductEntityRepositoryTest : BaseDbTest() {
|
||||
|
||||
@Autowired
|
||||
private lateinit var orderProductRepository: OrderProductRepository
|
||||
|
||||
private val orderId = 1000L
|
||||
private val orderProduct = OrderProduct(
|
||||
private val orderProductEntity = OrderProductEntity(
|
||||
guid = UUID.fromString("930f54e2-c60d-448e-83b1-0d259ff2c2d3"),
|
||||
orderId = orderId,
|
||||
productId = 1000,
|
||||
@@ -38,6 +38,6 @@ class OrderProductRepositoryTest : BaseDbTest() {
|
||||
fun findByOrderId() {
|
||||
val result = orderProductRepository.findByOrderId(orderId)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(orderProduct, result[0])
|
||||
assertEquals(orderProductEntity, result[0])
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.dannecron.demo.db.repository
|
||||
|
||||
import com.github.dannecron.demo.db.BaseDbTest
|
||||
import com.github.dannecron.demo.db.entity.order.Order
|
||||
import com.github.dannecron.demo.db.entity.order.OrderEntity
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.test.context.jdbc.Sql
|
||||
@@ -11,14 +11,14 @@ import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@ContextConfiguration(classes = [OrderRepository::class])
|
||||
class OrderRepositoryTest : BaseDbTest() {
|
||||
class OrderEntityRepositoryTest : BaseDbTest() {
|
||||
|
||||
@Autowired
|
||||
private lateinit var orderRepository: OrderRepository
|
||||
|
||||
private val orderGuid = UUID.fromString("2c960a08-7187-4e91-9ef3-275c91b1342c")
|
||||
private val customerId = 1000L
|
||||
private val order = Order(
|
||||
private val orderEntity = OrderEntity(
|
||||
id = 1000,
|
||||
guid = orderGuid,
|
||||
customerId = customerId,
|
||||
@@ -38,6 +38,6 @@ class OrderRepositoryTest : BaseDbTest() {
|
||||
fun findByGuid() {
|
||||
val result = orderRepository.findByCustomerId(customerId)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(order, result[0])
|
||||
assertEquals(orderEntity, result[0])
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.github.dannecron.demo.db.repository
|
||||
|
||||
import com.github.dannecron.demo.db.BaseDbTest
|
||||
import com.github.dannecron.demo.db.entity.Product
|
||||
import com.github.dannecron.demo.db.entity.ProductEntity
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.test.context.jdbc.Sql
|
||||
@@ -12,13 +12,13 @@ import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@ContextConfiguration(classes = [ProductRepository::class])
|
||||
class ProductRepositoryTest : BaseDbTest() {
|
||||
class ProductEntityRepositoryTest : BaseDbTest() {
|
||||
|
||||
@Autowired
|
||||
private lateinit var productRepository: ProductRepository
|
||||
|
||||
private val productGuid = UUID.fromString("1fb5c7e4-8ce2-43b8-8ca7-1089b04959b9")
|
||||
private val product = Product(
|
||||
private val productEntity = ProductEntity(
|
||||
id = 1000,
|
||||
guid = productGuid,
|
||||
name = "product",
|
||||
@@ -33,7 +33,7 @@ class ProductRepositoryTest : BaseDbTest() {
|
||||
@Sql(scripts = ["/sql/insert_product.sql"])
|
||||
fun findByGuid() {
|
||||
val result = productRepository.findByGuid(productGuid)
|
||||
assertEquals(product, result)
|
||||
assertEquals(productEntity, result)
|
||||
|
||||
val emptyResult = productRepository.findByGuid(UUID.randomUUID())
|
||||
assertNull(emptyResult)
|
||||
Reference in New Issue
Block a user