Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadshahwan committed Jul 31, 2024
1 parent 6363ce1 commit a4a96a7
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import co.digamma.ca.domain.api.common.NotFoundException
import co.digamma.ca.domain.api.model.Model
import co.digamma.ca.domain.spi.CrudRepository

open class InMemCrudRepository<T: Model>: CrudRepository<T> {
open class InMemCrudRepository<T : Model> : CrudRepository<T> {
private val data: MutableMap<String, T> = HashMap()

override fun retrieve(id: String): T? = data[id]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import co.digamma.ca.domain.spi.food.CourseRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemCourseRepository: InMemCrudRepository<Course>(), CourseRepository
class InMemCourseRepository : InMemCrudRepository<Course>(), CourseRepository
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import co.digamma.ca.domain.spi.food.CuisineRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemCuisineRepository: InMemCrudRepository<Cuisine>(), CuisineRepository
class InMemCuisineRepository : InMemCrudRepository<Cuisine>(), CuisineRepository
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import co.digamma.ca.domain.spi.food.DishRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemDishRepository: InMemCrudRepository<Dish>(), DishRepository
class InMemDishRepository : InMemCrudRepository<Dish>(), DishRepository
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import co.digamma.ca.domain.spi.food.ServingRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemServingRepository: InMemCrudRepository<Serving>(), ServingRepository
class InMemServingRepository : InMemCrudRepository<Serving>(), ServingRepository
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import co.digamma.ca.domain.spi.media.ImageRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemImageRepository: InMemCrudRepository<Image>(), ImageRepository
class InMemImageRepository : InMemCrudRepository<Image>(), ImageRepository
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.Locale

abstract class CourseRepositoryTestBase : CrudRepositoryTestBase<Course>() {

abstract override val sut : CourseRepository
abstract override val sut: CourseRepository

override fun newModel() = Course(
id = RandGen.uuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.Locale

abstract class CuisineRepositoryTestBase : CrudRepositoryTestBase<Cuisine>() {

abstract override val sut : CuisineRepository
abstract override val sut: CuisineRepository

override fun newModel() = Cuisine(
id = RandGen.uuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.Locale

abstract class DishRepositoryTestBase : CrudRepositoryTestBase<Dish>() {

abstract override val sut : DishRepository
abstract override val sut: DishRepository
abstract val courseRepository: CourseRepository
abstract val cuisineRepository: CuisineRepository
abstract val servingRepository: ServingRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.Locale

abstract class ServingRepositoryTestBase : CrudRepositoryTestBase<Serving>() {

abstract override val sut : ServingRepository
abstract override val sut: ServingRepository

override fun newModel() = Serving(
id = RandGen.uuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data class PageQuery(

private fun Int.toCursor() = DefaultConnectionCursor(this.toString())

fun <T: Model> Page<T>.asConnection(): Connection<T> {
fun <T : Model> Page<T>.asConnection(): Connection<T> {
return DefaultConnection(
this.results.mapIndexed { index, item -> DefaultEdge(item, index.toCursor()) },
DefaultPageInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ class ImageControllerTest {
@Autowired
private lateinit var mockMvc: MockMvc

private val client get(): WebTestClient =
MockMvcWebTestClient.bindTo(mockMvc)
.baseUrl("/graphql")
.build()
private val client
get(): WebTestClient =
MockMvcWebTestClient.bindTo(mockMvc)
.baseUrl("/graphql")
.build()

private val tester get(): HttpGraphQlTester =
HttpGraphQlTester.create(client)
private val tester
get(): HttpGraphQlTester =
HttpGraphQlTester.create(client)

@Test
fun image() {
Expand All @@ -68,10 +70,11 @@ class ImageControllerTest {
tester.document(GET_IMAGE_DOCUMENT)
.variables(mapOf("id" to createdId))
.execute()
.path("data.image") { it
.path("id").entity(String::class.java).isEqualTo(createdId)
.path("description").entity(String::class.java).isEqualTo(DESCRIPTION)
.path("url").entity(String::class.java).isEqualTo(URL)
.path("data.image") {
it
.path("id").entity(String::class.java).isEqualTo(createdId)
.path("description").entity(String::class.java).isEqualTo(DESCRIPTION)
.path("url").entity(String::class.java).isEqualTo(URL)
}
}

Expand Down Expand Up @@ -101,7 +104,7 @@ class ImageControllerTest {
.variables(mapOf("id" to createdId))
.execute()
.errors()
.expect { it.errorType.toString() === "NOT_FOUND" }
.expect { it.errorType.toString() === "NOT_FOUND" }
.verify()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.jooq.impl.SQLDataType

private const val TIMESTAMP_FIELD_NAME = "timestamp"

abstract class SqlCrudRepository<T: Model, R: UpdatableRecord<R>>(
abstract class SqlCrudRepository<T : Model, R : UpdatableRecord<R>>(
protected val table: Table<R>,
protected val idField: TableField<R, String?>,
protected val dsl: DSLContext,
Expand All @@ -50,7 +50,7 @@ abstract class SqlCrudRepository<T: Model, R: UpdatableRecord<R>>(

override fun retrieve(pageSpecs: PageSpecs): Page<T> {
val total = this.dsl.selectCount().from(this.table).fetchOne(0, Int::class.java)!!
val list = this.joining(this.dsl.select().from(this.table))
val list = this.joining(this.dsl.select().from(this.table))
.offset(pageSpecs.index * pageSpecs.size)
.limit(pageSpecs.size)
.fetch(this::toModel)
Expand Down
1 change: 0 additions & 1 deletion backend/sql/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
spring.datasource.url=jdbc:postgresql://localhost:5432/ca
spring.datasource.username=su
spring.datasource.password=sekret

spring.liquibase.test-rollback-on-update=true
spring.liquibase.show-summary=verbose
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ databaseChangeLog:
name: id
type: char(36)
constraints:
primaryKey: true
primaryKey: true
- column:
name: locale
type: varchar(255)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ databaseChangeLog:
name: id
type: char(36)
constraints:
primaryKey: true
primaryKey: true
- column:
name: locale
type: varchar(255)
Expand Down

0 comments on commit a4a96a7

Please sign in to comment.