Migrate power_supply_test.cpp from Gerrit to Google3.

Google-Bug-Id:548070242
PiperOrigin-RevId: 968146608
Change-Id: I8e06fb15b15826b6702906bd6b4968a41c185e99
diff --git a/copy.bara.sky b/copy.bara.sky
index 0300de8..b5bb45b 100644
--- a/copy.bara.sky
+++ b/copy.bara.sky
@@ -291,6 +291,7 @@
     ("test/redfish_core/lib/ports_test.cc", "test/redfish-core/lib/ports_test.cpp"),
     ("test/redfish_core/lib/power_subsystem_test.cc", "test/redfish-core/lib/power_subsystem_test.cpp"),
     ("test/redfish_core/lib/power_supply_metrics_test.cc", "test/redfish-core/lib/power_supply_metrics_test.cpp"),
+    ("test/redfish_core/lib/power_supply_test.cc", "test/redfish-core/lib/power_supply_test.cpp"),
     ("test/redfish_core/lib/power_test.cc", "test/redfish-core/lib/power_test.cpp"),
     ("test/redfish_core/lib/service_root_test.cc", "test/redfish-core/lib/service_root_test.cpp"),
     ("test/redfish_core/lib/snapshot_fixture.h", "test/redfish-core/lib/snapshot_fixture.hpp"),
diff --git a/test/redfish-core/lib/power_supply_test.cpp b/test/redfish-core/lib/power_supply_test.cpp
index ea1134b..900615b 100644
--- a/test/redfish-core/lib/power_supply_test.cpp
+++ b/test/redfish-core/lib/power_supply_test.cpp
@@ -1,95 +1,88 @@
-#include "async_resp.hpp"
-#include "chassis_utils.hpp"
 #include "power_supply.hpp"
-#include "snapshot_fixture.hpp"
-#include "test/g3/mock_managed_store_test.hpp"
 
-#include <nlohmann/json.hpp>
-
+#include <memory>
 #include <optional>
 #include <string>
+#include <vector>
 
 #include <gtest/gtest.h>
+#include "utility.hpp"
+#include "async_resp.hpp"
+#include "snapshot_fixture.hpp"
+#include <nlohmann/json.hpp>
+#include "test/g3/mock_managed_store_test.hpp"
 
