Class MountebankImporter

java.lang.Object
org.mockserver.imports.MountebankImporter

public class MountebankImporter extends Object
Imports MockServer expectations from Mountebank imposter JSON.

Accepts a single imposter object, a { "imposters": [ ... ] } wrapper (the mb config file / GET /imposters?replayable=true format), or a bare JSON array of imposters. Only http/https imposters are mapped — tcp/smtp imposters are skipped with a per-imposter ImportWarning.

Mapping

  • Predicates (equals/deepEquals/contains/matches/ exists/startsWith/endsWith) over the method, path, query, headers and body request fields become MockServer matchers; all predicates in a stub are AND-combined into one request matcher.
  • is responses become HttpResponses (statusCode/headers/body).
  • proxy responses become HttpForwards (to host/port/scheme).
  • A response fault becomes an HttpError.
  • _behaviors.wait becomes a response delay; _behaviors.repeat is reported as an ImportWarning and otherwise dropped — a Mountebank single response wraps and is served indefinitely, so a Times.exactly(N) constraint would wrongly make the stub 404 after N matching requests.
  • A stub with multiple is responses becomes one sequential/cycling multi-response expectation; mixed or non-is multi-response stubs fall back to the first response with a warning.

Compound predicates (and/or/not), JavaScript inject responses, and post-processing behaviours (decorate/copy/lookup/shellTransform) have no MockServer equivalent and are reported as ImportWarnings.