PEL: Add Repo API to update transmission states

Provided APIs for the Repository class to update the host and HMC
transmission states on a PEL it contains.  It saves the updated PEL data
in the filesystem.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Iadbc589ee85d4408339e1171c36b8324910f4f0a
diff --git a/test/openpower-pels/repository_test.cpp b/test/openpower-pels/repository_test.cpp
index 8596840..5c4db47 100644
--- a/test/openpower-pels/repository_test.cpp
+++ b/test/openpower-pels/repository_test.cpp
@@ -300,3 +300,89 @@
         EXPECT_FALSE(a);
     }
 }
+
+TEST_F(RepositoryTest, TestSetHostState)
+{
+    // Add a PEL to the repo
+    auto data = pelDataFactory(TestPELType::pelSimple);
+    auto pel = std::make_unique<PEL>(data);
+    using ID = Repository::LogID;
+    ID id{ID::Pel(pel->id())};
+
+    {
+        Repository repo{repoPath};
+
+        repo.add(pel);
+
+        auto a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hostState, TransmissionState::newPEL);
+
+        repo.setPELHostTransState(pel->id(), TransmissionState::acked);
+
+        // First, check the attributes
+        a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hostState, TransmissionState::acked);
+
+        // Next, check the PEL data itself
+        auto pelData = repo.getPELData(id);
+        PEL newPEL{*pelData};
+        EXPECT_EQ(newPEL.hostTransmissionState(), TransmissionState::acked);
+    }
+
+    {
+        // Now restore, and check again
+        Repository repo{repoPath};
+
+        // First, check the attributes
+        auto a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hostState, TransmissionState::acked);
+
+        // Next, check the PEL data itself
+        auto pelData = repo.getPELData(id);
+        PEL newPEL{*pelData};
+        EXPECT_EQ(newPEL.hostTransmissionState(), TransmissionState::acked);
+    }
+}
+
+TEST_F(RepositoryTest, TestSetHMCState)
+{
+    // Add a PEL to the repo
+    auto data = pelDataFactory(TestPELType::pelSimple);
+    auto pel = std::make_unique<PEL>(data);
+    using ID = Repository::LogID;
+    ID id{ID::Pel(pel->id())};
+
+    {
+        Repository repo{repoPath};
+
+        repo.add(pel);
+
+        auto a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hmcState, TransmissionState::newPEL);
+
+        repo.setPELHMCTransState(pel->id(), TransmissionState::acked);
+
+        // First, check the attributes
+        a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hmcState, TransmissionState::acked);
+
+        // Next, check the PEL data itself
+        auto pelData = repo.getPELData(id);
+        PEL newPEL{*pelData};
+        EXPECT_EQ(newPEL.hmcTransmissionState(), TransmissionState::acked);
+    }
+
+    {
+        // Now restore, and check again
+        Repository repo{repoPath};
+
+        // First, check the attributes
+        auto a = repo.getPELAttributes(id);
+        EXPECT_EQ((*a).get().hmcState, TransmissionState::acked);
+
+        // Next, check the PEL data itself
+        auto pelData = repo.getPELData(id);
+        PEL newPEL{*pelData};
+        EXPECT_EQ(newPEL.hmcTransmissionState(), TransmissionState::acked);
+    }
+}