{"id":16536797,"url":"https://github.com/eliasnogueira/wiremock-service-virtualization","last_synced_at":"2025-04-11T00:43:38.590Z","repository":{"id":147153820,"uuid":"282062247","full_name":"eliasnogueira/wiremock-service-virtualization","owner":"eliasnogueira","description":"Service Virtualization example using WireMock standalone with JSON files to map the request and responses and Docker to create a persistent container to enable the long-living service.","archived":false,"fork":false,"pushed_at":"2020-12-14T19:13:18.000Z","size":7,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T00:43:31.710Z","etag":null,"topics":["api-testing","containers","docker","service-virtualization","wiremock"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/eliasnogueira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-07-23T21:47:27.000Z","updated_at":"2024-06-19T16:45:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"421725c1-4123-49ba-bc69-c611f66d9c9b","html_url":"https://github.com/eliasnogueira/wiremock-service-virtualization","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fwiremock-service-virtualization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fwiremock-service-virtualization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fwiremock-service-virtualization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasnogueira%2Fwiremock-service-virtualization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliasnogueira","download_url":"https://codeload.github.com/eliasnogueira/wiremock-service-virtualization/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322604,"owners_count":21084336,"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":["api-testing","containers","docker","service-virtualization","wiremock"],"created_at":"2024-10-11T18:33:24.412Z","updated_at":"2025-04-11T00:43:38.585Z","avatar_url":"https://github.com/eliasnogueira.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wiremock Service Virtualization example\n\n## Basic explanation\nThis project explains how to create service virtualization using WireMock.\nWe have innumerable benefits using it, as:\n* provide an endpoint for not completed APIs\n* provide an API for the 3rd parties dependencies you can't control\n* when needed to be consumed from different perspectives (backend, frontend, test)\n\nThe main purpose here is to create a Docker image with all the mappings (request and responses) you can share across your team/company and use it in any test level without duplication and consuming it in one centralized point. E.g: integration, functional API test, etc...\n\n## What does this service virtualization do?\nFirst of all: this is a didact example. I know that this domain might be complex but I ask you to follow the basic example logic. \n\nThis simulates an account verification where we send two small deposits to an account. Later on, you need to add the amount of those two deposits to validate the process.\n\n### Sending the deposits\nYou must use the endpoint `POST /api/v1/check` with a specific IBAN (account number in Europe). The mapping will respond only if we send the expected IBAN, that is _NL13ABNA8672131290_\n\nYou must pass it in the body as a JSON object, like this:\n```json\n{\n  \"iban\": \"NL13ABNA8672131290\"\n}\n```\n\nIf you send a different, but valid IBAN format, the API will respond with a HTTP 404 and the following body\n```json\n{\n    \"message\": \"Account not found!\"\n}\n```\n\n### Verify the deposite\nWe are going to verify the accound filling in the deposits we have received to confirm the operation.\nYou must use the endpoint `POST /api/v1/verify` with the ID, account 1 and account 2 you have received when you sent the deposit\n\nYou must pass it in the body as a JSON object, like this:\n```json\n{\n  \"id\": \"b3e3541fd0577426d1d190cfc04d4d00\",\n  \"deposits\": {\n        \"first\": 0.06,\n        \"second\": 0.10\n    }\n}\n```\n\n\n## Steps to use this project\n\n### Pre-condition\n* You must have Docker installed in your machine\n\n### Steps\n1. Clone this project\n2. Open your Terminal/Command Prompt\n3. Go to the project folder\n4. Execute the following docker command to build and start the container\n```bash\ndocker-compose up --build\n```\n\nYou will see something like this:\n```\nBuilding wiremock\nStep 1/9 : FROM anapsix/alpine-java:8\n ---\u003e 745575fbfe52\nStep 2/9 : RUN apk add --update curl \u0026\u0026     rm -rf /var/cache/apk/*\n ---\u003e Using cache\n ---\u003e b54b1118f3ee\nStep 3/9 : ENV WM_PACKAGE wiremock\n ---\u003e Using cache\n ---\u003e b7694d2dd801\nStep 4/9 : ARG WM_VERSION=2.27.1\n ---\u003e Using cache\n ---\u003e 56d2a956525b\nStep 5/9 : RUN mkdir /$WM_PACKAGE\n ---\u003e Using cache\n ---\u003e 5f3214602a0b\nStep 6/9 : WORKDIR /$WM_PACKAGE\n ---\u003e Using cache\n ---\u003e e952c4744512\nStep 7/9 : RUN curl -sSL -o $WM_PACKAGE.jar https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.27.1/wiremock-standalone-2.27.1.jar\n ---\u003e Using cache\n ---\u003e 5dd98cc7d6ab\nStep 8/9 : EXPOSE 80\n ---\u003e Using cache\n ---\u003e b9f1c60c5d31\nStep 9/9 : ENTRYPOINT [\"java\",\"-jar\",\"wiremock.jar\",\"--verbose\", \"--port\", \"80\"]\n ---\u003e Using cache\n ---\u003e 7e00a72f527f\n\nSuccessfully built 7e00a72f527f\nSuccessfully tagged wiremock-custom:latest\nStarting wiremock-payment-gateway ... done\nAttaching to wiremock-payment-gateway\nwiremock-payment-gateway | 2020-07-23 18:52:17.753 Verbose logging enabled\nwiremock-payment-gateway | SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".\nwiremock-payment-gateway | SLF4J: Defaulting to no-operation (NOP) logger implementation\nwiremock-payment-gateway | SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\nwiremock-payment-gateway | 2020-07-23 18:52:18.813 Verbose logging enabled\nwiremock-payment-gateway |  /$$      /$$ /$$                     /$$      /$$                     /$$      \nwiremock-payment-gateway | | $$  /$ | $$|__/                    | $$$    /$$$                    | $$      \nwiremock-payment-gateway | | $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$\nwiremock-payment-gateway | | $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/\nwiremock-payment-gateway | | $$$$_  $$$$| $$| $$  \\__/| $$$$$$$$| $$  $$$| $$| $$  \\ $$| $$      | $$$$$$/ \nwiremock-payment-gateway | | $$$/ \\  $$$| $$| $$      | $$_____/| $$\\  $ | $$| $$  | $$| $$      | $$_  $$ \nwiremock-payment-gateway | | $$/   \\  $$| $$| $$      |  $$$$$$$| $$ \\/  | $$|  $$$$$$/|  $$$$$$$| $$ \\  $$\nwiremock-payment-gateway | |__/     \\__/|__/|__/       \\_______/|__/     |__/ \\______/  \\_______/|__/  \\__/\nwiremock-payment-gateway | \nwiremock-payment-gateway | port:                         80\nwiremock-payment-gateway | enable-browser-proxying:      false\nwiremock-payment-gateway | disable-banner:               false\nwiremock-payment-gateway | no-request-journal:           false\nwiremock-payment-gateway | verbose:                      true\nwiremock-payment-gateway | \n```\n\n## Testing\n\n### Check the account\nSend the following request\n```bash\ncurl -d '{\"iban\":\"NL13ABNA8672131290\"}' -H \"Content-Type: application/json\" -X POST http://localhost/api/v1/check\n```\n\nExpected result\n```json\n{\n    \"id\":\"b3e3541fd0577426d1d190cfc04d4d00\",\n    \"deposits\":{\n       \"first\":0.06,\n       \"second\":0.10\n    }\n }\n```\n\n### Verify the deposit\nSend the following request\n```bash\ncurl -d '{\"id\":\"b3e3541fd0577426d1d190cfc04d4d00\",\"deposits\":{\"first\": 0.06,\"second\": 0.10}}' -H \"Content-Type: application/json\" -X POST http://localhost/api/v1/verify\n```\n\nExpected result\n```json\n{\n    \"message\": \"Account verification completed!\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fwiremock-service-virtualization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliasnogueira%2Fwiremock-service-virtualization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasnogueira%2Fwiremock-service-virtualization/lists"}