blob: e1815584f52d2ea38a0a67e649e1e5aa9ccecfae [file] [log] [blame]
Zane Shelleyf685afd2021-02-15 15:39:44 -06001#include <stdio.h>
2
3#include <analyzer/service_data.hpp>
4
5#include "gtest/gtest.h"
6
7using namespace analyzer;
8
Zane Shelley8af9e462021-03-11 10:44:28 -06009TEST(ServiceData, TestSet1)
Zane Shelleyf685afd2021-02-15 15:39:44 -060010{
Zane Shelley8af9e462021-03-11 10:44:28 -060011 libhei::Chip chip{"/proc0", 0xdeadbeef};
12 libhei::Signature rootCause{chip, 0xabcd, 0, 0,
13 libhei::ATTN_TYPE_CHECKSTOP};
14
15 ServiceData sd{rootCause};
Zane Shelley64791cf2021-02-15 17:02:37 -060016
17 sd.addCallout(std::make_shared<HardwareCallout>("Test location 1",
18 Callout::Priority::HIGH));
19 sd.addCallout(std::make_shared<HardwareCallout>("Test location 2",
20 Callout::Priority::MED_A));
21 sd.addCallout(std::make_shared<ProcedureCallout>(ProcedureCallout::NEXTLVL,
22 Callout::Priority::LOW));
Zane Shelleyf685afd2021-02-15 15:39:44 -060023
24 nlohmann::json j{};
Zane Shelley64791cf2021-02-15 17:02:37 -060025 sd.getCalloutList(j);
Zane Shelleyf685afd2021-02-15 15:39:44 -060026
27 // Create a RAW string containing what we should expect in the JSON output.
28 std::string s = R"([
29 {
30 "LocationCode": "Test location 1",
31 "Priority": "H"
32 },
33 {
34 "LocationCode": "Test location 2",
35 "Priority": "A"
36 },
37 {
38 "Priority": "L",
39 "Procedure": "NEXTLVL"
40 }
41])";
42
43 ASSERT_EQ(s, j.dump(4));
44}