diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1e050f52 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +[*.{kt,kts}] + +ktlint_standard_blank-line-before-declaration = disabled +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_class-naming = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_function-expression-body = disabled +ktlint_standard_function-naming = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_if-else-wrapping = disabled +ktlint_standard_max-line-length = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_no-blank-line-in-list = disabled +ktlint_standard_property-naming = disabled +ktlint_standard_trailing-comma-on-call-site = disabled diff --git a/build.gradle.kts b/build.gradle.kts index 6374b815..989918f4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ plugins { java kotlin("jvm") - id("com.diffplug.spotless")version "6.25.0" + id("com.diffplug.spotless") version "6.25.0" } val springBootProjects = subprojects.filter { diff --git a/comparison-with-exposed/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/comparison-with-exposed/src/test/kotlin/org/komapper/example/ApplicationTest.kt index fa89f38b..7ed9d1b4 100644 --- a/comparison-with-exposed/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/comparison-with-exposed/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -3,7 +3,6 @@ package org.komapper.example import kotlin.test.Test class ApplicationTest { - @Test fun test() { main() diff --git a/console-jdbc/src/test/kotlin/org/komapper/example/AddressTest.kt b/console-jdbc/src/test/kotlin/org/komapper/example/AddressTest.kt index 830cfe6a..b2a18753 100644 --- a/console-jdbc/src/test/kotlin/org/komapper/example/AddressTest.kt +++ b/console-jdbc/src/test/kotlin/org/komapper/example/AddressTest.kt @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test import org.komapper.core.dsl.Meta class AddressTest { - @Test fun test() { assertNotNull(Meta.address) diff --git a/console-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/console-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt index a74abf9f..13133bda 100644 --- a/console-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/console-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -3,7 +3,6 @@ package org.komapper.example import org.junit.jupiter.api.Test class ApplicationTest { - @Test fun test() { main() diff --git a/console-r2dbc/src/test/kotlin/org/komapper/example/AddressTest.kt b/console-r2dbc/src/test/kotlin/org/komapper/example/AddressTest.kt index 830cfe6a..b2a18753 100644 --- a/console-r2dbc/src/test/kotlin/org/komapper/example/AddressTest.kt +++ b/console-r2dbc/src/test/kotlin/org/komapper/example/AddressTest.kt @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test import org.komapper.core.dsl.Meta class AddressTest { - @Test fun test() { assertNotNull(Meta.address) diff --git a/console-r2dbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/console-r2dbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt index 1984797c..542eaf76 100644 --- a/console-r2dbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/console-r2dbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -4,7 +4,6 @@ import kotlinx.coroutines.runBlocking import org.junit.jupiter.api.Test class ApplicationTest { - @Test fun test() = runBlocking { main() diff --git a/gradle.properties b/gradle.properties index abb54b54..d282cf62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,10 +7,10 @@ group=org.komapper version=0.0.1 ktorVersion=3.0.1 -kotlinVersion=2.0.21 +kotlinVersion=2.1.0 komapperVersion=5.0.0 kspVersion=1.0.28 -ktlintVersion=0.48.0 +ktlintVersion=1.4.1 quarkusVersion=3.17.2 springBootVersion=3.3.5 nativeBuildToolsVersion=0.10.3 diff --git a/jpetstore/src/main/kotlin/org/komapper/example/repository/AccountRepository.kt b/jpetstore/src/main/kotlin/org/komapper/example/repository/AccountRepository.kt index 4060dca4..50921e4c 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/repository/AccountRepository.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/repository/AccountRepository.kt @@ -16,7 +16,6 @@ import org.springframework.stereotype.Repository @Repository class AccountRepository(private val db: JdbcDatabase) { - private val a = Meta.account private val p = Meta.profile private val s = Meta.signOn diff --git a/jpetstore/src/main/kotlin/org/komapper/example/repository/CategoryRepository.kt b/jpetstore/src/main/kotlin/org/komapper/example/repository/CategoryRepository.kt index 730aa134..9a363a87 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/repository/CategoryRepository.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/repository/CategoryRepository.kt @@ -10,7 +10,6 @@ import org.springframework.stereotype.Repository @Repository class CategoryRepository(private val db: JdbcDatabase) { - private val c = Meta.category fun fetchCategory(categoryId: String): Category? { diff --git a/jpetstore/src/main/kotlin/org/komapper/example/repository/ItemRepository.kt b/jpetstore/src/main/kotlin/org/komapper/example/repository/ItemRepository.kt index 7b5b58d2..43e94323 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/repository/ItemRepository.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/repository/ItemRepository.kt @@ -11,7 +11,6 @@ import org.springframework.stereotype.Repository @Repository class ItemRepository(private val db: JdbcDatabase) { - private val item = Meta.item private val inv = Meta.inventory private val p = Meta.product diff --git a/jpetstore/src/main/kotlin/org/komapper/example/repository/OrderRepository.kt b/jpetstore/src/main/kotlin/org/komapper/example/repository/OrderRepository.kt index 60d52946..11d0696b 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/repository/OrderRepository.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/repository/OrderRepository.kt @@ -17,7 +17,6 @@ import org.springframework.stereotype.Repository @Repository class OrderRepository(private val db: JdbcDatabase) { - private val o = Meta.order private val os = Meta.orderStatus private val li = Meta.lineItem diff --git a/jpetstore/src/main/kotlin/org/komapper/example/repository/ProductRepository.kt b/jpetstore/src/main/kotlin/org/komapper/example/repository/ProductRepository.kt index 2ebf18cc..31867505 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/repository/ProductRepository.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/repository/ProductRepository.kt @@ -12,7 +12,6 @@ import org.springframework.stereotype.Repository @Repository class ProductRepository(private val db: JdbcDatabase) { - private val p = Meta.product private val item = Meta.item diff --git a/jpetstore/src/main/kotlin/org/komapper/example/service/AccountService.kt b/jpetstore/src/main/kotlin/org/komapper/example/service/AccountService.kt index f918cb5e..c34f0142 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/service/AccountService.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/service/AccountService.kt @@ -13,7 +13,6 @@ import org.springframework.stereotype.Service @Service class AccountService(private val accountRepository: AccountRepository) : UserDetailsService { - fun getAccountAggregate(username: String): AccountAggregate { return accountRepository.fetchAccountAggregate(username) } diff --git a/jpetstore/src/main/kotlin/org/komapper/example/service/OrderService.kt b/jpetstore/src/main/kotlin/org/komapper/example/service/OrderService.kt index 36a1b223..4489c102 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/service/OrderService.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/service/OrderService.kt @@ -15,7 +15,6 @@ class OrderService( private val orderRepository: OrderRepository, private val accountRepository: AccountRepository, ) { - fun executeOrder(username: String, cart: Cart) { val order = orderRepository.insertOrder(createOrder(username, cart)) val lineItemList = orderRepository.insertLineItemList(createLineItemList(order, cart)) diff --git a/jpetstore/src/main/kotlin/org/komapper/example/service/ProductService.kt b/jpetstore/src/main/kotlin/org/komapper/example/service/ProductService.kt index bff05664..31314609 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/service/ProductService.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/service/ProductService.kt @@ -8,7 +8,6 @@ import java.util.StringTokenizer @Service class ProductService(private val productRepository: ProductRepository) { - fun getProductListByCategory(categoryId: String): List { return productRepository.fetchProductListByCategoryId(categoryId) } diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/AccountController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/AccountController.kt index ef456ea8..5ed6d48a 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/AccountController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/AccountController.kt @@ -28,7 +28,6 @@ class AccountController( private val passwordEncoder: PasswordEncoder, private val passwordValidator: PasswordValidator, ) { - @InitBinder("accountAddForm") fun initBinder(binder: WebDataBinder) { binder.addValidators(passwordValidator) @@ -66,7 +65,10 @@ class AccountController( } @GetMapping("/edit") - fun edit(model: Model, @AuthenticationPrincipal user: User): String { + fun edit( + model: Model, + @AuthenticationPrincipal user: User, + ): String { val aggregate = accountService.getAccountAggregate(user.username) val accountForm = createAccountEditForm(aggregate) return modelAndViewForEdit(model, accountForm, user) diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CartController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CartController.kt index 2f004c13..92e47036 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CartController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CartController.kt @@ -33,7 +33,11 @@ class CartController(private val itemService: ItemService, private val cart: Car } @PostMapping - fun updateAll(@Validated cartForm: CartForm, result: BindingResult, model: Model): String { + fun updateAll( + @Validated cartForm: CartForm, + result: BindingResult, + model: Model, + ): String { if (result.hasErrors()) { model.addAttribute("cart", cart) model.addAttribute("cartForm", cartForm) @@ -52,7 +56,10 @@ class CartController(private val itemService: ItemService, private val cart: Car } @PostMapping("/item/{itemId}") - fun addItem(@PathVariable itemId: String, model: Model): String { + fun addItem( + @PathVariable itemId: String, + model: Model, + ): String { if (cart.containsItemId(itemId)) { cart.incrementQuantity(itemId) } else { @@ -65,7 +72,9 @@ class CartController(private val itemService: ItemService, private val cart: Car } @DeleteMapping("/item/{itemId}") - fun removeItem(@PathVariable itemId: String): String { + fun removeItem( + @PathVariable itemId: String, + ): String { cart.removeItemById(itemId) return "redirect:/cart" } diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CategoryController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CategoryController.kt index 6afcb64e..39fb32e7 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CategoryController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/CategoryController.kt @@ -14,7 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping @Transactional class CategoryController(private val categoryService: CategoryService, private val productService: ProductService) { @GetMapping("/{id}") - fun category(@PathVariable id: String?, model: Model): String { + fun category( + @PathVariable id: String?, + model: Model, + ): String { model.addAttribute("category", categoryService.getCategory(id!!)) model.addAttribute("productList", productService.getProductListByCategory(id)) return "category/list" diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/HistoryController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/HistoryController.kt index a6c04b8b..c0e6796b 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/HistoryController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/HistoryController.kt @@ -17,18 +17,23 @@ import org.springframework.web.server.ResponseStatusException @RequestMapping("/history") @Transactional class HistoryController(private val orderService: OrderService) { - private val logger = LoggerFactory.getLogger(HistoryController::class.java) @GetMapping - fun viewList(model: Model, @AuthenticationPrincipal user: User): String { + fun viewList( + model: Model, + @AuthenticationPrincipal user: User, + ): String { val orderList = orderService.getOrderList(user.username) model.addAttribute("orderList", orderList) return "history/list" } @GetMapping("{orderId}") - fun viewDetail(@PathVariable orderId: Int, model: Model): String { + fun viewDetail( + @PathVariable orderId: Int, + model: Model, + ): String { val orderAggregate = orderService.getOrderAggregate(orderId) ?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "orderId=$orderId not found") model.addAttribute("order", orderAggregate.order) diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ItemController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ItemController.kt index ee326063..e1cdcc23 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ItemController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ItemController.kt @@ -15,7 +15,10 @@ import org.springframework.web.server.ResponseStatusException @Transactional class ItemController(private val itemService: ItemService) { @GetMapping("/{itemId}") - fun viewDetail(@PathVariable itemId: String, model: Model): String { + fun viewDetail( + @PathVariable itemId: String, + model: Model, + ): String { val itemAggregate = itemService.getItemAggregate(itemId) ?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "itemId=$itemId not found") model.addAttribute("item", itemAggregate.item) diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/OrderController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/OrderController.kt index 6e462774..fa88c837 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/OrderController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/OrderController.kt @@ -31,7 +31,10 @@ class OrderController(private val orderService: OrderService, private val cart: } @PostMapping - fun confirm(@AuthenticationPrincipal user: User, redirectAttributes: RedirectAttributes): String { + fun confirm( + @AuthenticationPrincipal user: User, + redirectAttributes: RedirectAttributes, + ): String { if (cart.isEmpty) { return fillMessageAndRedirectToIndex(redirectAttributes) } diff --git a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ProductController.kt b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ProductController.kt index 53db809c..ed8cd36b 100644 --- a/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ProductController.kt +++ b/jpetstore/src/main/kotlin/org/komapper/example/web/controller/ProductController.kt @@ -15,7 +15,10 @@ import org.springframework.web.server.ResponseStatusException @Transactional class ProductController(private val productService: ProductService) { @GetMapping("/{productId}") - fun product(@PathVariable productId: String, model: Model): String { + fun product( + @PathVariable productId: String, + model: Model, + ): String { val productAggregate = productService.getProductAggregate(productId) ?: throw ResponseStatusException(HttpStatus.BAD_REQUEST, "productId=$productId not found") model.addAttribute("product", productAggregate.product) diff --git a/jpetstore/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/jpetstore/src/test/kotlin/org/komapper/example/ApplicationTest.kt index fb36f235..0fb6f143 100644 --- a/jpetstore/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/jpetstore/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -12,7 +12,6 @@ internal class ApplicationTest( @Autowired private val restTemplate: TestRestTemplate, @LocalServerPort private val port: Int, ) { - @Test fun fish() { Assertions.assertThat( diff --git a/kweet/src/dao/DAOFacadeKomapper.kt b/kweet/src/dao/DAOFacadeKomapper.kt index 70c98589..62197dcc 100644 --- a/kweet/src/dao/DAOFacadeKomapper.kt +++ b/kweet/src/dao/DAOFacadeKomapper.kt @@ -16,7 +16,6 @@ import java.time.LocalDateTime class DAOFacadeKomapper( private val db: R2dbcDatabase, ) : DAOFacade { - private val k = Meta.kweet private val k2 = Meta.kweet2 private val u = Meta.user diff --git a/kweet/test/KweetApplicationTest.kt b/kweet/test/KweetApplicationTest.kt index 0295c939..db22dfc4 100644 --- a/kweet/test/KweetApplicationTest.kt +++ b/kweet/test/KweetApplicationTest.kt @@ -34,7 +34,6 @@ import kotlin.test.assertTrue * Uses [testApp] in test methods to simplify the testing. */ class KweetApplicationTest { - private val db = object : R2dbcDatabase by mockk(relaxed = true) { private val operator = mockk(relaxed = true) override suspend fun withTransaction( diff --git a/quarkus-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxService.kt b/quarkus-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxService.kt index 82d0647a..b8daa403 100644 --- a/quarkus-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxService.kt +++ b/quarkus-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxService.kt @@ -18,23 +18,26 @@ import org.komapper.jdbc.JdbcDatabase @Consumes("application/json") @Transactional @ApplicationScoped -class DeclarativeTxService @Inject constructor(private val database: JdbcDatabase) { - - @GET - fun list(): List { - return database.runQuery { - val m = Meta.message - QueryDsl.from(m).orderBy(m.id.desc()) +class DeclarativeTxService + @Inject + constructor(private val database: JdbcDatabase) { + @GET + fun list(): List { + return database.runQuery { + val m = Meta.message + QueryDsl.from(m).orderBy(m.id.desc()) + } } - } - @GET - @Path("/add") - fun add(@QueryParam("text") text: String?): Message { - val message = Message(text = text ?: "empty") - return database.runQuery { - val m = Meta.message - QueryDsl.insert(m).single(message) + @GET + @Path("/add") + fun add( + @QueryParam("text") text: String?, + ): Message { + val message = Message(text = text ?: "empty") + return database.runQuery { + val m = Meta.message + QueryDsl.insert(m).single(message) + } } } -} diff --git a/quarkus-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxService.kt b/quarkus-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxService.kt index 2ddcbccb..ad4e7092 100644 --- a/quarkus-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxService.kt +++ b/quarkus-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxService.kt @@ -16,23 +16,26 @@ import org.komapper.jdbc.JdbcDatabase @Produces("application/json") @Consumes("application/json") @ApplicationScoped -class ImperativeTxService @Inject constructor(private val database: JdbcDatabase) { - - @GET - fun list(): List = database.withTransaction { - database.runQuery { - val m = Meta.message - QueryDsl.from(m).orderBy(m.id.desc()) +class ImperativeTxService + @Inject + constructor(private val database: JdbcDatabase) { + @GET + fun list(): List = database.withTransaction { + database.runQuery { + val m = Meta.message + QueryDsl.from(m).orderBy(m.id.desc()) + } } - } - @GET - @Path("/add") - fun add(@QueryParam("text") text: String?): Message = database.withTransaction { - val message = Message(text = text ?: "empty") - database.runQuery { - val m = Meta.message - QueryDsl.insert(m).single(message) + @GET + @Path("/add") + fun add( + @QueryParam("text") text: String?, + ): Message = database.withTransaction { + val message = Message(text = text ?: "empty") + database.runQuery { + val m = Meta.message + QueryDsl.insert(m).single(message) + } } } -} diff --git a/quarkus-jdbc/src/main/kotlin/org/komapper/example/Startup.kt b/quarkus-jdbc/src/main/kotlin/org/komapper/example/Startup.kt index 04b2c2bb..1935e19d 100644 --- a/quarkus-jdbc/src/main/kotlin/org/komapper/example/Startup.kt +++ b/quarkus-jdbc/src/main/kotlin/org/komapper/example/Startup.kt @@ -10,12 +10,15 @@ import org.komapper.core.dsl.query.andThen import org.komapper.jdbc.JdbcDatabase @ApplicationScoped -class Startup @Inject constructor(private val database: JdbcDatabase) { - - fun startup(@Observes event: StartupEvent) { - val q1 = QueryDsl.create(Meta.message) - val q2 = QueryDsl.insert(Meta.message) - .multiple(Message(text = "Hello"), Message(text = "World!")) - database.runQuery(q1.andThen(q2)) +class Startup + @Inject + constructor(private val database: JdbcDatabase) { + fun startup( + @Observes event: StartupEvent, + ) { + val q1 = QueryDsl.create(Meta.message) + val q2 = QueryDsl.insert(Meta.message) + .multiple(Message(text = "Hello"), Message(text = "World!")) + database.runQuery(q1.andThen(q2)) + } } -} diff --git a/quarkus-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/quarkus-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt index a059e39e..b669d37a 100644 --- a/quarkus-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/quarkus-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -7,7 +7,6 @@ import org.junit.jupiter.api.Test @QuarkusTest class ApplicationTest { - @Test fun declarative() { RestAssured.given() diff --git a/quarkus-jdbc/src/test/kotlin/org/komapper/example/QuarkusJdbcTransactionOperatorTest.kt b/quarkus-jdbc/src/test/kotlin/org/komapper/example/QuarkusJdbcTransactionOperatorTest.kt index 2298e0a1..90612ab7 100644 --- a/quarkus-jdbc/src/test/kotlin/org/komapper/example/QuarkusJdbcTransactionOperatorTest.kt +++ b/quarkus-jdbc/src/test/kotlin/org/komapper/example/QuarkusJdbcTransactionOperatorTest.kt @@ -21,7 +21,6 @@ import kotlin.test.assertTrue @QuarkusTest internal class QuarkusJdbcTransactionOperatorTest { - @Inject private lateinit var dataSource: DataSource @@ -283,7 +282,8 @@ internal class QuarkusJdbcTransactionOperatorTest { @BeforeTest fun before() { - val sql = """ + val sql = + """ CREATE TABLE ADDRESS(ADDRESS_ID INTEGER NOT NULL PRIMARY KEY, STREET VARCHAR(20) UNIQUE, VERSION INTEGER); INSERT INTO ADDRESS VALUES(1,'STREET 1',1); INSERT INTO ADDRESS VALUES(2,'STREET 2',1); @@ -300,7 +300,7 @@ internal class QuarkusJdbcTransactionOperatorTest { INSERT INTO ADDRESS VALUES(13,'STREET 13',1); INSERT INTO ADDRESS VALUES(14,'STREET 14',1); INSERT INTO ADDRESS VALUES(15,'STREET 15',1); - """.trimIndent() + """.trimIndent() val config = object : DefaultJdbcDatabaseConfig(dataSource, JdbcDialects.get("h2")) { override val session: JdbcSession = QuarkusJdbcTransactionSession(transactionManager, dataSource) diff --git a/repository-pattern-jdbc/src/main/kotlin/org/komapper/example/ExampleRepository.kt b/repository-pattern-jdbc/src/main/kotlin/org/komapper/example/ExampleRepository.kt index 69df317d..d4762c46 100644 --- a/repository-pattern-jdbc/src/main/kotlin/org/komapper/example/ExampleRepository.kt +++ b/repository-pattern-jdbc/src/main/kotlin/org/komapper/example/ExampleRepository.kt @@ -11,7 +11,6 @@ import org.komapper.jdbc.JdbcDatabase import java.math.BigDecimal class ExampleRepository(private val db: JdbcDatabase) { - private val d = Meta.department private val e = Meta.employee private val m = Meta.manager diff --git a/repository-pattern-jdbc/src/test/kotlin/org/komapper/example/ExampleRepositoryTest.kt b/repository-pattern-jdbc/src/test/kotlin/org/komapper/example/ExampleRepositoryTest.kt index f41a2f4c..f0ab36a2 100644 --- a/repository-pattern-jdbc/src/test/kotlin/org/komapper/example/ExampleRepositoryTest.kt +++ b/repository-pattern-jdbc/src/test/kotlin/org/komapper/example/ExampleRepositoryTest.kt @@ -16,7 +16,6 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue class ExampleRepositoryTest : InvocationInterceptor { - private val db = JdbcDatabase("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1") private val repo = ExampleRepository(db) @@ -167,7 +166,8 @@ class ExampleRepositoryTest : InvocationInterceptor { } } - private val script = """ + private val script = + """ CREATE TABLE IF NOT EXISTS DEPARTMENT(DEPARTMENT_ID INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 100) NOT NULL PRIMARY KEY, DEPARTMENT_NO INTEGER NOT NULL UNIQUE,DEPARTMENT_NAME VARCHAR(20),LOCATION VARCHAR(20) DEFAULT 'TOKYO', VERSION INTEGER); CREATE TABLE IF NOT EXISTS ADDRESS(ADDRESS_ID INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 100) NOT NULL PRIMARY KEY, STREET VARCHAR(20) UNIQUE, VERSION INTEGER); CREATE TABLE IF NOT EXISTS EMPLOYEE(EMPLOYEE_ID INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 100) NOT NULL PRIMARY KEY, EMPLOYEE_NO INTEGER NOT NULL ,EMPLOYEE_NAME VARCHAR(20),MANAGER_ID INTEGER,HIREDATE DATE,SALARY NUMERIC(7,2),DEPARTMENT_ID INTEGER,ADDRESS_ID INTEGER,VERSION INTEGER, CONSTRAINT FK_DEPARTMENT_ID FOREIGN KEY(DEPARTMENT_ID) REFERENCES DEPARTMENT(DEPARTMENT_ID), CONSTRAINT FK_ADDRESS_ID FOREIGN KEY(ADDRESS_ID) REFERENCES ADDRESS(ADDRESS_ID)); @@ -205,5 +205,5 @@ class ExampleRepositoryTest : InvocationInterceptor { INSERT INTO EMPLOYEE VALUES(12,7900,'JAMES',6,'1981-12-03',950,3,12,1); INSERT INTO EMPLOYEE VALUES(13,7902,'FORD',4,'1981-12-03',3000,1,13,1); INSERT INTO EMPLOYEE VALUES(14,7934,'MILLER',7,'1982-01-23',1300,1,14,1); - """.trimIndent() + """.trimIndent() } diff --git a/spring-boot-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt b/spring-boot-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt index 54dca7a7..c4f01b57 100644 --- a/spring-boot-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt +++ b/spring-boot-jdbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RestController @RestController @Transactional class DeclarativeTxController(private val database: JdbcDatabase) { - @RequestMapping fun list(): List { return database.runQuery { @@ -22,7 +21,9 @@ class DeclarativeTxController(private val database: JdbcDatabase) { } @RequestMapping(params = ["text"]) - fun add(@RequestParam text: String): Message { + fun add( + @RequestParam text: String, + ): Message { val message = Message(text = text) return database.runQuery { val m = Meta.message diff --git a/spring-boot-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt b/spring-boot-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt index 04134b4c..3edc7d2a 100644 --- a/spring-boot-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt +++ b/spring-boot-jdbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.RestController @RestController @Transactional class ImperativeTxController(private val database: JdbcDatabase) { - @RequestMapping fun list(): List = database.withTransaction { database.runQuery { @@ -22,7 +21,9 @@ class ImperativeTxController(private val database: JdbcDatabase) { } @RequestMapping(params = ["text"]) - fun add(@RequestParam text: String): Message = database.withTransaction { + fun add( + @RequestParam text: String, + ): Message = database.withTransaction { val message = Message(text = text) database.runQuery { val m = Meta.message diff --git a/spring-boot-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt b/spring-boot-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt index 46393f26..bd95bff1 100644 --- a/spring-boot-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt +++ b/spring-boot-jdbc/src/test/kotlin/org/komapper/example/ApplicationTest.kt @@ -12,7 +12,6 @@ import org.springframework.web.util.UriComponentsBuilder @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class ApplicationTest { - private val restTemplate = TestRestTemplate() private val typedReference: ParameterizedTypeReference> = object : ParameterizedTypeReference>() {} diff --git a/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt b/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt index f7306334..f97d929c 100644 --- a/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt +++ b/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/DeclarativeTxController.kt @@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController @RestController @Transactional class DeclarativeTxController(private val database: R2dbcDatabase) { - @RequestMapping suspend fun list(): Flow { return database.flowQuery { @@ -23,7 +22,9 @@ class DeclarativeTxController(private val database: R2dbcDatabase) { } @RequestMapping(params = ["text"]) - suspend fun add(@RequestParam text: String): Message { + suspend fun add( + @RequestParam text: String, + ): Message { val message = Message(text = text) return database.runQuery { val m = Meta.message diff --git a/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt b/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt index 93cdc4d7..dedf255a 100644 --- a/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt +++ b/spring-boot-r2dbc/src/main/kotlin/org/komapper/example/ImperativeTxController.kt @@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController @RestController @Transactional class ImperativeTxController(private val database: R2dbcDatabase) { - @RequestMapping suspend fun list(): Flow = database.withTransaction { database.flowQuery { @@ -23,7 +22,9 @@ class ImperativeTxController(private val database: R2dbcDatabase) { } @RequestMapping(params = ["text"]) - suspend fun add(@RequestParam text: String): Message = database.withTransaction { + suspend fun add( + @RequestParam text: String, + ): Message = database.withTransaction { val message = Message(text = text) database.runQuery { val m = Meta.message diff --git a/spring-boot-r2dbc/src/test/java/org/komapper/example/ApplicationTest.kt b/spring-boot-r2dbc/src/test/java/org/komapper/example/ApplicationTest.kt index 46393f26..bd95bff1 100644 --- a/spring-boot-r2dbc/src/test/java/org/komapper/example/ApplicationTest.kt +++ b/spring-boot-r2dbc/src/test/java/org/komapper/example/ApplicationTest.kt @@ -12,7 +12,6 @@ import org.springframework.web.util.UriComponentsBuilder @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class ApplicationTest { - private val restTemplate = TestRestTemplate() private val typedReference: ParameterizedTypeReference> = object : ParameterizedTypeReference>() {}