use rocketmq_model::common::attribute::topic_message_type::TopicMessageType as CommonTopicMessageType;
use rocketmq_model::common::config::TopicConfig as CommonTopicConfig;
use rocketmq_model::common::consistenthash::ConsistentHashRouter as CommonConsistentHashRouter;
use rocketmq_model::common::consistenthash::Node as CommonNode;
use rocketmq_model::common::message::message_queue::MessageQueue as CommonMessageQueue;
use rocketmq_model::common::TopicFilterType as CommonTopicFilterType;
use rocketmq_model::consistent_hash::ConsistentHashRouter;
use rocketmq_model::consistent_hash::Node;
use rocketmq_model::message::MessageQueue;
use rocketmq_model::topic::TopicConfig;
use rocketmq_model::topic::TopicFilterType;
use rocketmq_model::topic::TopicMessageType;
#[test]
fn common_paths_are_the_canonical_model_types() {
fn queue_identity(value: MessageQueue) -> CommonMessageQueue {
value
}
fn config_identity(value: TopicConfig) -> CommonTopicConfig {
value
}
fn filter_identity(value: TopicFilterType) -> CommonTopicFilterType {
value
}
fn message_type_identity(value: TopicMessageType) -> CommonTopicMessageType {
value
}
assert_eq!(queue_identity(MessageQueue::default()), CommonMessageQueue::default());
assert_eq!(config_identity(TopicConfig::default()), CommonTopicConfig::default());
assert_eq!(
filter_identity(TopicFilterType::MultiTag),
CommonTopicFilterType::MultiTag
);
assert_eq!(
message_type_identity(TopicMessageType::Transaction),
CommonTopicMessageType::Transaction
);
}
#[derive(Clone)]
struct TestNode(String);
impl Node for TestNode {
fn get_key(&self) -> &str {
&self.0
}
}
fn assert_common_node<T: CommonNode>(_value: &T) {}
#[test]
fn common_consistent_hash_path_is_the_canonical_model_type() {
fn identity(value: ConsistentHashRouter<TestNode>) -> CommonConsistentHashRouter<TestNode> {
value
}
let node = TestNode("node-a".to_owned());
assert_common_node(&node);
assert_eq!(identity(ConsistentHashRouter::new(vec![node], 2)).size(), 2);
}