input: Systemd unit monitor input
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/dependencies/+/2869
Change-Id: Ia22b4cf620a58624357549bd903455fc94c76931
diff --git a/tests/dbus-helpers/dbus_systemd_server.h b/tests/dbus-helpers/dbus_systemd_server.h
new file mode 100644
index 0000000..9dd700f
--- /dev/null
+++ b/tests/dbus-helpers/dbus_systemd_server.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <memory>
+#include <mutex>
+#include <sdbus-c++/sdbus-c++.h>
+#include <string>
+
+/** @brief Mimics the systemd dbus behaviour */
+class DbusSystemdServer {
+public:
+ using UnitStruct = sdbus::Struct<std::string, std::string, std::string, std::string, std::string, std::string, sdbus::ObjectPath, uint32_t, std::string, sdbus::ObjectPath>;
+
+ explicit DbusSystemdServer(sdbus::IConnection& connection);
+
+ void createUnit(sdbus::IConnection& connection, const sdbus::ObjectPath& objPath, const std::string& activeState, const std::string& subState);
+ void changeUnitState(const sdbus::ObjectPath& objPath, const std::string& activeState, const std::string& subState);
+
+private:
+ struct Unit {
+ Unit(std::unique_ptr<sdbus::IObject> object, std::string activeState, std::string subState);
+
+ std::unique_ptr<sdbus::IObject> m_object;
+ std::string m_activeState;
+ std::string m_subState;
+ };
+
+ std::unique_ptr<sdbus::IObject> m_manager;
+ std::map<sdbus::ObjectPath, Unit> m_units;
+
+ std::vector<UnitStruct> ListUnits();
+};
\ No newline at end of file