diff --git a/src/test/kotlin/feature/FollowSteps.kt b/src/test/kotlin/feature/FollowSteps.kt new file mode 100644 index 0000000..fe3398e --- /dev/null +++ b/src/test/kotlin/feature/FollowSteps.kt @@ -0,0 +1,21 @@ +package feature + +import fr.dcproject.entity.ArticleRef +import fr.dcproject.entity.Follow +import fr.dcproject.utils.toUUID +import io.cucumber.java8.En +import org.koin.test.KoinTest +import org.koin.test.get +import fr.dcproject.repository.Citizen as CitizenRepository +import fr.dcproject.repository.FollowArticle as FollowArticleRepository + +class FollowSteps : En, KoinTest { + init { + Given("The citizen {word} {word} follow article {string}") { firstName: String, lastName: String, articleId: String -> + val username = "$firstName-$lastName".toLowerCase() + val citizen = get().findByUsername(username) ?: error("Citizen not exist") + val follow = Follow(createdBy = citizen, target = ArticleRef(articleId.toUUID())) + get().follow(follow) + } + } +} \ No newline at end of file diff --git a/src/test/resources/feature/follow.feature b/src/test/resources/feature/follow.feature index 20407fc..49fd9ed 100644 --- a/src/test/resources/feature/follow.feature +++ b/src/test/resources/feature/follow.feature @@ -1,3 +1,4 @@ +@follow Feature: follow Article and Constitution # Article @@ -37,3 +38,13 @@ Feature: follow Article and Constitution Given I am authenticated as John Doe with id "64b7b379-2298-43ec-b428-ba134930cabd" When I send a DELETE request to "/constitutions/72aa1ee1-4963-eb44-c9e0-5ce6e0f18f00/follow" Then the response status code should be 204 + + Scenario: I can know if I follow an article + Given I have article with id "3ee4e6d0-f312-4940-872d-1f578c8d824c" + And I have citizen Marie Curie + And I am authenticated as Marie Curie + And The citizen Marie Curie follow article "3ee4e6d0-f312-4940-872d-1f578c8d824c" + When I send a GET request to "/articles/3ee4e6d0-f312-4940-872d-1f578c8d824c/follows" + Then the response status code should be 200 + And the JSON should contain: + | target.id | 3ee4e6d0-f312-4940-872d-1f578c8d824c |