diff --git a/parsers/src/pubsub/owner.rs b/parsers/src/pubsub/owner.rs index ee98f85..93cb8ef 100644 --- a/parsers/src/pubsub/owner.rs +++ b/parsers/src/pubsub/owner.rs @@ -223,22 +223,12 @@ mod tests { let pubsub = PubSubOwner::Configure(Configure { node: Some(NodeName(String::from("foo"))), - form: Some(DataForm { - type_: DataFormType::Submit, - form_type: Some(String::from(ns::PUBSUB_CONFIGURE)), - title: None, - instructions: None, - fields: vec![Field { - var: Some(String::from("pubsub#access_model")), - type_: FieldType::ListSingle, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![String::from("whitelist")], - media: vec![], - }], - }), + form: Some(DataForm::new( + DataFormType::Submit, + ns::PUBSUB_CONFIGURE, + vec![Field::new("pubsub#access_model", FieldType::ListSingle) + .with_value("whitelist")], + )), }); let elem2 = Element::from(pubsub); @@ -271,22 +261,12 @@ mod tests { let elem1 = elem.clone(); let pubsub = PubSubOwner::Default(Default { - form: Some(DataForm { - type_: DataFormType::Submit, - form_type: Some(String::from(ns::PUBSUB_CONFIGURE)), - title: None, - instructions: None, - fields: vec![Field { - var: Some(String::from("pubsub#access_model")), - type_: FieldType::ListSingle, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![String::from("whitelist")], - media: vec![], - }], - }), + form: Some(DataForm::new( + DataFormType::Submit, + ns::PUBSUB_CONFIGURE, + vec![Field::new("pubsub#access_model", FieldType::ListSingle) + .with_value("whitelist")], + )), }); let elem2 = Element::from(pubsub); diff --git a/parsers/src/pubsub/pubsub.rs b/parsers/src/pubsub/pubsub.rs index b8a3f47..f087ef6 100644 --- a/parsers/src/pubsub/pubsub.rs +++ b/parsers/src/pubsub/pubsub.rs @@ -615,22 +615,12 @@ mod tests { node: Some(NodeName(String::from("foo"))), }, configure: Some(Configure { - form: Some(DataForm { - type_: DataFormType::Submit, - form_type: Some(String::from(ns::PUBSUB_CONFIGURE)), - title: None, - instructions: None, - fields: vec![Field { - var: Some(String::from("pubsub#access_model")), - type_: FieldType::ListSingle, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![String::from("whitelist")], - media: vec![], - }], - }), + form: Some(DataForm::new( + DataFormType::Submit, + ns::PUBSUB_CONFIGURE, + vec![Field::new("pubsub#access_model", FieldType::ListSingle) + .with_value("whitelist")], + )), }), }; diff --git a/parsers/src/server_info.rs b/parsers/src/server_info.rs index 4bd4955..61b84b4 100644 --- a/parsers/src/server_info.rs +++ b/parsers/src/server_info.rs @@ -116,81 +116,24 @@ mod tests { #[test] fn test_simple() { - let form = DataForm { - type_: DataFormType::Result_, - form_type: Some(String::from(ns::SERVER_INFO)), - title: None, - instructions: None, - fields: vec![ - Field { - var: Some(String::from("abuse-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![], - media: vec![], - }, - Field { - var: Some(String::from("admin-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![ - String::from("xmpp:admin@foo.bar"), - String::from("https://foo.bar/chat/"), - String::from("mailto:admin@foo.bar"), - ], - media: vec![], - }, - Field { - var: Some(String::from("feedback-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![], - media: vec![], - }, - Field { - var: Some(String::from("sales-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![], - media: vec![], - }, - Field { - var: Some(String::from("security-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![ - String::from("xmpp:security@foo.bar"), - String::from("mailto:security@foo.bar"), - ], - media: vec![], - }, - Field { - var: Some(String::from("support-addresses")), - type_: FieldType::ListMulti, - label: None, - required: false, - desc: None, - options: vec![], - values: vec![String::from("mailto:support@foo.bar")], - media: vec![], - }, + let form = DataForm::new( + DataFormType::Result_, + ns::SERVER_INFO, + vec![ + Field::new("abuse-addresses", FieldType::ListMulti), + Field::new("admin-addresses", FieldType::ListMulti) + .with_value("xmpp:admin@foo.bar") + .with_value("https://foo.bar/chat/") + .with_value("mailto:admin@foo.bar"), + Field::new("feedback-addresses", FieldType::ListMulti), + Field::new("sales-addresses", FieldType::ListMulti), + Field::new("security-addresses", FieldType::ListMulti) + .with_value("xmpp:security@foo.bar") + .with_value("mailto:security@foo.bar"), + Field::new("support-addresses", FieldType::ListMulti) + .with_value("mailto:support@foo.bar"), ], - }; + ); let server_info = ServerInfo { abuse: vec![],