22 #ifndef _PLUGINS_ROBOT_MEMORY_TEST_H_
23 #define _PLUGINS_ROBOT_MEMORY_TEST_H_
25 #include "plugins/robot-memory/robot_memory.h"
27 #include <blackboard/blackboard.h>
28 #include <gtest/gtest.h>
30 #include <bsoncxx/builder/basic/document.hpp>
31 #include <bsoncxx/document/value.hpp>
32 #include <bsoncxx/document/view.hpp>
84 ::testing::AssertionResult
contains_pairs(
const bsoncxx::document::view_or_value &obj,
85 const bsoncxx::document::view_or_value &exp);
86 ::testing::AssertionResult
contains_pairs(mongocxx::cursor & cursor,
87 const bsoncxx::document::view_or_value &exp);
129 std::list<bsoncxx::document::value>
130 compute(
const bsoncxx::document::view &query,
const std::string &collection)
132 std::list<bsoncxx::document::value> res;
133 using namespace bsoncxx::builder;
135 doc.append(basic::kvp(
"computed",
true));
136 doc.append(basic::kvp(
"result",
"this is computed"));
137 res.push_back(doc.extract());
146 std::list<bsoncxx::document::value>
147 compute_sum(
const bsoncxx::document::view &query,
const std::string &collection)
149 std::list<bsoncxx::document::value> res;
150 int x = query[
"x"].get_int64();
151 int y = query[
"y"].get_int64();
153 using namespace bsoncxx::builder;
155 b.append(basic::kvp(
"compute",
"sum"));
156 b.append(basic::kvp(
"x", x));
157 b.append(basic::kvp(
"y", y));
158 b.append(basic::kvp(
"sum", sum));
159 res.push_back(b.extract());
168 std::list<bsoncxx::document::value>
171 std::list<bsoncxx::document::value> res;
172 using namespace bsoncxx::builder;
173 for (
auto i : {1, 2, 3}) {
175 doc.append(basic::kvp(
"compute",
"multiple"));
176 doc.append(basic::kvp(
"count", i));
177 res.push_back(doc.extract());
Class to register callbacks independent of how many tests are using them at the moment.
int callback_counter
Counter for how often the callback was called.
void callback_test(const bsoncxx::document::view &update)
Test callback function.
Environment for running Tests of the RobotMemory Necessary for making object such as the robot memory...
void SetUp()
Setup the environment.
static RobotMemory * robot_memory
Access to Robot Memory.
static fawkes::BlackBoard * blackboard
Access to blackboard.
RobotMemoryTestEnvironment(RobotMemory *robot_memory, fawkes::BlackBoard *blackboard)
Constructor with objects of the thread.
virtual void TearDown()
TearDown the environment.
Class for Tests of the RobotMemory.
virtual void SetUp()
Setup for each test.
RobotMemory * robot_memory
Access to Robot Memory.
fawkes::BlackBoard * blackboard
Access to blackboard.
::testing::AssertionResult contains_pairs(const bsoncxx::document::view_or_value &obj, const bsoncxx::document::view_or_value &exp)
Function for testing if a document contains all key-value pairs of another document.
Access to the robot memory based on mongodb.
Class providing a computable function.
std::list< bsoncxx::document::value > compute(const bsoncxx::document::view &query, const std::string &collection)
Computable function for static document.
std::list< bsoncxx::document::value > compute_sum(const bsoncxx::document::view &query, const std::string &collection)
Computable function for addition.
std::list< bsoncxx::document::value > compute_multiple(const bsoncxx::document::view &query, const std::string &collection)
Computable function for multiple static document.
The BlackBoard abstract class.