1 #include "elog_entry.hpp"
2 #include "elog_serialize.hpp"
3 #include "serialization_tests.hpp"
4 
5 namespace phosphor
6 {
7 namespace logging
8 {
9 namespace test
10 {
11 
TEST_F(TestSerialization,testProperties)12 TEST_F(TestSerialization, testProperties)
13 {
14     auto id = 99;
15     phosphor::logging::AssociationList assocations{};
16     std::vector<std::string> testData{"additional", "data"};
17     uint64_t timestamp{100};
18     std::string message{"test error"};
19     std::string fwLevel{"level42"};
20     std::string inputPath = getEntrySerializePath(id, TestSerialization::dir);
21     auto input = std::make_unique<Entry>(
22         bus, std::string(OBJ_ENTRY) + '/' + std::to_string(id), id, timestamp,
23         Entry::Level::Informational, std::move(message), std::move(testData),
24         std::move(assocations), fwLevel, inputPath, manager);
25     auto path = serialize(*input, TestSerialization::dir);
26     EXPECT_EQ(path, inputPath);
27 
28     auto idStr = path.filename();
29     id = std::stol(idStr.c_str());
30     auto output = std::make_unique<Entry>(
31         bus, std::filesystem::path(OBJ_ENTRY) / idStr, id, manager);
32     deserialize(path, *output);
33 
34     EXPECT_EQ(input->id(), output->id());
35     EXPECT_EQ(input->severity(), output->severity());
36     EXPECT_EQ(input->timestamp(), output->timestamp());
37     EXPECT_EQ(input->message(), output->message());
38     EXPECT_EQ(input->additionalData(), output->additionalData());
39     EXPECT_EQ(input->resolved(), output->resolved());
40     EXPECT_EQ(input->associations(), output->associations());
41     EXPECT_EQ(input->version(), output->version());
42     EXPECT_EQ(input->purpose(), output->purpose());
43     EXPECT_EQ(input->updateTimestamp(), output->updateTimestamp());
44 }
45 
46 } // namespace test
47 } // namespace logging
48 } // namespace phosphor
49