From 1bd18e123f9f7b89bb951a0bb2abcbb791d14067 Mon Sep 17 00:00:00 2001 From: Ahmad Shahwan Date: Wed, 17 Jul 2024 16:09:48 +0200 Subject: [PATCH] Move in-mem fixture to domain module * This is to allow unit tests in domain. --- backend/domain/pom.xml | 6 ++++ .../ca/fixtures}/inmem/InMemCrudRepository.kt | 2 +- .../inmem/food/InMemCourseRepository.kt | 4 +-- .../inmem/food/InMemCuisineRepository.kt | 4 +-- .../inmem/food/InMemDishRepository.kt | 4 +-- .../inmem/food/InMemServingRepository.kt | 4 +-- .../inmem/media/InMemImageRepository.kt | 4 +-- .../media/ImageRepositoryTestBase.kt} | 6 ++-- .../persistence/CrudRepositoryTestBase.kt} | 4 +-- .../inmem/media/InMemImageRepositoryTest.kt | 7 ++-- backend/inmem/pom.xml | 33 ------------------- backend/pom.xml | 1 - .../sql/media/SqlImageRepositoryTest.kt | 4 +-- 13 files changed, 28 insertions(+), 55 deletions(-) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/InMemCrudRepository.kt (97%) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/food/InMemCourseRepository.kt (70%) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/food/InMemCuisineRepository.kt (70%) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/food/InMemDishRepository.kt (69%) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/food/InMemServingRepository.kt (70%) rename backend/{inmem/src/main/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/fixtures}/inmem/media/InMemImageRepository.kt (70%) rename backend/domain/src/test/kotlin/co/digamma/ca/{media/ImageRepositoryTest.kt => suites/media/ImageRepositoryTestBase.kt} (78%) rename backend/domain/src/test/kotlin/co/digamma/ca/{persistence/CrudRepositoryTest.kt => suites/persistence/CrudRepositoryTestBase.kt} (94%) rename backend/{inmem/src/test/kotlin/co/digamma/ca/persistence => domain/src/test/kotlin/co/digamma/ca/tests}/inmem/media/InMemImageRepositoryTest.kt (69%) delete mode 100644 backend/inmem/pom.xml diff --git a/backend/domain/pom.xml b/backend/domain/pom.xml index 816d3ef..697f723 100644 --- a/backend/domain/pom.xml +++ b/backend/domain/pom.xml @@ -32,6 +32,12 @@ test-jar + + + co/digamma/ca/tests/** + co/digamma/ca/domain/internal/** + + diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/InMemCrudRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/InMemCrudRepository.kt similarity index 97% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/InMemCrudRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/InMemCrudRepository.kt index 4c7b0f1..a63f8e9 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/InMemCrudRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/InMemCrudRepository.kt @@ -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 diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCourseRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCourseRepository.kt similarity index 70% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCourseRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCourseRepository.kt index 3e9c856..79aefc5 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCourseRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCourseRepository.kt @@ -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(), CourseRepository \ No newline at end of file diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCuisineRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCuisineRepository.kt similarity index 70% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCuisineRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCuisineRepository.kt index 2ae8298..3bad3e6 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemCuisineRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemCuisineRepository.kt @@ -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(), CuisineRepository \ No newline at end of file diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemDishRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemDishRepository.kt similarity index 69% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemDishRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemDishRepository.kt index fedceef..6358d5d 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemDishRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemDishRepository.kt @@ -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(), DishRepository \ No newline at end of file diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemServingRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemServingRepository.kt similarity index 70% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemServingRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemServingRepository.kt index ac66cb0..b501f3a 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/food/InMemServingRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/food/InMemServingRepository.kt @@ -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(), ServingRepository \ No newline at end of file diff --git a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepository.kt b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/media/InMemImageRepository.kt similarity index 70% rename from backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepository.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/media/InMemImageRepository.kt index 0b12067..e90acb4 100644 --- a/backend/inmem/src/main/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepository.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/fixtures/inmem/media/InMemImageRepository.kt @@ -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(), ImageRepository \ No newline at end of file diff --git a/backend/domain/src/test/kotlin/co/digamma/ca/media/ImageRepositoryTest.kt b/backend/domain/src/test/kotlin/co/digamma/ca/suites/media/ImageRepositoryTestBase.kt similarity index 78% rename from backend/domain/src/test/kotlin/co/digamma/ca/media/ImageRepositoryTest.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/suites/media/ImageRepositoryTestBase.kt index 6196e78..e782c03 100644 --- a/backend/domain/src/test/kotlin/co/digamma/ca/media/ImageRepositoryTest.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/suites/media/ImageRepositoryTestBase.kt @@ -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() { +abstract class ImageRepositoryTestBase: CrudRepositoryTestBase() { abstract override val sut: ImageRepository diff --git a/backend/domain/src/test/kotlin/co/digamma/ca/persistence/CrudRepositoryTest.kt b/backend/domain/src/test/kotlin/co/digamma/ca/suites/persistence/CrudRepositoryTestBase.kt similarity index 94% rename from backend/domain/src/test/kotlin/co/digamma/ca/persistence/CrudRepositoryTest.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/suites/persistence/CrudRepositoryTestBase.kt index e04acbe..226d18b 100644 --- a/backend/domain/src/test/kotlin/co/digamma/ca/persistence/CrudRepositoryTest.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/suites/persistence/CrudRepositoryTestBase.kt @@ -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 @@ -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 { +abstract class CrudRepositoryTestBase { abstract fun newModel(): T abstract fun modifyModel(model: T): T abstract val sut: CrudRepository diff --git a/backend/inmem/src/test/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepositoryTest.kt b/backend/domain/src/test/kotlin/co/digamma/ca/tests/inmem/media/InMemImageRepositoryTest.kt similarity index 69% rename from backend/inmem/src/test/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepositoryTest.kt rename to backend/domain/src/test/kotlin/co/digamma/ca/tests/inmem/media/InMemImageRepositoryTest.kt index 204f01c..ad9698b 100644 --- a/backend/inmem/src/test/kotlin/co/digamma/ca/persistence/inmem/media/InMemImageRepositoryTest.kt +++ b/backend/domain/src/test/kotlin/co/digamma/ca/tests/inmem/media/InMemImageRepositoryTest.kt @@ -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() diff --git a/backend/inmem/pom.xml b/backend/inmem/pom.xml deleted file mode 100644 index a78f510..0000000 --- a/backend/inmem/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - - co.digamma.ca - cookalchemy-parent - 1.0-SNAPSHOT - - - cookalchemy-inmem - - - - co.digamma.ca - cookalchemy-domain - - - - org.jetbrains.kotlin - kotlin-stdlib - - - - co.digamma.ca - cookalchemy-domain - tests - test-jar - test - - - \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml index bffda2c..e606563 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -11,7 +11,6 @@ domain - inmem graphql app sql diff --git a/backend/sql/src/test/kotlin/co/digamma/ca/persistence/sql/media/SqlImageRepositoryTest.kt b/backend/sql/src/test/kotlin/co/digamma/ca/persistence/sql/media/SqlImageRepositoryTest.kt index 2e00061..81141f9 100644 --- a/backend/sql/src/test/kotlin/co/digamma/ca/persistence/sql/media/SqlImageRepositoryTest.kt +++ b/backend/sql/src/test/kotlin/co/digamma/ca/persistence/sql/media/SqlImageRepositoryTest.kt @@ -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) } \ No newline at end of file