use std::collections::BTreeMap;
use camel_api::EndpointUri;
use camel_component_api::UriConfig;
use camel_component_timer::TimerConfig;
#[test]
fn canonical_string_roundtrips_timer_from_uri() {
let params = BTreeMap::from([("period".to_string(), "2500".to_string())]);
let endpoint_uri = EndpointUri::try_from_uri_and_params("timer:tick", params)
.expect("valid base URI and params must construct EndpointUri");
let canonical = endpoint_uri.to_canonical_string();
assert_eq!(canonical, "timer:tick?period=2500");
let from_canonical = TimerConfig::from_uri(&canonical)
.expect("canonical string must re-parse via TimerConfig::from_uri");
let from_literal = TimerConfig::from_uri("timer:tick?period=2500")
.expect("literal URI must parse via TimerConfig::from_uri");
assert_eq!(
from_canonical.period, from_literal.period,
"period from canonical URI must equal period from literal URI"
);
assert_eq!(
format!("{from_canonical:?}"),
format!("{from_literal:?}"),
"canonical URI and literal URI must produce identical TimerConfig values"
);
}