| #include <memory> |
| #include <string> |
| |
| #include <gtest/gtest.h> |
| #include "chassis.hpp" |
| #include "test/redfish-core/lib/snapshot_fixture.hpp" |
| #include <nlohmann/json.hpp> |
| |
| namespace redfish { |
| namespace { |
| |
| TEST_F(SnapshotFixture, GetChassisAssemblyReturnsTheCorrectResponse) { |
| getChassisAssembly(app_, CreateRequest(), share_async_resp_, "platform1"); |
| |
| RunIoUntilDone(); |
| |
| nlohmann::json& json = share_async_resp_->res.jsonValue; |
| EXPECT_EQ(json["@odata.id"], "/redfish/v1/Chassis/platform1/Assembly"); |
| EXPECT_EQ(json["@odata.type"], "#Assembly.v1_3_0.Assembly"); |
| EXPECT_EQ(json["Id"], "Assembly"); |
| EXPECT_EQ(json["Name"], "Assembly Collection"); |
| EXPECT_EQ(json["Assemblies"].size(), json["Assemblies@odata.count"]); |
| |
| // Order should be CpuCooler0, CpuCooler1, tray |
| nlohmann::json& cpuCooler0 = json["Assemblies"][0]; |
| EXPECT_EQ(cpuCooler0["@odata.id"], |
| "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/0"); |
| EXPECT_EQ(cpuCooler0["@odata.type"], "#Assembly.v1_3_0.AssemblyData"); |
| EXPECT_EQ(cpuCooler0["Location"]["PartLocation"]["LocationType"], "Slot"); |
| EXPECT_EQ(cpuCooler0["Location"]["PartLocation"]["ServiceLabel"], |
| "CPU0_ANCHORS"); |
| EXPECT_EQ(cpuCooler0["MemberId"], "0"); |
| EXPECT_EQ(cpuCooler0["Model"], "Model"); |
| EXPECT_EQ(cpuCooler0["Name"], "CpuCooler0"); |
| |
| nlohmann::json& cpuCooler1 = json["Assemblies"][1]; |
| EXPECT_EQ(cpuCooler1["@odata.id"], |
| "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/1"); |
| EXPECT_EQ(cpuCooler1["@odata.type"], "#Assembly.v1_3_0.AssemblyData"); |
| EXPECT_EQ(cpuCooler1["Location"]["PartLocation"]["LocationType"], "Slot"); |
| EXPECT_EQ(cpuCooler1["Location"]["PartLocation"]["ServiceLabel"], |
| "CPU1_ANCHORS"); |
| EXPECT_EQ(cpuCooler1["MemberId"], "1"); |
| EXPECT_EQ(cpuCooler1["Model"], "Model"); |
| EXPECT_EQ(cpuCooler1["Name"], "CpuCooler1"); |
| |
| nlohmann::json& tray = json["Assemblies"][2]; |
| EXPECT_EQ(tray["@odata.id"], |
| "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/2"); |
| EXPECT_EQ(tray["@odata.type"], "#Assembly.v1_3_0.AssemblyData"); |
| EXPECT_EQ(tray["Location"]["PartLocation"]["LocationType"], "Slot"); |
| EXPECT_EQ(tray["Location"]["PartLocation"]["ServiceLabel"], "TRAY"); |
| EXPECT_EQ(tray["MemberId"], "2"); |
| EXPECT_EQ(tray["Name"], "tray"); |
| |
| EXPECT_EQ(share_async_resp_->res.result(), boost::beast::http::status::ok); |
| } |
| |
| } // namespace |
| } // namespace redfish |