-namespace redfish
-{
-namespace
-{
+namespace redfish {
+namespace {
 
-const std::string chassisId = "platfrom1";
-const std::string validChassisPath =
+constexpr const char* chassisId = "platform1";
+constexpr const char* validChassisPath =
     "/xyz/openbmc_project/inventory/system/board/platform1";
 
-std::vector<std::string> getPowerSupplyIds()
-{
-    auto dummyResp = std::make_shared<bmcweb::AsyncResp>();
-    std::vector<std::string> res;
+std::vector<std::string> getPowerSupplyIds() {
+  auto dummyResp = std::make_shared<bmcweb::AsyncResp>();
+  std::vector<std::string> res;
 
-    // Get valid powerSupplyId
-    doPowerSupplyCollection(dummyResp, chassisId,
-                            std::make_optional<std::string>(validChassisPath));
+  // Get valid powerSupplyId
+  doPowerSupplyCollection(dummyResp, chassisId,
+                          std::make_optional<std::string>(validChassisPath));
 
-    managedStore::MockManagedStoreTest::RunIoUntilDone();
+  managedStore::MockManagedStoreTest::RunIoUntilDone();
 
-    nlohmann::json& json = dummyResp->res.jsonValue;
+  nlohmann::json& json = dummyResp->res.jsonValue;
 
-    EXPECT_EQ(json["@odata.type"],
-              "#PowerSupplyCollection.PowerSupplyCollection");
-    EXPECT_EQ(json["Name"], "Power Supply Collection");
-    EXPECT_EQ(json["@odata.id"], crow::utility::urlFromPieces(
-                                     "redfish", "v1", "Chassis", chassisId,
-                                     "PowerSubsystem", "PowerSupplies"));
-    EXPECT_TRUE(json.contains("Description"));
-    EXPECT_GT(json["Members@odata.count"], 0);
+  EXPECT_EQ(json["@odata.type"],
+            "#PowerSupplyCollection.PowerSupplyCollection");
+  EXPECT_EQ(json["Name"], "Power Supply Collection");
+  EXPECT_EQ(json["@odata.id"],
+            crow::utility::urlFromPieces("redfish", "v1", "Chassis", chassisId,
+                                         "PowerSubsystem", "PowerSupplies"));
+  EXPECT_TRUE(json.contains("Description"));
+  EXPECT_GT(json["Members@odata.count"], 0);
 
-    for (const auto& member : dummyResp->res.jsonValue["Members"])
-    {
-        auto odata_id = member["@odata.id"].get<std::string>();
-        std::string powerSupplyId =
-            odata_id.substr(odata_id.find_last_of('/') + 1);
-        res.emplace_back(powerSupplyId);
-    }
+  for (const auto& member : dummyResp->res.jsonValue["Members"]) {
+    auto odata_id = member["@odata.id"].get<std::string>();
+    std::string powerSupplyId = odata_id.substr(odata_id.find_last_of('/') + 1);
+    res.emplace_back(powerSupplyId);
+  }
 
-    return res;
+  return res;
 }
 
-TEST_F(SnapshotFixture_Platform11_Config4, doPowerSupplyCollectionTest)
-{
-    getPowerSupplyIds();
+TEST_F(SnapshotFixture_Platform11_Config4, doPowerSupplyCollectionTest) {
+  getPowerSupplyIds();
 }
 
-TEST_F(SnapshotFixture_Platform11_Config4, doPowerSupplyGetTest)
-{
-    std::vector<std::string> powerSupplyIds;
+TEST_F(SnapshotFixture_Platform11_Config4, doPowerSupplyGetTest) {
+  std::vector<std::string> powerSupplyIds;
 
-    // Get powerSupplyId
-    powerSupplyIds = getPowerSupplyIds();
+  // Get powerSupplyId
+  powerSupplyIds = getPowerSupplyIds();
 
-    for (const auto& powerSupplyId : powerSupplyIds)
-    {
-        doPowerSupplyGet(share_async_resp_, chassisId, powerSupplyId,
-                         validChassisPath);
-        
-        RunIoUntilDone();
+  for (const auto& powerSupplyId : powerSupplyIds) {
+    doPowerSupplyGet(share_async_resp_, chassisId, powerSupplyId,
+                     validChassisPath);
 
-        nlohmann::json& json = share_async_resp_->res.jsonValue;
+    RunIoUntilDone();
 
-        EXPECT_EQ(json["@odata.type"], "#PowerSupply.v1_5_0.PowerSupply");
-        EXPECT_EQ(json["Name"], "Power Supply");
-        EXPECT_EQ(json["Id"], powerSupplyId);
-        EXPECT_EQ(json["@odata.id"],
-                  crow::utility::urlFromPieces("redfish", "v1", "Chassis",
-                                               chassisId, "PowerSubsystem",
-                                               "PowerSupplies", powerSupplyId));
+    nlohmann::json& json = share_async_resp_->res.jsonValue;
 
-        EXPECT_TRUE(json.contains("Metrics"));
-        EXPECT_TRUE(json["Metrics"].contains("@odata.id"));
-        // getPowerSupplyState
-        // getPowerSupplyHealth
-        EXPECT_EQ(json["Status"]["State"], "Enabled");
-        EXPECT_EQ(json["Status"]["Health"], "OK");
-    }
+    EXPECT_EQ(json["@odata.type"], "#PowerSupply.v1_5_0.PowerSupply");
+    EXPECT_EQ(json["Name"], "Power Supply");
+    EXPECT_EQ(json["Id"], powerSupplyId);
+    EXPECT_EQ(json["@odata.id"],
+              crow::utility::urlFromPieces("redfish", "v1", "Chassis",
+                                           chassisId, "PowerSubsystem",
+                                           "PowerSupplies", powerSupplyId));
+
+    EXPECT_TRUE(json.contains("Metrics"));
+    EXPECT_TRUE(json["Metrics"].contains("@odata.id"));
+    // getPowerSupplyState
+    // getPowerSupplyHealth
+    EXPECT_EQ(json["Status"]["State"], "Enabled");
+    EXPECT_EQ(json["Status"]["Health"], "OK");
+  }
 }
 
-} // namespace
-} // namespace redfish
\ No newline at end of file
+}  // namespace
+}  // namespace redfish