From 04ce615eb4af3851a74ec645ee9adf0490a5b2c4 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 13 Feb 2021 22:20:35 -0500 Subject: [PATCH 1/3] =?UTF-8?q?`MixService.save(MixSaveDto)`=20utilise=20m?= =?UTF-8?q?aintenant=20le=20m=C3=A9thode=20MixTypeService.createForNameAnd?= =?UTF-8?q?MaterialType(String,=20MaterialType)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La méthode utilisait directement le constructeur de MixType, qui ne vérifie pas les conflits de nom avec les Materials existants, d'où l'erreur de contrainte unique. Le test de la méthode est ajuster pour vérifier l'utilisation de la méthode adéquate. --- .../kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt | 2 +- .../fyloz/trial/colorrecipesexplorer/service/MixService.kt | 2 +- src/main/resources/application-h2.properties | 4 ++-- .../trial/colorrecipesexplorer/service/MixServiceTest.kt | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt index 1c75639..0b9f74a 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/model/Mix.kt @@ -26,7 +26,7 @@ data class Mix( @ManyToOne val recipe: Recipe, - @ManyToOne(cascade = [CascadeType.PERSIST]) + @ManyToOne var mixType: MixType, @OneToMany(cascade = [CascadeType.ALL]) diff --git a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt index f4717f7..98fbb08 100644 --- a/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt +++ b/src/main/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixService.kt @@ -33,7 +33,7 @@ class MixServiceImpl( override fun save(entity: MixSaveDto): Mix { val recipe = recipeService.getById(entity.recipeId) val materialType = materialTypeService.getById(entity.materialTypeId) - val mixType = MixType(entity.name, materialType) + val mixType = mixTypeService.createForNameAndMaterialType(entity.name, materialType) var mix = save(mix(recipe = recipe, mixType = mixType)) val mixMaterials = diff --git a/src/main/resources/application-h2.properties b/src/main/resources/application-h2.properties index 33d00af..346ad2a 100644 --- a/src/main/resources/application-h2.properties +++ b/src/main/resources/application-h2.properties @@ -1,5 +1,5 @@ -#spring.datasource.url=jdbc:h2:mem:cre -spring.datasource.url=jdbc:h2:file:./workdir/recipes +spring.datasource.url=jdbc:h2:mem:cre +#spring.datasource.url=jdbc:h2:file:./workdir/recipes spring.datasource.username=sa spring.datasource.password=LWK4Y7TvEbNyhu1yCoG3 spring.h2.console.path=/dbconsole diff --git a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt index 79f13fd..405752b 100644 --- a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt +++ b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt @@ -56,6 +56,7 @@ class MixServiceTest : AbstractExternalModelServiceTest Date: Sun, 14 Feb 2021 01:52:09 -0500 Subject: [PATCH 2/3] =?UTF-8?q?Copie=20les=20r=C3=A9sultats=20des=20tests?= =?UTF-8?q?=20dans=20after=5Fscript=20pour=20les=20avoir=20en=20cas=20de?= =?UTF-8?q?=20tests=20qui=20fail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 817a739..4ca50a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,8 +30,8 @@ test: TEST_CONTAINER_NAME: "cre_backend_gradle_tests-$CI_COMMIT_REF_NAME" script: - docker run --name $TEST_CONTAINER_NAME $CI_REGISTRY_IMAGE_GRADLE gradle test - - mkdir test-results && docker cp $TEST_CONTAINER_NAME:/usr/src/cre/build/test-results/test/ test-results after_script: + - mkdir test-results && docker cp $TEST_CONTAINER_NAME:/usr/src/cre/build/test-results/test/ test-results - docker rm $TEST_CONTAINER_NAME artifacts: when: always From 1f6ceff75282c2be815fdcb93fff73d952ac946c Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sun, 14 Feb 2021 11:57:43 -0500 Subject: [PATCH 3/3] Correction du Test MixServiceTest.SaveDto.`calls and returns save() with the created entity`() --- .../fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt index 405752b..3bdc9ad 100644 --- a/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt +++ b/src/test/kotlin/dev/fyloz/trial/colorrecipesexplorer/service/MixServiceTest.kt @@ -68,7 +68,7 @@ class MixServiceTest : AbstractExternalModelServiceTest