use crate::{cdr, test, Version, Versioned as _};
#[test]
fn should_parse_v221_cdr_as_v211_with_unexpected_fields() {
const JSON: &str = include_str!("../../test_data/v221/lint/every_field_set/cdr.json");
test::setup();
let cdr::ParseReport {
cdr,
unexpected_fields,
} = cdr::parse_with_version(JSON, Version::V211).unwrap();
assert_eq!(
cdr.version(),
Version::V211,
"The v221 CDR was forced to be parsed as v211"
);
let mut unexpected_fields = unexpected_fields.to_strings();
unexpected_fields.sort();
assert_eq!(
unexpected_fields,
vec![
"$.cdr_location",
"$.cdr_location.address",
"$.cdr_location.city",
"$.cdr_location.connector_format",
"$.cdr_location.connector_id",
"$.cdr_location.connector_power_type",
"$.cdr_location.connector_standard",
"$.cdr_location.coordinates.latitude",
"$.cdr_location.coordinates.longitude",
"$.cdr_location.country",
"$.cdr_location.evse_id",
"$.cdr_location.evse_uid",
"$.cdr_location.id",
"$.cdr_location.name",
"$.cdr_location.postal_code",
"$.cdr_token",
"$.cdr_token.contract_id",
"$.cdr_token.type",
"$.cdr_token.uid",
"$.charging_periods.0.tariff_id",
"$.charging_periods.1.tariff_id",
"$.country_code",
"$.end_date_time",
"$.party_id",
"$.session_id",
"$.tariffs.0.country_code",
"$.tariffs.0.elements.0.price_components.0.vat",
"$.tariffs.0.elements.0.restrictions.max_current",
"$.tariffs.0.elements.0.restrictions.min_current",
"$.tariffs.0.elements.0.restrictions.reservation",
"$.tariffs.0.elements.1.price_components.0.vat",
"$.tariffs.0.elements.2.price_components.0.vat",
"$.tariffs.0.end_date_time",
"$.tariffs.0.energy_mix.energy_sources.0.percentage",
"$.tariffs.0.energy_mix.energy_sources.0.source",
"$.tariffs.0.energy_mix.energy_sources.1.percentage",
"$.tariffs.0.energy_mix.energy_sources.1.source",
"$.tariffs.0.energy_mix.energy_sources.2.percentage",
"$.tariffs.0.energy_mix.energy_sources.2.source",
"$.tariffs.0.energy_mix.energy_sources.3.percentage",
"$.tariffs.0.energy_mix.energy_sources.3.source",
"$.tariffs.0.energy_mix.energy_sources.4.percentage",
"$.tariffs.0.energy_mix.energy_sources.4.source",
"$.tariffs.0.energy_mix.environ_impact.0.amount",
"$.tariffs.0.energy_mix.environ_impact.0.category",
"$.tariffs.0.energy_mix.environ_impact.1.amount",
"$.tariffs.0.energy_mix.environ_impact.1.category",
"$.tariffs.0.max_price",
"$.tariffs.0.max_price.excl_vat",
"$.tariffs.0.max_price.incl_vat",
"$.tariffs.0.min_price",
"$.tariffs.0.min_price.excl_vat",
"$.tariffs.0.min_price.incl_vat",
"$.tariffs.0.party_id",
"$.tariffs.0.type",
"$.total_cost.excl_vat",
"$.total_cost.incl_vat",
"$.total_energy_cost",
"$.total_energy_cost.excl_vat",
"$.total_energy_cost.incl_vat",
"$.total_time_cost",
"$.total_time_cost.excl_vat",
"$.total_time_cost.incl_vat"
],
"The v221 Cdr should fail on the `total_cost` field as the internal structure differs between versions"
);
}