PEL: LightPath: Assert LED groups

Fill in the functions to get the LED group D-Bus paths corresponding to
the called out location codes, and then set the Asserted property on
that path to turn on the LEDs.

If there are any problems looking up any of the LED groups, then do not
turn on any LEDs at all, even if others were OK.  In this case, the
system attention indicator will be turned on instead.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I7e3ee6259d972dd2c6939c5a1004c6d25c40e38a
diff --git a/test/openpower-pels/service_indicators_test.cpp b/test/openpower-pels/service_indicators_test.cpp
index c391e92..8f1d9ab 100644
--- a/test/openpower-pels/service_indicators_test.cpp
+++ b/test/openpower-pels/service_indicators_test.cpp
@@ -257,3 +257,85 @@
                   (std::vector<std::string>{}));
     }
 }
+
+// Test the activate() function
+TEST(ServiceIndicatorsTest, ActivateTest)
+{
+    // pelFactory() will create a PEL with 1 callout with location code
+    // U42.  Test the LED for that gets activated.
+    {
+        MockDataInterface dataIface;
+        service_indicators::LightPath lightPath{dataIface};
+
+        EXPECT_CALL(dataIface, getInventoryFromLocCode("U42", 0, true))
+            .WillOnce(Return("/system/chassis/processor"));
+
+        EXPECT_CALL(dataIface, getFaultLEDGroup("/system/chassis/processor"))
+            .WillOnce(Return("/led/groups/cpu0"));
+
+        EXPECT_CALL(dataIface, assertLEDGroup("/led/groups/cpu0", true))
+            .Times(1);
+
+        auto data = pelFactory(1, 'O', 0x20, 0xA400, 500);
+        PEL pel{data};
+
+        lightPath.activate(pel);
+    }
+
+    // Make getInventoryFromLocCode fail
+    {
+        MockDataInterface dataIface;
+        service_indicators::LightPath lightPath{dataIface};
+
+        EXPECT_CALL(dataIface, getInventoryFromLocCode("U42", 0, true))
+            .WillOnce(Throw(std::runtime_error("Fail")));
+
+        EXPECT_CALL(dataIface, getFaultLEDGroup(_)).Times(0);
+
+        EXPECT_CALL(dataIface, assertLEDGroup(_, true)).Times(0);
+
+        auto data = pelFactory(1, 'O', 0x20, 0xA400, 500);
+        PEL pel{data};
+
+        lightPath.activate(pel);
+    }
+
+    // Make getFaultLEDGroup fail
+    {
+        MockDataInterface dataIface;
+        service_indicators::LightPath lightPath{dataIface};
+
+        EXPECT_CALL(dataIface, getInventoryFromLocCode("U42", 0, true))
+            .WillOnce(Return("/system/chassis/processor"));
+
+        EXPECT_CALL(dataIface, getFaultLEDGroup("/system/chassis/processor"))
+            .WillOnce(Throw(std::runtime_error("Fail")));
+
+        EXPECT_CALL(dataIface, assertLEDGroup(_, true)).Times(0);
+
+        auto data = pelFactory(1, 'O', 0x20, 0xA400, 500);
+        PEL pel{data};
+
+        lightPath.activate(pel);
+    }
+
+    // Make assertLEDGroup fail
+    {
+        MockDataInterface dataIface;
+        service_indicators::LightPath lightPath{dataIface};
+
+        EXPECT_CALL(dataIface, getInventoryFromLocCode("U42", 0, true))
+            .WillOnce(Return("/system/chassis/processor"));
+
+        EXPECT_CALL(dataIface, getFaultLEDGroup("/system/chassis/processor"))
+            .WillOnce(Return("/led/groups/cpu0"));
+
+        EXPECT_CALL(dataIface, assertLEDGroup("/led/groups/cpu0", true))
+            .WillOnce(Throw(std::runtime_error("Fail")));
+
+        auto data = pelFactory(1, 'O', 0x20, 0xA400, 500);
+        PEL pel{data};
+
+        lightPath.activate(pel);
+    }
+}