{"id":27128170,"url":"https://github.com/redfroggy/spring-cucumber-messaging","last_synced_at":"2025-04-07T18:35:53.797Z","repository":{"id":39058290,"uuid":"339666692","full_name":"RedFroggy/spring-cucumber-messaging","owner":"RedFroggy","description":"Test your messaging system with Spring, Spring cloud, Cucumber and Gherkin !","archived":false,"fork":false,"pushed_at":"2025-04-02T18:18:08.000Z","size":130,"stargazers_count":0,"open_issues_count":12,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T19:26:53.638Z","etag":null,"topics":["cucumber","gherkin","java","jsonpath","spring","spring-cloud"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedFroggy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-17T09:10:37.000Z","updated_at":"2021-08-13T09:20:46.000Z","dependencies_parsed_at":"2023-12-31T19:24:28.581Z","dependency_job_id":"e7be2719-fa01-45ff-b3cc-6653ca90ea94","html_url":"https://github.com/RedFroggy/spring-cucumber-messaging","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedFroggy%2Fspring-cucumber-messaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedFroggy%2Fspring-cucumber-messaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedFroggy%2Fspring-cucumber-messaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedFroggy%2Fspring-cucumber-messaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedFroggy","download_url":"https://codeload.github.com/RedFroggy/spring-cucumber-messaging/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247707949,"owners_count":20982879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cucumber","gherkin","java","jsonpath","spring","spring-cloud"],"created_at":"2025-04-07T18:35:52.913Z","updated_at":"2025-04-07T18:35:53.789Z","avatar_url":"https://github.com/RedFroggy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test your messaging system with Spring, Cucumber and Gherkin !\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca name=\"logo\" href=\"https://www.redfroggy.fr\"\u003e\u003cimg src=\"assets/logo.png\" alt=\"RedFroggy\"\u003e\u003c/a\u003e\n  \u003ch4 align=\"center\"\u003eA RedFroggy project\u003c/h4\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://forthebadge.com\"\u003e\u003cimg src=\"https://forthebadge.com/images/badges/fuck-it-ship-it.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://forthebadge.com\"\u003e\u003cimg src=\"https://forthebadge.com/images/badges/built-with-love.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://forthebadge.com\"\u003e\u003cimg src=\"https://forthebadge.com/images/badges/made-with-java.svg\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n   \u003ca href=\"https://maven-badges.herokuapp.com/maven-central/fr.redfroggy.test.bdd/ucumber-messaging\"\u003e\u003cimg src=\"https://maven-badges.herokuapp.com/maven-central/fr.redfroggy.test.bdd/cucumber-messaging/badge.svg?style=plastic\" /\u003e\u003c/a\u003e\n   \u003ca href=\"https://travis-ci.com/RedFroggy/spring-cucumber-messaging\"\u003e\u003cimg src=\"https://travis-ci.com/RedFroggy/spring-cucumber-messaging.svg?branch=master\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://codecov.io/gh/RedFroggy/spring-cucumber-messaging\"\u003e\u003cimg src=\"https://codecov.io/gh/RedFroggy/spring-cucumber-messaging/branch/master/graph/badge.svg?token=XM9R6ZV9SJ\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://github.com/semantic-release/semantic-release\"\u003e\u003cimg src=\"https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\"/\u003e\u003c/a\u003e\n   \u003ca href=\"https://opensource.org/licenses/mit-license.php\"\u003e\u003cimg src=\"https://badges.frapsoft.com/os/mit/mit.svg?v=103\"/\u003e\u003c/a\u003e \n\u003c/div\u003e\n\u003cbr/\u003e\n\u003cbr/\u003e\n\nMade with Spring, [Cucumber](https://cucumber.io/) and [Gherkin](https://cucumber.io/docs/gherkin/) !\n\u003cbr/\u003e\nTo test your REST API with cucumber, gherkin please use this [library](https://github.com/RedFroggy/spring-cucumber-rest-api)\n\n## Stack\n- Spring Boot / Spring cloud\n- Cucumber / Gherkin\n- Jayway JsonPath\n\n## Installation\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003efr.redfroggy.test.bdd\u003c/groupId\u003e\n  \u003cartifactId\u003ecucumber-messaging\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/fr.redfroggy.test.bdd/cucumber-messaging/badge.svg)](https://maven-badges.herokuapp.com/maven-central/fr.redfroggy.test.bdd/cucumber-messaging)\n\nRun `npm install` to add commitlint + husky\n\n## Example\n\n```gherkin\n@user @messaging\nFeature: Users messaging tests\n\n  Background:\n    Given I set contentType queue message header to application/json\n\n  Scenario: Should valid user\n    When I mock third party call GET /public/characters/2?sessionId=43233333 with return code 200 and body: {\"comicName\": \"IronMan\", \"city\": \"New York\", \"mainColor\": [\"red\", \"yellow\"]}\n    And I set queue message body to {\"id\": \"2\",\"firstName\":\"Bruce\",\"lastName\":\"Wayne\",\"age\":\"50\", \"sessionIds\": [\"43233333\", \"45654345\"]}\n    And I set queue message body path $.age to 51\n    And I set X_TOKEN_ID queue message header to 1234\n    And I PUSH to queue input-valid-user\n    And I POLL first message from queue output-valid-user\n    Then queue message body should be valid json\n    And queue message body should contain Wayne\n    And queue message body path $.id should exist\n    And queue message body path $.relatedTo should not exist\n    And queue message body path $.status should not be INVALID\n    And queue message body path $.status should be VALID\n    And queue message body path $.firstName should be Bruce\n    And queue message body path $.lastName should be Wayne\n    And queue message body path $.age should be 51\n    And queue message body is typed as array for path $.sessionIds\n    And queue message body is typed as array using path $.sessionIds with length 2\n    And queue message body path $.sessionIds should be [\"43233333\", \"45654345\"]\n    And queue message body path $.sessionIds should not be []\n    And queue message header contentType should not be application/xml\n    And queue message header X_TOKEN_ID should exist\n    And queue message header X_TOKEN_ID should be 1234\n    And I store the value of queue message header X_TOKEN_ID as tokenId in scenario scope\n    And I store the value of queue message path $.sessionIds.[0] as firstSessionId in scenario scope\n\n  Scenario: Should valid user using json file as body\n    Given I mock third party call GET /public/characters/15948349393 with return code 200, content type: application/json and file: fixtures/bruce_wayne_marvel_api.fixture.json\n    When I set queue message body with file fixtures/bruce-banner.user.json\n    And I PUSH to queue input-valid-user\n    And I POLL first message from queue output-valid-user\n    Then queue message body should be valid json\n    And queue message body path $.firstName should be Bruce\n    And queue message body path $.lastName should be Banner\n\n  Scenario: Should not be able to read multiple times from queue when polling\n    When I mock third party call GET /public/characters/2 with return code 200 and body: {\"comicName\": \"IronMan\", \"city\": \"New York\", \"mainColor\": [\"red\", \"yellow\"]}\n    And I set queue message body to {\"id\": \"2\",\"firstName\":\"Bruce\",\"lastName\":\"Wayne\",\"age\":\"50\", \"sessionIds\": [`$firstSessionId`]}\n    And queue value of scenario variable tokenId should be 1234\n    And I set  X_TOKEN_ID queue message header to `$tokenId`\n    And I PUSH to queue input-valid-user\n    And I POLL first message from queue output-valid-user\n    Then queue message body path $.status should be VALID\n    And queue message header X_TOKEN_ID should be 1234\n    And queue value of scenario variable firstSessionId should be 43233333\n    When I POLL first message from queue output-valid-user\n    And queue should have 0 messages left\n\n  Scenario: Should be able to read multiple times from queue when peeking\n    When I mock third party call GET /public/characters/2 with return code 200 and body: {\"comicName\": \"IronMan\", \"city\": \"New York\", \"mainColor\": [\"red\", \"yellow\"]}\n    And I set queue message body to {\"id\": \"2\",\"firstName\":\"Bruce\",\"lastName\":\"Wayne\",\"age\":\"50\"}\n    And I PUSH to queue input-valid-user\n    And I PEEK first message from queue output-valid-user\n    Then queue message body path $.status should be VALID\n    When I PEEK first message from queue output-valid-user\n    And queue should have 1 messages left\n    Then queue message body path $.status should be VALID\n    And queue message header X_TOKEN_ID should not exist\n\n```\n\n\nYou can look at the [users.feature](src/test/resources/features/users.feature) file for a more detailed example.\n\n## Share data between steps\n- You can use the following step to store data from a json response body to a shared context:\n```gherkin\nAnd I store the value of queue message path $.id as idUser in scenario scope\n```\n- You can use the following step to store data from a response header to a shared context:\n```gherkin\nAnd I store the value of queue message header Authorization as authHeader in scenario scope\n```\n- The result of the JsonPath `$.id` will be stored in the `idUser` variable.\n- To reuse this variable in another step, you can do:\n```gherkin\nWhen I PUSH to queue valid-user`$idUser`\nAnd I set X-USER-ID queue message header to `$idUser`\n```\n\n\n## How to use it in my existing project ?\n\nYou can see a usage example in the [test folder](src/test/java/fr/redfroggy/bdd/messaging).\n\n### Add a CucumberTest  file\n\n```java\n@RunWith(Cucumber.class)\n@CucumberOptions(\n        plugin = {\"pretty\"},\n        features = \"src/test/resources/features\",\n        glue = {\"fr.redfroggy.bdd.messaging.glue\"})\npublic class CucumberTest {\n\n}\n````\n- Set the glue property to  `fr.redfroggy.bdd.messaging.glue` and add your package glue.\n- Set your `features` folder property\n- Add your `.feature` files under your `features` folder\n- In your `.feature` files you should have access to all the steps defined in the [MessagingBddStepDefinition](src/main/java/fr/redfroggy/bdd/messaging/glue/MessagingBddStepDefinition.java) file.\n\n\n### Add default step definition file\nIt is mandatory to have a class annotated with `@CucumberContextConfiguration` to be able to run the tests.\nThis class must be in the same `glue` package that you've specified in the `CucumberTest` class.\n\n```java\n@CucumberContextConfiguration\n@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\npublic class DefaultStepDefinition {\n\n}\n````\n\n## Mock third party call\nIf you need to mock a third party API, you can use the following steps:\n\n```gherkin\nI mock third party call (.*) (.*) with return code (.*), content type: (.*) and body: (.*)\n  # Example: I mock third party call GET /public/characters/1?format=json with return code 200, content type: application/json and body: {\"comicName\": \"IronMan\", \"city\": \"New York\", \"mainColor\": [\"red\", \"yellow\"]}\nI mock third party call (.*) (.*) with return code (.*), content type: (.*) and file: (.*)\n  # Example: I mock third party call GET /public/characters/2 with return code 200, content type: application/json and file: fixtures/bruce_wayne_marvel_api.fixture.json\n```\n\nIt relies on [WireMock](http://wiremock.org) for stubbing api calls.\nBy default, the wiremock port is `8888`, if you need to override it you need to change the\n`redfroggy.cucumber.restapi.wiremock.port` property in your project.\n\n## Run local unit tests\n\n````bash\n$ mvn test\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredfroggy%2Fspring-cucumber-messaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredfroggy%2Fspring-cucumber-messaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredfroggy%2Fspring-cucumber-messaging/lists"}