1 #include "async_resp.hpp"
2 #include "http_response.hpp"
3 #include "power_subsystem.hpp"
4 
5 #include <nlohmann/json.hpp>
6 
7 #include <memory>
8 #include <optional>
9 #include <string>
10 
11 #include <gtest/gtest.h>
12 
13 namespace redfish
14 {
15 namespace
16 {
17 
18 constexpr const char* chassisId = "ChassisId";
19 constexpr const char* validChassisPath = "ChassisPath";
20 
assertPowerSubsystemCollectionGet(crow::Response & res)21 void assertPowerSubsystemCollectionGet(crow::Response& res)
22 {
23     nlohmann::json& json = res.jsonValue;
24     EXPECT_EQ(json["@odata.type"], "#PowerSubsystem.v1_1_0.PowerSubsystem");
25     EXPECT_EQ(json["Name"], "Power Subsystem");
26     EXPECT_EQ(json["Id"], "PowerSubsystem");
27     EXPECT_EQ(json["@odata.id"],
28               "/redfish/v1/Chassis/ChassisId/PowerSubsystem");
29     EXPECT_EQ(json["Status"]["State"], "Enabled");
30     EXPECT_EQ(json["Status"]["Health"], "OK");
31 }
32 
TEST(PowerSubsystemCollectionTest,PowerSubsystemCollectionStaticAttributesAreExpected)33 TEST(PowerSubsystemCollectionTest,
34      PowerSubsystemCollectionStaticAttributesAreExpected)
35 {
36     auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
37     shareAsyncResp->res.setCompleteRequestHandler(
38         assertPowerSubsystemCollectionGet);
39     doPowerSubsystemCollection(
40         shareAsyncResp, chassisId,
41         std::make_optional<std::string>(validChassisPath));
42 }
43 
44 } // namespace
45 } // namespace redfish
46