Skip to content

Commit

Permalink
Move in-mem fixture to domain module
Browse files Browse the repository at this point in the history
* This is to allow unit tests in domain.
  • Loading branch information
ahmadshahwan committed Jul 17, 2024
1 parent 25babb8 commit 50e5bd0
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 55 deletions.
5 changes: 5 additions & 0 deletions backend/domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<goals>
<goal>test-jar</goal>
</goals>
<configuration>
<excludes>
<exclude>co/digamma/ca/tests/inmem/media/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.digamma.ca.persistence.inmem
package co.digamma.ca.fixtures.inmem

import co.digamma.ca.domain.api.Page
import co.digamma.ca.domain.api.PageSpecs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.digamma.ca.persistence.inmem.food
package co.digamma.ca.fixtures.inmem.food

import co.digamma.ca.domain.api.common.stereotypes.Singleton
import co.digamma.ca.domain.api.food.Course
import co.digamma.ca.domain.spi.food.CourseRepository
import co.digamma.ca.persistence.inmem.InMemCrudRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemCourseRepository: InMemCrudRepository<Course>(), CourseRepository
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.digamma.ca.persistence.inmem.food
package co.digamma.ca.fixtures.inmem.food

import co.digamma.ca.domain.api.common.stereotypes.Singleton
import co.digamma.ca.domain.api.food.Cuisine
import co.digamma.ca.domain.spi.food.CuisineRepository
import co.digamma.ca.persistence.inmem.InMemCrudRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemCuisineRepository: InMemCrudRepository<Cuisine>(), CuisineRepository
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.digamma.ca.persistence.inmem.food
package co.digamma.ca.fixtures.inmem.food

import co.digamma.ca.domain.api.common.stereotypes.Singleton
import co.digamma.ca.domain.api.food.Dish
import co.digamma.ca.domain.spi.food.DishRepository
import co.digamma.ca.persistence.inmem.InMemCrudRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemDishRepository: InMemCrudRepository<Dish>(), DishRepository
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.digamma.ca.persistence.inmem.food
package co.digamma.ca.fixtures.inmem.food

import co.digamma.ca.domain.api.common.stereotypes.Singleton
import co.digamma.ca.domain.api.food.Serving
import co.digamma.ca.domain.spi.food.ServingRepository
import co.digamma.ca.persistence.inmem.InMemCrudRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemServingRepository: InMemCrudRepository<Serving>(), ServingRepository
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package co.digamma.ca.persistence.inmem.media
package co.digamma.ca.fixtures.inmem.media

import co.digamma.ca.domain.api.common.stereotypes.Singleton
import co.digamma.ca.domain.api.media.Image
import co.digamma.ca.domain.spi.media.ImageRepository
import co.digamma.ca.persistence.inmem.InMemCrudRepository
import co.digamma.ca.fixtures.inmem.InMemCrudRepository

@Singleton
class InMemImageRepository: InMemCrudRepository<Image>(), ImageRepository
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package co.digamma.ca.media
package co.digamma.ca.suites.media

import co.digamma.ca.domain.api.media.Image
import co.digamma.ca.domain.spi.media.ImageRepository
import co.digamma.ca.persistence.CrudRepositoryTest
import co.digamma.ca.suites.persistence.CrudRepositoryTestBase
import java.util.Locale
import java.util.UUID

abstract class ImageRepositoryTest: CrudRepositoryTest<Image>() {
abstract class ImageRepositoryTestBase: CrudRepositoryTestBase<Image>() {

abstract override val sut: ImageRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package co.digamma.ca.persistence
package co.digamma.ca.suites.persistence

import co.digamma.ca.domain.api.common.DuplicateKeyException
import co.digamma.ca.domain.api.common.NotFoundException
Expand All @@ -7,7 +7,7 @@ import co.digamma.ca.domain.spi.CrudRepository
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test

abstract class CrudRepositoryTest<T : Model> {
abstract class CrudRepositoryTestBase<T : Model> {
abstract fun newModel(): T
abstract fun modifyModel(model: T): T
abstract val sut: CrudRepository<T>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package co.digamma.ca.persistence.inmem.media
package co.digamma.ca.tests.inmem.media

import co.digamma.ca.domain.api.media.Image
import co.digamma.ca.media.ImageRepositoryTest
import co.digamma.ca.fixtures.inmem.media.InMemImageRepository
import co.digamma.ca.suites.media.ImageRepositoryTestBase
import java.util.Locale

class InMemImageRepositoryTest : ImageRepositoryTest() {
class InMemImageRepositoryTest : ImageRepositoryTestBase() {

override val sut = InMemImageRepository()

Expand Down
33 changes: 0 additions & 33 deletions backend/inmem/pom.xml

This file was deleted.

1 change: 0 additions & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

<modules>
<module>domain</module>
<module>inmem</module>
<module>graphql</module>
<module>app</module>
<module>sql</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package co.digamma.ca.persistence.sql.media

import co.digamma.ca.media.ImageRepositoryTest
import co.digamma.ca.suites.media.ImageRepositoryTestBase
import org.jooq.DSLContext
import org.junit.jupiter.api.extension.ExtendWith


@ExtendWith(PostgreSQLContainerExtension::class)
class SqlImageRepositoryTest(dsl: DSLContext): ImageRepositoryTest() {
class SqlImageRepositoryTest(dsl: DSLContext) : ImageRepositoryTestBase() {

override val sut = SqlImageRepository(dsl)
}

0 comments on commit 50e5bd0

Please sign in to comment.