2020
2121#include " json_engine.h"
2222#include < firebolt/helpers.h>
23+ #include < firebolt/json_types.h>
2324#include < gmock/gmock.h>
2425
2526class MockHelper : public Firebolt ::Helpers::IHelper
@@ -46,6 +47,30 @@ class MockHelper : public Firebolt::Helpers::IHelper
4647class MockBase
4748{
4849protected:
50+ template <typename T>
51+ void validate_enum (const std::string& enumName, const nlohmann::json& enums,
52+ const Firebolt::JSON::EnumType<T>& enumType)
53+ {
54+ for (const auto & expectedValue : enumType)
55+ {
56+ EXPECT_TRUE (std::find (enums.begin (), enums.end (), expectedValue.first ) != enums.end ())
57+ << " Expected enum value: " << expectedValue.first
58+ << " not found in OpenRPC schema for enum: " << enumName;
59+ }
60+ for (const auto & enumValue : enums)
61+ {
62+ auto it = std::find_if (enumType.begin (), enumType.end (), [&enumValue](const auto & pair)
63+ { return pair.first == enumValue.get <std::string>(); });
64+ EXPECT_TRUE (it != enumType.end ())
65+ << " An enum: " << enumValue.get <std::string>() << " from OpenRPC schema for enum: " << enumName
66+ << " is not defined in sources" ;
67+ }
68+ }
69+ template <typename T> void validate_enum (const std::string& enumName, const Firebolt::JSON::EnumType<T>& enumType)
70+ {
71+ validate_enum (enumName, jsonEngine[" components" ][" schemas" ][enumName][" enum" ], enumType);
72+ }
73+
4974 Firebolt::Result<nlohmann::json> getter (const std::string& methodName, const nlohmann::json& parameters)
5075 {
5176 nlohmann::json message;
0 commit comments