summaryrefslogtreecommitdiffstats
path: root/test/serialization_test_properties.cpp
blob: be9a7c740457b81a35684ddf858a2a02a58adcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "serialization_tests.hpp"
#include "elog_entry.hpp"
#include "elog_serialize.hpp"

namespace phosphor
{
namespace logging
{
namespace test
{

TEST_F(TestSerialization, testProperties)
{
    auto id = 99;
    phosphor::logging::AssociationList assocations{};
    std::vector<std::string> testData{"additional", "data"};
    uint64_t timestamp{100};
    std::string message{"test error"};
    std::string fwLevel{"level42"};
    auto input = std::make_unique<Entry>(
                     bus,
                     std::string(OBJ_ENTRY) + '/' + std::to_string(id),
                     id,
                     timestamp,
                     Entry::Level::Informational,
                     std::move(message),
                     std::move(testData),
                     std::move(assocations),
                     fwLevel,
                     manager);
    auto path = serialize(*input, TestSerialization::dir);

    auto idStr = path.filename().c_str();
    id = std::stol(idStr);
    auto output = std::make_unique<Entry>(
                      bus,
                      std::string(OBJ_ENTRY) + '/' + idStr,
                      id,
                      manager);
    deserialize(path, *output);

    EXPECT_EQ(input->id(), output->id());
    EXPECT_EQ(input->severity(), output->severity());
    EXPECT_EQ(input->timestamp(), output->timestamp());
    EXPECT_EQ(input->message(), output->message());
    EXPECT_EQ(input->additionalData(), output->additionalData());
    EXPECT_EQ(input->resolved(), output->resolved());
    EXPECT_EQ(input->associations(), output->associations());
    EXPECT_EQ(input->version(), output->version());
    EXPECT_EQ(input->purpose(), output->purpose());
}

} // namespace test
} // namespace logging
} // namespace phosphor


OpenPOWER on IntegriCloud