2

I want to set-up mountebank for the end-point /trends?param1=PT-31. Following is the way, I am setting up the predicates in the imposter. However, there does not seem to be a match and I do not get a response.

What am I missing?

        "predicates": [
            {
                "and": [
                    {
                        "deepEquals": {
                            "path": "/trends",
                            "query": {
                                "param1" : [
                                    "PT-31", "PT-32"
                                ]
                            },
                            "method": "GET",
                            "headers": {
                                "Content-Type": "application/json"
                            }
                        }
                    }
                ]
            }
        ]
cogitoergosum
  • 2,309
  • 4
  • 38
  • 62

1 Answers1

3

It looks like your problem is you are requiring two params in your predicate - PT-31 and PT-32 - which would match a path of /trends?param1=PT-31&param1=PT32 but not /trends?param1=PT-31.

A couple other suggestions, in the hopes that they're useful:

  • Because you're using deepEquals, it won't even match /trends?param1=PT-31&param1=PT-32&param1=PT-33. It requires an exact match. If you want to be a bit more flexible, I'd suggest using equals instead
  • The outermost "and" predicate is unnecessary. All predicates within a single operator (the "deepEquals") are automatically ANDed together.
bbyars
  • 406
  • 3
  • 3
  • Got it, thanks! Any thoughts on how to match _either_ of `PT-31` and `PT-32` for `param1`? – cogitoergosum Apr 11 '18 at 16:40
  • 1
    Yes, that's what the "or" predicate is, so it'd be something like this: { "or": [ { "equals": { "query": { "param1": "PT-31" } } }, { "equals": { "query": { "param1": "PT-32" } } } ] } – bbyars Apr 12 '18 at 18:23