1919#pragma once
2020
2121#include " json_engine.h"
22+ #include < algorithm>
2223#include < firebolt/helpers.h>
24+ #include < firebolt/json_types.h>
2325#include < gmock/gmock.h>
2426
2527class MockHelper : public Firebolt ::Helpers::IHelper
@@ -46,6 +48,30 @@ class MockHelper : public Firebolt::Helpers::IHelper
4648class MockBase
4749{
4850protected:
51+ template <typename T>
52+ void validate_enum (const std::string& enumName, const nlohmann::json& enums,
53+ const Firebolt::JSON::EnumType<T>& enumType)
54+ {
55+ for (const auto & expectedValue : enumType)
56+ {
57+ EXPECT_TRUE (std::find (enums.begin (), enums.end (), expectedValue.first ) != enums.end ())
58+ << " Expected enum value: " << expectedValue.first
59+ << " not found in OpenRPC schema for enum: " << enumName;
60+ }
61+ for (const auto & enumValue : enums)
62+ {
63+ auto it = std::find_if (enumType.begin (), enumType.end (), [&enumValue](const auto & pair)
64+ { return pair.first == enumValue.get <std::string>(); });
65+ EXPECT_TRUE (it != enumType.end ())
66+ << " An enum: " << enumValue.get <std::string>() << " from OpenRPC schema for enum: " << enumName
67+ << " is not defined in sources" ;
68+ }
69+ }
70+ template <typename T> void validate_enum (const std::string& enumName, const Firebolt::JSON::EnumType<T>& enumType)
71+ {
72+ validate_enum (enumName, jsonEngine[" components" ][" schemas" ][enumName][" enum" ], enumType);
73+ }
74+
4975 Firebolt::Result<nlohmann::json> getter (const std::string& methodName, const nlohmann::json& parameters)
5076 {
5177 nlohmann::json message;
0 commit comments