Zane Shelley | f685afd | 2021-02-15 15:39:44 -0600 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | |
| 3 | #include <analyzer/service_data.hpp> |
| 4 | |
| 5 | #include "gtest/gtest.h" |
| 6 | |
| 7 | using namespace analyzer; |
| 8 | |
Zane Shelley | 8af9e46 | 2021-03-11 10:44:28 -0600 | [diff] [blame] | 9 | TEST(ServiceData, TestSet1) |
Zane Shelley | f685afd | 2021-02-15 15:39:44 -0600 | [diff] [blame] | 10 | { |
Zane Shelley | 8af9e46 | 2021-03-11 10:44:28 -0600 | [diff] [blame] | 11 | libhei::Chip chip{"/proc0", 0xdeadbeef}; |
| 12 | libhei::Signature rootCause{chip, 0xabcd, 0, 0, |
| 13 | libhei::ATTN_TYPE_CHECKSTOP}; |
| 14 | |
Zane Shelley | ca49619 | 2021-08-09 12:05:52 -0500 | [diff] [blame^] | 15 | ServiceData sd{rootCause, true}; |
Zane Shelley | 64791cf | 2021-02-15 17:02:37 -0600 | [diff] [blame] | 16 | |
| 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 Shelley | f685afd | 2021-02-15 15:39:44 -0600 | [diff] [blame] | 23 | |
| 24 | nlohmann::json j{}; |
Zane Shelley | 64791cf | 2021-02-15 17:02:37 -0600 | [diff] [blame] | 25 | sd.getCalloutList(j); |
Zane Shelley | f685afd | 2021-02-15 15:39:44 -0600 | [diff] [blame] | 26 | |
| 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 | } |