PEL: Repository: Added getLogID() as public method

Currently, don't have any public method to get LogID from
the Repository class so added an api "getLogID()" which can be
used to get the LogID by using either OpenBMC event log id or
PEL id (aka Entry ID (EID)).

Tested:
- Tested by below unit test cases.
 - GetLogIDFoundTC
  - With valid PEL ID
  - With valid OpenBMC Event Log ID
 - GetLogIDNotFoundTC
  - With invalid PEL ID
  - With invalid OpenBMC Event Log ID

Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com>
Change-Id: Ia621c46f67198fccd88ec5b00c32d4f65be05743
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 42a921b..7aa0d0d 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -960,3 +960,54 @@
     EXPECT_FALSE(repo.sizeWarning());
     EXPECT_FALSE(fs::exists(archivePath));
 }
+
+TEST_F(RepositoryTest, GetLogIDFoundTC)
+{
+    // Add and Check the created LogId
+
+    Repository repo{repoPath};
+    auto data = pelDataFactory(TestPELType::pelSimple);
+    auto pel = std::make_unique<PEL>(data, 1);
+
+    pel->assignID();
+
+    repo.add(pel);
+
+    // Getting by PEL Id
+    Repository::LogID idWithPelId{Repository::LogID::Pel(pel->id())};
+    auto logID = repo.getLogID(idWithPelId);
+    ASSERT_TRUE(logID.has_value());
+    EXPECT_EQ(logID->obmcID.id, pel->obmcLogID());
+    EXPECT_EQ(logID->pelID.id, pel->id());
+
+    // Getting by OBMC Event Log Id
+    Repository::LogID idWithObmcLogId{
+        Repository::LogID::Obmc(pel->obmcLogID())};
+    logID = repo.getLogID(idWithObmcLogId);
+    ASSERT_TRUE(logID.has_value());
+    EXPECT_EQ(logID->obmcID.id, pel->obmcLogID());
+    EXPECT_EQ(logID->pelID.id, pel->id());
+}
+
+TEST_F(RepositoryTest, GetLogIDNotFoundTC)
+{
+    // Add and Check the created LogId
+
+    Repository repo{repoPath};
+    auto data = pelDataFactory(TestPELType::pelSimple);
+    auto pel = std::make_unique<PEL>(data, 1);
+
+    pel->assignID();
+
+    repo.add(pel);
+
+    // Getting by invalid PEL Id
+    Repository::LogID idWithPelId{Repository::LogID::Pel(0xFFFFFFFF)};
+    auto logID = repo.getLogID(idWithPelId);
+    ASSERT_TRUE(!logID.has_value());
+
+    // Getting by invalid OBMC Event Log ID
+    Repository::LogID idWithObmcLogId{Repository::LogID::Obmc(0xFFFFFFFF)};
+    logID = repo.getLogID(idWithObmcLogId);
+    ASSERT_TRUE(!logID.has_value());
+}