/* ******************
Mock data
*****************
187264
static List<ListItem> createItemsV1(Context context) {
        final List<ListItem> items = new ArrayList<>();
        final Painting[] paintings = Painting.list(context.getResources());

        items.add(new ListItem("Donec sem arcu, feugiat sit amet purus ut, cursus tristique"
                + " justo. Quisque eu ligula sed massa tristique elementum eu vel augue."));
        items.add(new ListItem(paintings[0], paintings[1]));
        items.add(new ListItem(paintings[2]));
        items.add(new ListItem("Vivamus orci nulla, euismod ac purus id, porttitor vulputate"
                + " purus. Proin at aliquam justo. Integer eget eros vitae metus ornare lacinia eu"
                + " sit amet justo. Integer aliquam sit amet diam ac laoreet. Cras tincidunt dolor"
                + " ut nisl aliquet."));
        items.add(new ListItem("Nulla sed eleifend quam"));
        items.add(new ListItem(paintings[3], paintings[4]));
        items.add(new ListItem("Suspendisse dignissim pretium nisi nec tincidunt. In ut"
                + " finibus arcu. Nunc pretium purus a eros convallis finibus. Vestibulum eleifend"
                + " efficitur arcu, ut fringilla lorem molestie nec."));
        items.add(new ListItem(paintings[0]));
        items.add(new ListItem(paintings[1], paintings[2]));
        return items;
    }
738365
function mockDB() {
  if (!mocked) {
    defaultController = Parse.CoreManager.getRESTController();
    mocked = true;
    Parse.CoreManager.setRESTController(MockRESTController);
  }
}
658790
function isMatch(config, mock) {
		if (angular.isFunction(mock)) {
			return !!mock(config.method, config.url, config.params, config.data, config.headers);
		}
		mock = mock || {};
		var fail = false;
		if (mock.method) {
			fail = fail || (config.method ? config.method.toLowerCase() : 'get') != mock.method.toLowerCase();
		}
		if (mock.url && angular.isString(config.url) && angular.isString(mock.url)) {
			fail = fail || config.url.split('?')[0] != mock.url.split('?')[0];
		}
		if (mock.params || angular.isString(config.url) && config.url.split('?')[1]) {
			var configParams = angular.extend(queryParams(config.url.split('?')[1]), config.params);
			var mockParams = angular.isString(mock.url) ? queryParams(mock.url.split('?')[1]) : {};
			mockParams = angular.extend(mockParams, mock.params);
			fail = fail || !angular.equals(configParams, mockParams);
		}
		if (mock.data) {
			fail = fail || !angular.equals(config.data, mock.data);
		}
		// Header props can be functions
		if (mock.headers) {
			var headers = {};
			angular.forEach(config.headers, function(value, key) {
				if (angular.isFunction(value)) {
					value = value(config);
				}
				if (value) {
					headers[key] = value;
				}
			});
			fail = fail || !angular.equals(headers, mock.headers);
		}
		return !fail;
	}
795275
function(data, done) {
      this._data.push(this._clone(data));
      var ret = this._data.length;
      done(null, ret);
    }
915058
function (config, mockSrc, defaultScenario, filenames,
      scenarioName) {
    // read mock data files for this scenario
    var scenario = filenames.map(function (filename) {
      var filepath = fs.realpathSync(path.join(mockSrc, filename));

      return {
        scenarioName: scenarioName,
        filename: filename,
        scenario: require(filepath)
      };
    });

    return scenario;
  }
679566
function mock_fsmerge( & $fs, & $comp) {
		if (isset($comp['%type']) && $comp['%type'] == 'file') {
			throw new \Exception('[Mock] Tried to copy file as directory.');
		}

		// map existing files
		$existing_files = [];
		foreach ($fs as $node => $file) {
			if (is_integer($node)) {
				$existing_files[] = $file['filename'];
			}
		}

		// merge
		foreach ($comp as $node => $file) {
			if (is_integer($node)) {
				if (in_array($file['filename'], $existing_files)) {
					throw new \Exception("[Mock] Tried to overwrite file: {$file['filename']}");
				}
				$fs[] = $file;
			}
			else if ($node[0] == '%') { // attribute
				$fs[$node] = $file;
			}
			else { // dir
				isset($fs[$node]) or $fs[$node] = [];
				$this->mock_fsmerge($fs[$node], $file);
			}
		}
	}
250114
def post_mockdata_url(service_name, implementation_name,
                      url, headers, body,
                      dir_base=dirname(__file__)):
    
    # Currently this post method does not return a response body
    response = MockHTTP()
    if body is not None:
        if "dispatch" in url:
            response.status = 200
        else:
            response.status = 201
        response.headers = {"X-Data-Source": service_name + " file mock data",
                            "Content-Type": headers['Content-Type']}
    else:
        response.status = 400
        response.data = "Bad Request: no POST body"
    return response
916383
@Override
	public void setData(final byte[] data, final int offset)
	{
		if (offset < 0 || offset > data.length)
			throw new KNXIllegalArgumentException("illegal offset " + offset);
		toDPT(data, offset);
	}
420189
public static function mock(array $userData = []): self
    {
        $data = \array_merge([
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'REQUEST_METHOD'       => 'GET',
            'SCRIPT_NAME'          => '',
            'REQUEST_URI'          => '',
            'QUERY_STRING'         => '',
            'SERVER_NAME'          => 'localhost',
            'SERVER_PORT'          => 80,
            'HTTP_HOST'            => 'localhost',
            'HTTP_ACCEPT'          => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8',
            'HTTP_ACCEPT_CHARSET'  => 'utf-8;q=0.7,*;q=0.3',
            'HTTP_USER_AGENT'      => 'MY Framework',
            'REMOTE_ADDR'          => '127.0.0.1',
            'REQUEST_TIME'         => \time(),
            'REQUEST_TIME_FLOAT'   => \microtime(true),
        ], $userData);

        return new static($data);
    }
1280658
function mockServer(app) {
        const jsonRouter = jsonServer.router(db);

        const shouldMockReq = req => {
          return (
            req.method !== "GET" ||
            (req.headers.accept &&
              req.headers.accept.indexOf("application/json") !== -1)
          );
        };

        if (serverOpts.delay) {
          app.use((req, res, next) => {
            if (shouldMockReq(req)) {
              return pause(serverOpts.delay)(req, res, next);
            }
            return next();
          });
        }

        app.use(jsonServer.rewriter(rewrites));

        // user defined routers
        app.use(jsonServer.bodyParser);

        // user query normalizr
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            req.query = toJsonServer(req.query);
            return next();
          }
          return next();
        });

        routers.forEach(router => app.use(router));

        // json server router
        app.use((req, res, next) => {
          if (shouldMockReq(req)) {
            return jsonRouter(req, res, next);
          }
          return next();
        });

        return app;
      }
236695
function loadMockDbQuery (mockData, options) {
    // get stable id for http request data with non-deterministic properites removed
    try {
        var stableId = dbQueryStableId(mockData.data)
    }
    // catch errors if ignore option is set
    catch (ex) {
        if (options.ignoreInvalidMockData) {
            return
        }
        else {
            throw new Error('automock error: invalid mock data')
        }
    }
    // store moduleCall data keyed by stable id
    immutableAutomock.dbQueryMocks[stableId] = mockData.data
}
1301920
function ExpectedRequest(method, path, data) {
    this.method = method;
    this.path = path;
    this.data = data;
    this.response = null;
    this.checks = [];
}
440390
function mockTimeout() {
  var events = [];
  var id = 0;
  var now = 0;

  return {
    mocks: {setTimeout: mockSetTimeout, clearTimeout: mockClearTimeout},
    flush: flush, get pending() { return events.length; }
  };

  function mockSetTimeout(fn, delay) {
    delay = delay || 0;
    events.push({time: now + delay, fn: fn, id: id});
    events.sort(function(a, b) { return a.time - b.time; });
    return id++;
  }

  function mockClearTimeout(id) {
    for (var i = 0; i < events.length; ++i) {
      if (events[i].id === id) {
        events.splice(i, 1);
        break;
      }
    }
  }

  function flush(delay) {
    if (delay !== undefined)
      now += delay;
    else if (events.length)
      now = events[events.length - 1].time;
    else
      throw new Error('No timer events registered');

    while (events.length && events[0].time <= now) {
      events.shift().fn();
    }
  }
}
300326
public function mock($options = array())
    {
        $this->mockedData = $options;

        if (empty($this->mockedData) || !is_array($this->mockedData)) {
            $this->mockedData = array();
        }
    }
982114
private static Data checkData(final Data data) {
		if (Data.EMPTY.equals(data)) {
			throw new IllegalStateOfArgumentException("Argument 'data' must not be empty.");
		}
		return data;
	}
1265844
function mock (context, router, dataStore) {
  router = router || context.router;
  dataStore = (dataStore instanceof DataStore) ? dataStore : new MemoryDataStore();
  let isDisabled = _.noop;

  if (util.isExpressApp(router)) {
    // Store the DataStore as an Express setting, so it can be accessed/changed by third-party code
    if (!(router.get("mock data store") instanceof DataStore)) {
      router.set("mock data store", dataStore);
    }

    // Allow the mock to be disabled using `router.disable("mock")`
    isDisabled = function () {
      return router.get("mock") === false;
    };
  }

  return [
    mockResponse, mockImplementation, mockResponseHeaders, mockResponseBody
  ];

  /**
   * Determines the best Response object for this request and sets `res.swagger` to a {@link SemanticRequest} object.
   * Also sets `res.statusCode` if it isn't already set.
   */
  function mockResponse (req, res, next) {
    if (util.isSwaggerRequest(req) && !isDisabled()) {
      let response;

      // Is there already a statusCode? (perhaps set by third-party middleware)
      if (res.statusCode && req.swagger.operation.responses[res.statusCode]) {
        util.debug("Using %s response for %s %s", res.statusCode, req.method, req.path);
        response = req.swagger.operation.responses[res.statusCode];
      }
      else {
        // Use the first response with a 2XX or 3XX code (or "default")
        let responses = util.getResponsesBetween(req.swagger.operation, 200, 399);

        if (responses.length > 0) {
          response = responses[0].api;

          // Set the response status code
          if (_.isNumber(responses[0].code)) {
            util.debug("Using %s response for %s %s", responses[0].code, req.method, req.path);
            res.status(responses[0].code);
          }
          else {
            if (req.method === "POST" || req.method === "PUT") {
              res.status(201);
            }
            else if (req.method === "DELETE" && !responses[0].api.schema) {
              res.status(204);
            }
            else {
              res.status(200);
            }
            util.debug("Using %s (%d) response for %s %s", responses[0].code, res.statusCode, req.method, req.path);
          }
        }
        else {
          // There is no response with a 2XX or 3XX code, so just use the first one
          let keys = Object.keys(req.swagger.operation.responses);
          util.debug("Using %s response for %s %s", keys[0], req.method, req.path);
          response = req.swagger.operation.responses[keys[0]];
          res.status(parseInt(keys[0]));
        }
      }

      // The rest of the Mock middleware will use this ResponseMetadata object
      res.swagger = new SemanticResponse(response, req.swagger.path);
    }

    next();
  }

  /**
   * Runs the appropriate mock implementation.
   */
  function mockImplementation (req, res, next) {
    if (res.swagger) {
      // Determine the semantics of this request
      let request = new SemanticRequest(req);

      // Determine which mock to run
      let mock;
      if (request.isCollection) {
        mock = queryCollection[req.method] || editCollection[req.method];
      }
      else {
        mock = queryResource[req.method] || editResource[req.method];
      }

      // Get the current DataStore (this can be changed at any time by third-party code)
      let db = util.isExpressApp(router) ? router.get("mock data store") || dataStore : dataStore;
      db.__router = router;

      // Run the mock
      util.debug("Running the %s mock", mock.name);
      mock(req, res, next, db);
    }
    else {
      next();
    }
  }
}
657678
function loadMockDbResponse (mockData, options) {
    immutableAutomock.dbResponseMocks[mockData.data.dbQueryId] = mockData.data
}