use domain::{KeyMapping, Value}; use std::collections::BTreeMap; #[test] fn extracts_value_at_path_and_renames_key() { let mapping = KeyMapping { source_path: "$.main.temp".into(), target_key: "temperature".into(), }; let raw = Value::Object(BTreeMap::from([( "main".into(), Value::Object(BTreeMap::from([("temp".into(), Value::Number(5.4))])), )])); let result = mapping.extract(&raw); assert_eq!(result, Some(("temperature".into(), Value::Number(5.4)))); } #[test] fn returns_none_when_path_does_not_match() { let mapping = KeyMapping { source_path: "$.missing.path".into(), target_key: "value".into(), }; let raw = Value::Object(BTreeMap::from([("other".into(), Value::Number(1.0))])); assert_eq!(mapping.extract(&raw), None); }