diff --git a/rust/pact_matching/src/generators/bodies.rs b/rust/pact_matching/src/generators/bodies.rs index a6c6344cf..49252a9cb 100644 --- a/rust/pact_matching/src/generators/bodies.rs +++ b/rust/pact_matching/src/generators/bodies.rs @@ -13,7 +13,7 @@ use pact_models::path_exp::DocPath; use pact_models::plugins::PluginData; #[cfg(feature = "xml")] use pact_models::xml_utils::parse_bytes; -#[cfg(feature = "xml")] use crate::generators::XmlHandler; +#[cfg(feature = "xml")] use pact_models::generators::xml::XmlHandler; #[cfg(feature = "form_urlencoded")] use pact_models::generators::form_urlencoded::FormUrlEncodedHandler; @@ -168,10 +168,10 @@ mod tests { } #[tokio::test] - async fn do_not_apply_generator_to_xml_body_because_unimplemented() { + async fn apply_generator_to_xml_body_test() { let body = OptionalBody::Present("100".into(), None, None); expect!(generators_process_body(&GeneratorTestMode::Provider, &body, Some(XML.clone()), - &hashmap!{}, &hashmap!{DocPath::new_unwrap("$.name") => Generator::RandomInt(0, 10)}, &DefaultVariantMatcher{}, &vec![], &hashmap!{}).await.unwrap()).to(be_equal_to(body)); + &hashmap!{}, &hashmap!{DocPath::new_unwrap("$.name") => Generator::RandomInt(0, 10)}, &DefaultVariantMatcher{}, &vec![], &hashmap!{}).await.unwrap()).to_not(be_equal_to(body)); } #[tokio::test] diff --git a/rust/pact_matching/src/generators/mod.rs b/rust/pact_matching/src/generators/mod.rs index 614167e7e..72dfd792d 100644 --- a/rust/pact_matching/src/generators/mod.rs +++ b/rust/pact_matching/src/generators/mod.rs @@ -23,7 +23,6 @@ use pact_models::v4::async_message::AsynchronousMessage; use pact_models::v4::message_parts::MessageContents; use pact_models::v4::sync_message::SynchronousMessage; use serde_json::{self, Value}; -#[cfg(feature = "xml")] use sxd_document::dom::Document; use tracing::{debug, error, trace}; use crate::{CoreMatchingContext, DiffConfig, MatchingContext}; @@ -31,36 +30,6 @@ use crate::json::compare_json; pub mod bodies; -/// Implementation of a content type handler for XML (currently unimplemented). -#[cfg(feature = "xml")] -pub struct XmlHandler<'a> { - /// XML document to apply the generators to. - pub value: Document<'a> -} - -#[cfg(feature = "xml")] -impl <'a> pact_models::generators::ContentTypeHandler> for XmlHandler<'a> { - fn process_body( - &mut self, - _generators: &HashMap, - _mode: &GeneratorTestMode, - _context: &HashMap<&str, Value>, - _matcher: &Box - ) -> Result { - error!("UNIMPLEMENTED: Generators are not currently supported with XML"); - Err("Generators are not supported with XML".to_string()) - } - - fn apply_key( - &mut self, - _key: &DocPath, - _generator: &dyn GenerateValue>, - _context: &HashMap<&str, Value>, - _matcher: &Box - ) { - error!("UNIMPLEMENTED: Generators are not currently supported with XML"); - } -} /// Apply the generators to the body, returning a new body #[deprecated(note = "moved to the generators::bodies module", since = "0.12.16")]