fn test_properties_conversion()

in sdk/core/azure_core_amqp/src/fe2o3/messaging/message_fields.rs [428:485]


fn test_properties_conversion() {
    use std::time::{SystemTime, UNIX_EPOCH};

    {
        let properties = fe2o3_amqp_types::messaging::Properties {
            message_id: Some(fe2o3_amqp_types::messaging::MessageId::String(
                "test".into(),
            )),
            user_id: Some(vec![1, 2, 3].into()),
            to: Some("to".into()),
            subject: Some("subject".into()),
            reply_to: Some("reply_to".into()),
            correlation_id: Some("correlation_id".to_string().into()),
            content_type: Some("content_type".into()),
            content_encoding: Some("content_encoding".into()),
            absolute_expiry_time: Some(fe2o3_amqp_types::primitives::Timestamp::from(1)),
            creation_time: Some(fe2o3_amqp_types::primitives::Timestamp::from(2)),
            group_id: Some("group_id".into()),
            group_sequence: Some(3),
            reply_to_group_id: Some("reply_to_group_id".into()),
        };

        let amqp_properties = AmqpMessageProperties::from(properties.clone());
        let roundtrip_properties = fe2o3_amqp_types::messaging::Properties::from(amqp_properties);
        assert_eq!(properties, roundtrip_properties);
    }

    {
        let time_now = SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as i64;

        // Round trip time_now through milliseconds to round down from nanoseconds.
        let time_now: SystemTime = UNIX_EPOCH + Duration::from_millis(time_now as u64);

        let properties = AmqpMessageProperties {
            absolute_expiry_time: Some(time_now.into()),
            content_encoding: Some(crate::value::AmqpSymbol("content_encoding".to_string())),
            content_type: Some(crate::value::AmqpSymbol("content_type".to_string())),
            correlation_id: Some("correlation_id".into()),
            creation_time: Some(time_now.into()),
            group_id: Some("group_id".to_string()),
            group_sequence: Some(3),
            message_id: Some("test".into()),
            reply_to: Some("reply_to".to_string()),
            reply_to_group_id: Some("reply_to_group_id".to_string()),
            subject: Some("subject".to_string()),
            to: Some("to".to_string()),
            user_id: Some(vec![1, 2, 3]),
        };

        let fe2o3_properties: fe2o3_amqp_types::messaging::Properties = properties.clone().into();

        let amqp_round_trip = AmqpMessageProperties::from(fe2o3_properties);
        assert_eq!(properties, amqp_round_trip);
    }
}