PEL: New repository method to get PEL data

Add the getPELData() function on the Repository class to return
PEL data based on a PEL ID or OBMC event log ID.

The intended use for this will be a D-Bus method, mainly used for
debug via the REST interface, to get the PEL data off the BMC when
only the OpenBMC event log ID is known, which will be the case until
the Redfish APIs are ready.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia1d8bff627992fae16be9136f2814f01ea69009e
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 6963184..57952e3 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -138,3 +138,26 @@
         EXPECT_FALSE(repo.hasPEL(ids[1]));
     }
 }
+
+TEST_F(RepositoryTest, TestGetPELData)
+{
+    using ID = Repository::LogID;
+    Repository repo{repoPath};
+
+    ID badID{ID::Pel(42)};
+    auto noData = repo.getPELData(badID);
+    EXPECT_FALSE(noData);
+
+    // Add a PEL to the repo, and get the data back with getPELData.
+    auto data = pelDataFactory(TestPelType::pelSimple);
+    auto dataCopy = *data;
+    auto pel = std::make_unique<PEL>(*data);
+    auto pelID = pel->id();
+    repo.add(pel);
+
+    ID id{ID::Pel(pelID)};
+    auto pelData = repo.getPELData(id);
+
+    ASSERT_TRUE(pelData);
+    EXPECT_EQ(dataCopy, *pelData);
+}