fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2 Co-authored-by: Sebastian McKenzie <sebmck@fb.com> Co-authored-by: John Knox <jknox@fb.com> Co-authored-by: Emil Sjölander <emilsj@fb.com> Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
44 lines
968 B
C++
44 lines
968 B
C++
/*
|
|
* Copyright (c) 2018-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Sonar/SonarResponder.h>
|
|
#include <folly/json.h>
|
|
#include <vector>
|
|
|
|
namespace facebook {
|
|
namespace sonar {
|
|
|
|
class SonarResponderMock : public SonarResponder {
|
|
public:
|
|
SonarResponderMock(
|
|
std::vector<folly::dynamic>* successes = nullptr,
|
|
std::vector<folly::dynamic>* errors = nullptr)
|
|
: successes_(successes), errors_(errors) {}
|
|
|
|
void success(const folly::dynamic& response) const override {
|
|
if (successes_) {
|
|
successes_->push_back(response);
|
|
}
|
|
}
|
|
|
|
void error(const folly::dynamic& response) const override {
|
|
if (errors_) {
|
|
errors_->push_back(response);
|
|
}
|
|
}
|
|
|
|
private:
|
|
std::vector<folly::dynamic>* successes_;
|
|
std::vector<folly::dynamic>* errors_;
|
|
};
|
|
|
|
} // namespace sonar
|
|
} // namespace facebook
|