6 #include <gtest/gtest.h> 7 #include <aws/core/utils/StringUtils.h> 8 #include <aws/monitoring/model/MetricDatum.h> 30 const Aws::String mock_serialized_metric_datum{
31 R
"({"timestamp": 5, "metric_name": "awesomeness", "storage_resolution": 25, "unit": 1})" 36 Aws::Utils::DateTime ts(static_cast<int64_t>(5)); 37 EXPECT_EQ(result.GetTimestamp(), ts); 38 EXPECT_EQ(result.GetMetricName(), "awesomeness");
39 auto expected_counts = Aws::Vector<double>();
40 EXPECT_EQ(result.GetStorageResolution(), 25);
41 EXPECT_EQ(result.GetUnit(), Aws::CloudWatch::Model::StandardUnit::Seconds);
45 const Aws::String min_json = R
"({"metric_name": "minimum", "timestamp": 10})"; 48 EXPECT_EQ(result.GetMetricName(), "minimum");
52 const Aws::String bad_json =
"not json";
54 const Aws::String json_missing_values =
"{}";
59 const Aws::Utils::DateTime ts = Aws::Utils::DateTime::Now();
60 const Aws::String metric_name(
"cerealized");
61 const Aws::Vector<double> counts = {111, 222};
62 const int storage_resolution = 25;
63 const auto metric_unit = Aws::CloudWatch::Model::StandardUnit::Seconds;
64 const double value = 42;
66 metric_datum.SetTimestamp(ts);
67 metric_datum.SetMetricName(metric_name);
68 metric_datum.SetStorageResolution(storage_resolution);
69 metric_datum.SetUnit(metric_unit);
70 metric_datum.SetValue(value);
71 Aws::String serialized_metric_datum;
75 EXPECT_EQ(result.GetTimestamp().Millis(), ts.Millis());
76 EXPECT_EQ(result.GetMetricName(), metric_name);
77 EXPECT_EQ(result.GetStorageResolution(), storage_resolution);
78 EXPECT_EQ(result.GetUnit(), metric_unit);
79 EXPECT_EQ(result.GetValue(), value);
TEST_F(TestMetricSerialization, deserialize_returns_metric_datum)
Aws::String serializeMetricDatum(const MetricDatum &datum)
Aws::CloudWatch::Model::MetricDatum MetricDatum
MetricDatum deserializeMetricDatum(const Aws::String &basic_string)