diff --git a/src/main/kotlin/com/example/demo/config/AppConfig.kt b/src/main/kotlin/com/example/demo/config/AppConfig.kt index 560b86e..ae013fa 100644 --- a/src/main/kotlin/com/example/demo/config/AppConfig.kt +++ b/src/main/kotlin/com/example/demo/config/AppConfig.kt @@ -1,13 +1,13 @@ package com.example.demo.config -import com.example.demo.provider.CityRepository -import com.example.demo.provider.MockedShopProvider -import com.example.demo.provider.ProductRepository -import com.example.demo.provider.ShopProvider -import com.example.demo.services.CityService -import com.example.demo.services.CityServiceImpl -import com.example.demo.services.ProductService -import com.example.demo.services.ProductServiceImpl +import com.example.demo.providers.CityRepository +import com.example.demo.providers.MockedShopProvider +import com.example.demo.providers.ProductRepository +import com.example.demo.providers.ShopProvider +import com.example.demo.services.database.city.CityService +import com.example.demo.services.database.city.CityServiceImpl +import com.example.demo.services.database.product.ProductService +import com.example.demo.services.database.product.ProductServiceImpl import com.example.demo.services.kafka.Producer import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value diff --git a/src/main/kotlin/com/example/demo/http/controllers/GreetingController.kt b/src/main/kotlin/com/example/demo/http/controllers/GreetingController.kt index 77eb131..ea265e4 100644 --- a/src/main/kotlin/com/example/demo/http/controllers/GreetingController.kt +++ b/src/main/kotlin/com/example/demo/http/controllers/GreetingController.kt @@ -1,6 +1,6 @@ package com.example.demo.http.controllers -import com.example.demo.provider.html.renderProductTable +import com.example.demo.providers.html.renderProductTable import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.ResponseBody import org.springframework.web.bind.annotation.RestController diff --git a/src/main/kotlin/com/example/demo/http/controllers/ProductController.kt b/src/main/kotlin/com/example/demo/http/controllers/ProductController.kt index c50fa58..f6becf8 100644 --- a/src/main/kotlin/com/example/demo/http/controllers/ProductController.kt +++ b/src/main/kotlin/com/example/demo/http/controllers/ProductController.kt @@ -4,7 +4,9 @@ import com.example.demo.http.exceptions.NotFoundException import com.example.demo.http.exceptions.UnprocessableException import com.example.demo.http.requests.CreateProductRequest import com.example.demo.http.responses.makeOkResponse -import com.example.demo.services.ProductService +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.product.ProductService +import com.example.demo.services.database.product.exceptions.ProductNotFoundException import com.example.demo.services.kafka.exceptions.InvalidArgumentException import jakarta.validation.Valid import org.springframework.http.HttpStatus @@ -65,7 +67,13 @@ class ProductController( fun deleteProduct( @PathVariable guid: UUID, ): ResponseEntity { - productService.delete(guid) + try { + productService.delete(guid) + } catch (notFoundException: ProductNotFoundException) { + throw NotFoundException() + } catch (alreadyDeletedException: AlreadyDeletedException) { + throw UnprocessableException("product already deleted") + } return ResponseEntity(makeOkResponse(), HttpStatus.OK) } diff --git a/src/main/kotlin/com/example/demo/http/controllers/ShopController.kt b/src/main/kotlin/com/example/demo/http/controllers/ShopController.kt index a15d7c2..c10b43d 100644 --- a/src/main/kotlin/com/example/demo/http/controllers/ShopController.kt +++ b/src/main/kotlin/com/example/demo/http/controllers/ShopController.kt @@ -1,7 +1,7 @@ package com.example.demo.http.controllers import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.provider.ShopProvider +import com.example.demo.providers.ShopProvider import jakarta.servlet.http.HttpServletResponse import kotlinx.serialization.json.Json import kotlinx.serialization.json.encodeToJsonElement diff --git a/src/main/kotlin/com/example/demo/provider/html/Center.kt b/src/main/kotlin/com/example/demo/provider/html/Center.kt deleted file mode 100644 index 028824e..0000000 --- a/src/main/kotlin/com/example/demo/provider/html/Center.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.example.demo.provider.html - -class Center: Tag("center") \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/provider/html/TD.kt b/src/main/kotlin/com/example/demo/provider/html/TD.kt deleted file mode 100644 index d355154..0000000 --- a/src/main/kotlin/com/example/demo/provider/html/TD.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.example.demo.provider.html - -class TD: Tag("td") \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/provider/CityRepository.kt b/src/main/kotlin/com/example/demo/providers/CityRepository.kt similarity index 94% rename from src/main/kotlin/com/example/demo/provider/CityRepository.kt rename to src/main/kotlin/com/example/demo/providers/CityRepository.kt index c61afdd..f004a36 100644 --- a/src/main/kotlin/com/example/demo/provider/CityRepository.kt +++ b/src/main/kotlin/com/example/demo/providers/CityRepository.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider +package com.example.demo.providers import com.example.demo.models.City import org.springframework.data.jdbc.repository.query.Query diff --git a/src/main/kotlin/com/example/demo/provider/MockedShopProvider.kt b/src/main/kotlin/com/example/demo/providers/MockedShopProvider.kt similarity index 98% rename from src/main/kotlin/com/example/demo/provider/MockedShopProvider.kt rename to src/main/kotlin/com/example/demo/providers/MockedShopProvider.kt index 191e1d6..d876f80 100644 --- a/src/main/kotlin/com/example/demo/provider/MockedShopProvider.kt +++ b/src/main/kotlin/com/example/demo/providers/MockedShopProvider.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider +package com.example.demo.providers import com.example.demo.models.* import java.time.OffsetDateTime diff --git a/src/main/kotlin/com/example/demo/provider/ProductRepository.kt b/src/main/kotlin/com/example/demo/providers/ProductRepository.kt similarity index 94% rename from src/main/kotlin/com/example/demo/provider/ProductRepository.kt rename to src/main/kotlin/com/example/demo/providers/ProductRepository.kt index 632d135..263200c 100644 --- a/src/main/kotlin/com/example/demo/provider/ProductRepository.kt +++ b/src/main/kotlin/com/example/demo/providers/ProductRepository.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider +package com.example.demo.providers import com.example.demo.models.Product import org.springframework.data.jdbc.repository.query.Query diff --git a/src/main/kotlin/com/example/demo/provider/ShopProvider.kt b/src/main/kotlin/com/example/demo/providers/ShopProvider.kt similarity index 73% rename from src/main/kotlin/com/example/demo/provider/ShopProvider.kt rename to src/main/kotlin/com/example/demo/providers/ShopProvider.kt index bc6aca9..e152c11 100644 --- a/src/main/kotlin/com/example/demo/provider/ShopProvider.kt +++ b/src/main/kotlin/com/example/demo/providers/ShopProvider.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider +package com.example.demo.providers import com.example.demo.models.Shop diff --git a/src/main/kotlin/com/example/demo/provider/html/Attribute.kt b/src/main/kotlin/com/example/demo/providers/html/Attribute.kt similarity index 73% rename from src/main/kotlin/com/example/demo/provider/html/Attribute.kt rename to src/main/kotlin/com/example/demo/providers/html/Attribute.kt index e2d009d..a1a1bbd 100644 --- a/src/main/kotlin/com/example/demo/provider/html/Attribute.kt +++ b/src/main/kotlin/com/example/demo/providers/html/Attribute.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html class Attribute(val name : String, val value : String) { override fun toString() = """$name="$value" """ diff --git a/src/main/kotlin/com/example/demo/providers/html/Center.kt b/src/main/kotlin/com/example/demo/providers/html/Center.kt new file mode 100644 index 0000000..fce6909 --- /dev/null +++ b/src/main/kotlin/com/example/demo/providers/html/Center.kt @@ -0,0 +1,3 @@ +package com.example.demo.providers.html + +class Center: Tag("center") \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/provider/html/Html.kt b/src/main/kotlin/com/example/demo/providers/html/Html.kt similarity index 86% rename from src/main/kotlin/com/example/demo/provider/html/Html.kt rename to src/main/kotlin/com/example/demo/providers/html/Html.kt index 14a1e07..f319a2d 100644 --- a/src/main/kotlin/com/example/demo/provider/html/Html.kt +++ b/src/main/kotlin/com/example/demo/providers/html/Html.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html class Html: Tag("html") diff --git a/src/main/kotlin/com/example/demo/provider/html/HtmlProvider.kt b/src/main/kotlin/com/example/demo/providers/html/HtmlProvider.kt similarity index 96% rename from src/main/kotlin/com/example/demo/provider/html/HtmlProvider.kt rename to src/main/kotlin/com/example/demo/providers/html/HtmlProvider.kt index 9c9b792..deae82d 100644 --- a/src/main/kotlin/com/example/demo/provider/html/HtmlProvider.kt +++ b/src/main/kotlin/com/example/demo/providers/html/HtmlProvider.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html fun getTitleColor() = "#b9c9fe" fun getCellColor(index: Int, row: Int) = if ((index + row) %2 == 0) "#dce4ff" else "#eff2ff" diff --git a/src/main/kotlin/com/example/demo/provider/html/InnerProduct.kt b/src/main/kotlin/com/example/demo/providers/html/InnerProduct.kt similarity index 87% rename from src/main/kotlin/com/example/demo/provider/html/InnerProduct.kt rename to src/main/kotlin/com/example/demo/providers/html/InnerProduct.kt index 6a4f23d..92cbf31 100644 --- a/src/main/kotlin/com/example/demo/provider/html/InnerProduct.kt +++ b/src/main/kotlin/com/example/demo/providers/html/InnerProduct.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html data class InnerProduct(val description: String, val price: Double, val popularity: Int) diff --git a/src/main/kotlin/com/example/demo/providers/html/TD.kt b/src/main/kotlin/com/example/demo/providers/html/TD.kt new file mode 100644 index 0000000..f9a1463 --- /dev/null +++ b/src/main/kotlin/com/example/demo/providers/html/TD.kt @@ -0,0 +1,3 @@ +package com.example.demo.providers.html + +class TD: Tag("td") \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/provider/html/TR.kt b/src/main/kotlin/com/example/demo/providers/html/TR.kt similarity index 81% rename from src/main/kotlin/com/example/demo/provider/html/TR.kt rename to src/main/kotlin/com/example/demo/providers/html/TR.kt index f4f6f79..42bd7d3 100644 --- a/src/main/kotlin/com/example/demo/provider/html/TR.kt +++ b/src/main/kotlin/com/example/demo/providers/html/TR.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html class TR: Tag("tr") diff --git a/src/main/kotlin/com/example/demo/provider/html/Table.kt b/src/main/kotlin/com/example/demo/providers/html/Table.kt similarity index 76% rename from src/main/kotlin/com/example/demo/provider/html/Table.kt rename to src/main/kotlin/com/example/demo/providers/html/Table.kt index 4e400e8..f431ebe 100644 --- a/src/main/kotlin/com/example/demo/provider/html/Table.kt +++ b/src/main/kotlin/com/example/demo/providers/html/Table.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html class Table: Tag("table") diff --git a/src/main/kotlin/com/example/demo/provider/html/Tag.kt b/src/main/kotlin/com/example/demo/providers/html/Tag.kt similarity index 95% rename from src/main/kotlin/com/example/demo/provider/html/Tag.kt rename to src/main/kotlin/com/example/demo/providers/html/Tag.kt index f729987..3b75fef 100644 --- a/src/main/kotlin/com/example/demo/provider/html/Tag.kt +++ b/src/main/kotlin/com/example/demo/providers/html/Tag.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html open class Tag(val name: String) { val children: MutableList = ArrayList() diff --git a/src/main/kotlin/com/example/demo/provider/html/Text.kt b/src/main/kotlin/com/example/demo/providers/html/Text.kt similarity index 66% rename from src/main/kotlin/com/example/demo/provider/html/Text.kt rename to src/main/kotlin/com/example/demo/providers/html/Text.kt index 570452f..1464300 100644 --- a/src/main/kotlin/com/example/demo/provider/html/Text.kt +++ b/src/main/kotlin/com/example/demo/providers/html/Text.kt @@ -1,4 +1,4 @@ -package com.example.demo.provider.html +package com.example.demo.providers.html class Text(val text: String): Tag("b") { override fun toString() = text diff --git a/src/main/kotlin/com/example/demo/services/CityService.kt b/src/main/kotlin/com/example/demo/services/CityService.kt deleted file mode 100644 index bd01ea1..0000000 --- a/src/main/kotlin/com/example/demo/services/CityService.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.demo.services - -import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.http.exceptions.UnprocessableException -import com.example.demo.models.City -import org.springframework.stereotype.Service -import java.util.* - -@Service -interface CityService { - fun findByGuid(guid: UUID): City? - - fun create(name: String): City? - - @Throws(NotFoundException::class, UnprocessableException::class) - fun delete(guid: UUID): City? -} \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/services/database/city/CityService.kt b/src/main/kotlin/com/example/demo/services/database/city/CityService.kt new file mode 100644 index 0000000..dd3c113 --- /dev/null +++ b/src/main/kotlin/com/example/demo/services/database/city/CityService.kt @@ -0,0 +1,17 @@ +package com.example.demo.services.database.city + +import com.example.demo.models.City +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.city.exceptions.CityNotFoundException +import org.springframework.stereotype.Service +import java.util.* + +@Service +interface CityService { + fun findByGuid(guid: UUID): City? + + fun create(name: String): City? + + @Throws(CityNotFoundException::class, AlreadyDeletedException::class) + fun delete(guid: UUID): City? +} \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/services/CityServiceImpl.kt b/src/main/kotlin/com/example/demo/services/database/city/CityServiceImpl.kt similarity index 72% rename from src/main/kotlin/com/example/demo/services/CityServiceImpl.kt rename to src/main/kotlin/com/example/demo/services/database/city/CityServiceImpl.kt index be1dd9d..918334f 100644 --- a/src/main/kotlin/com/example/demo/services/CityServiceImpl.kt +++ b/src/main/kotlin/com/example/demo/services/database/city/CityServiceImpl.kt @@ -1,9 +1,9 @@ -package com.example.demo.services +package com.example.demo.services.database.city -import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.http.exceptions.UnprocessableException import com.example.demo.models.City -import com.example.demo.provider.CityRepository +import com.example.demo.providers.CityRepository +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.city.exceptions.CityNotFoundException import java.time.OffsetDateTime import java.util.* @@ -26,10 +26,10 @@ class CityServiceImpl( } override fun delete(guid: UUID): City? { - val city = findByGuid(guid) ?: throw NotFoundException() + val city = findByGuid(guid) ?: throw CityNotFoundException() if (city.isDeleted()) { - throw UnprocessableException("city already deleted") + throw AlreadyDeletedException() } val deletedCity = city.copy( diff --git a/src/main/kotlin/com/example/demo/services/database/city/exceptions/CityNotFoundException.kt b/src/main/kotlin/com/example/demo/services/database/city/exceptions/CityNotFoundException.kt new file mode 100644 index 0000000..dfaa560 --- /dev/null +++ b/src/main/kotlin/com/example/demo/services/database/city/exceptions/CityNotFoundException.kt @@ -0,0 +1,3 @@ +package com.example.demo.services.database.city.exceptions + +class CityNotFoundException: RuntimeException() diff --git a/src/main/kotlin/com/example/demo/services/database/exceptions/AlreadyDeletedException.kt b/src/main/kotlin/com/example/demo/services/database/exceptions/AlreadyDeletedException.kt new file mode 100644 index 0000000..dde551f --- /dev/null +++ b/src/main/kotlin/com/example/demo/services/database/exceptions/AlreadyDeletedException.kt @@ -0,0 +1,3 @@ +package com.example.demo.services.database.exceptions + +class AlreadyDeletedException: RuntimeException() diff --git a/src/main/kotlin/com/example/demo/services/ProductService.kt b/src/main/kotlin/com/example/demo/services/database/product/ProductService.kt similarity index 53% rename from src/main/kotlin/com/example/demo/services/ProductService.kt rename to src/main/kotlin/com/example/demo/services/database/product/ProductService.kt index ade3447..ae73a8b 100644 --- a/src/main/kotlin/com/example/demo/services/ProductService.kt +++ b/src/main/kotlin/com/example/demo/services/database/product/ProductService.kt @@ -1,8 +1,8 @@ -package com.example.demo.services +package com.example.demo.services.database.product -import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.http.exceptions.UnprocessableException import com.example.demo.models.Product +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.product.exceptions.ProductNotFoundException import com.example.demo.services.kafka.exceptions.InvalidArgumentException import org.springframework.stereotype.Service import java.util.* @@ -13,9 +13,9 @@ interface ProductService { fun create(name: String, price: Long, description: String?): Product - @Throws(NotFoundException::class, UnprocessableException::class) + @Throws(ProductNotFoundException::class, AlreadyDeletedException::class) fun delete(guid: UUID): Product? - @Throws(NotFoundException::class, InvalidArgumentException::class) + @Throws(ProductNotFoundException::class, InvalidArgumentException::class) fun syncToKafka(guid: UUID, topic: String?) } \ No newline at end of file diff --git a/src/main/kotlin/com/example/demo/services/ProductServiceImpl.kt b/src/main/kotlin/com/example/demo/services/database/product/ProductServiceImpl.kt similarity index 76% rename from src/main/kotlin/com/example/demo/services/ProductServiceImpl.kt rename to src/main/kotlin/com/example/demo/services/database/product/ProductServiceImpl.kt index 56e8ec0..08f2ad3 100644 --- a/src/main/kotlin/com/example/demo/services/ProductServiceImpl.kt +++ b/src/main/kotlin/com/example/demo/services/database/product/ProductServiceImpl.kt @@ -1,9 +1,9 @@ -package com.example.demo.services +package com.example.demo.services.database.product -import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.http.exceptions.UnprocessableException import com.example.demo.models.Product -import com.example.demo.provider.ProductRepository +import com.example.demo.providers.ProductRepository +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.product.exceptions.ProductNotFoundException import com.example.demo.services.kafka.Producer import java.time.OffsetDateTime import java.util.* @@ -31,10 +31,10 @@ class ProductServiceImpl( } override fun delete(guid: UUID): Product? { - val product = findByGuid(guid) ?: throw NotFoundException() + val product = findByGuid(guid) ?: throw ProductNotFoundException() if (product.isDeleted()) { - throw UnprocessableException("product already deleted") + throw AlreadyDeletedException() } val deletedProduct = product.copy( @@ -52,7 +52,7 @@ class ProductServiceImpl( } override fun syncToKafka(guid: UUID, topic: String?) { - val product = findByGuid(guid) ?: throw NotFoundException() + val product = findByGuid(guid) ?: throw ProductNotFoundException() producer.produceProductInfo(topic ?: defaultSyncTopic, product) } diff --git a/src/main/kotlin/com/example/demo/services/database/product/exceptions/ProductNotFoundException.kt b/src/main/kotlin/com/example/demo/services/database/product/exceptions/ProductNotFoundException.kt new file mode 100644 index 0000000..32f85b0 --- /dev/null +++ b/src/main/kotlin/com/example/demo/services/database/product/exceptions/ProductNotFoundException.kt @@ -0,0 +1,3 @@ +package com.example.demo.services.database.product.exceptions + +class ProductNotFoundException: RuntimeException() diff --git a/src/test/kotlin/com/example/demo/http/controllers/ProductControllerTest.kt b/src/test/kotlin/com/example/demo/http/controllers/ProductControllerTest.kt index 663eb9f..b546652 100644 --- a/src/test/kotlin/com/example/demo/http/controllers/ProductControllerTest.kt +++ b/src/test/kotlin/com/example/demo/http/controllers/ProductControllerTest.kt @@ -1,9 +1,8 @@ package com.example.demo.http.controllers -import com.example.demo.http.controllers.ProductController -import com.example.demo.models.Product import com.example.demo.http.responses.ResponseStatus -import com.example.demo.services.ProductService +import com.example.demo.models.Product +import com.example.demo.services.database.product.ProductService import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.nullValue diff --git a/src/test/kotlin/com/example/demo/http/controllers/ShopControllerTest.kt b/src/test/kotlin/com/example/demo/http/controllers/ShopControllerTest.kt index 463c4ef..7a0efd9 100644 --- a/src/test/kotlin/com/example/demo/http/controllers/ShopControllerTest.kt +++ b/src/test/kotlin/com/example/demo/http/controllers/ShopControllerTest.kt @@ -1,8 +1,7 @@ package com.example.demo.http.controllers -import com.example.demo.http.controllers.ShopController import com.example.demo.models.* -import com.example.demo.provider.ShopProvider +import com.example.demo.providers.ShopProvider import org.mockito.kotlin.doReturn import org.mockito.kotlin.whenever import org.springframework.beans.factory.annotation.Autowired diff --git a/src/test/kotlin/com/example/demo/services/CityServiceImplTest.kt b/src/test/kotlin/com/example/demo/services/database/city/CityServiceImplTest.kt similarity index 71% rename from src/test/kotlin/com/example/demo/services/CityServiceImplTest.kt rename to src/test/kotlin/com/example/demo/services/database/city/CityServiceImplTest.kt index e6b40f2..35bc029 100644 --- a/src/test/kotlin/com/example/demo/services/CityServiceImplTest.kt +++ b/src/test/kotlin/com/example/demo/services/database/city/CityServiceImplTest.kt @@ -1,10 +1,14 @@ -package com.example.demo.services +package com.example.demo.services.database.city import com.example.demo.BaseFeatureTest import com.example.demo.models.City -import com.example.demo.provider.CityRepository +import com.example.demo.providers.CityRepository +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.city.exceptions.CityNotFoundException +import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration +import java.util.* import kotlin.test.* @ContextConfiguration(classes = [CityRepository::class, CityServiceImpl::class]) @@ -35,6 +39,14 @@ class CityServiceImplTest: BaseFeatureTest() { assertEquals(city.id, deletedCity.id) assertNotNull(deletedCity.deletedAt) assertTrue(deletedCity.isDeleted()) + + assertThrows { + cityServiceImpl.delete(city.guid) + } + + assertThrows { + cityServiceImpl.delete(UUID.randomUUID()) + } } finally { val id = city?.id if (id != null) { diff --git a/src/test/kotlin/com/example/demo/services/ProductServiceImplFeatureTest.kt b/src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplFeatureTest.kt similarity index 85% rename from src/test/kotlin/com/example/demo/services/ProductServiceImplFeatureTest.kt rename to src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplFeatureTest.kt index 6696618..123f85c 100644 --- a/src/test/kotlin/com/example/demo/services/ProductServiceImplFeatureTest.kt +++ b/src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplFeatureTest.kt @@ -1,10 +1,10 @@ -package com.example.demo.services +package com.example.demo.services.database.product import com.example.demo.BaseFeatureTest -import com.example.demo.http.exceptions.NotFoundException -import com.example.demo.http.exceptions.UnprocessableException import com.example.demo.models.Product -import com.example.demo.provider.ProductRepository +import com.example.demo.providers.ProductRepository +import com.example.demo.services.database.exceptions.AlreadyDeletedException +import com.example.demo.services.database.product.exceptions.ProductNotFoundException import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration @@ -52,11 +52,11 @@ class ProductServiceImplFeatureTest: BaseFeatureTest() { assertTrue(deletedProduct.isDeleted()) // try to delete already deleted product - assertThrows { + assertThrows { productService.delete(product.guid) } - assertThrows { + assertThrows { productService.delete(UUID.randomUUID()) } } finally { diff --git a/src/test/kotlin/com/example/demo/services/ProductServiceImplTest.kt b/src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplTest.kt similarity index 92% rename from src/test/kotlin/com/example/demo/services/ProductServiceImplTest.kt rename to src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplTest.kt index a538925..97f098e 100644 --- a/src/test/kotlin/com/example/demo/services/ProductServiceImplTest.kt +++ b/src/test/kotlin/com/example/demo/services/database/product/ProductServiceImplTest.kt @@ -1,10 +1,10 @@ -package com.example.demo.services +package com.example.demo.services.database.product -import com.example.demo.http.exceptions.NotFoundException import com.example.demo.models.Product -import com.example.demo.provider.ProductRepository +import com.example.demo.providers.ProductRepository import com.example.demo.services.kafka.Producer import com.example.demo.services.kafka.exceptions.InvalidArgumentException +import com.example.demo.services.database.product.exceptions.ProductNotFoundException import org.junit.jupiter.api.assertThrows import org.junit.runner.RunWith import org.mockito.kotlin.* @@ -67,7 +67,7 @@ class ProductServiceImplTest { whenever(productRepository.findByGuid(eq(guid))) .thenReturn(null) - assertThrows { + assertThrows { productService.syncToKafka(guid, specificTopic) }