wiremock / wiremock-state-extension

Adds support for transporting state across different API mock stubs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for modeling queues and lists

dirkbolte opened this issue · comments

Proposal

Reported by: @ioanngolovko

In order to support modeling collections and messaging queues a new data container should be added. The current approach only has one state with CRUD operations. Adding a dynamic list is challenging.

Idea is to add a new container: list. The syntax can look like this:

  • serveEventListeners
    • recordState
    {
      "context": "...",
      "list": {
        "addLast": {
          "stateValue": "..."
        },
        "addFirst": {
          "stateValue": "..."
        }
      }
    • deleteState
      {
        "context": "...",
        "list": {
          "deleteFirst": true,
          "deleteLast": true,
          "deleteIndex": 1,
          "deleteWhere": {
            "property": "...",
            "value": "...",
      }
  • response
    {
     "jsonBody": {
        "id": "{{state context=... list.last='id'}}",
        "firstName": "{{state context=... list.first='firstName'}}",
        "lastName": "{{state context=... list.[1]='lastName'}}"
      }
    }

Templating will be supported for all values.

References

No response

Syntax for recordState and deleteState is as described.

For Response Templating, the syntax had to be adapted:

{
 "jsonBody": {
    "id": "{{state context=... list.last='id'}}",
    "firstName": "{{state context=... list='[0].firstName'}}",
    "lastName": "{{state context=... list='[-1].lastName'}}"
  }
}

merged