@@ -0,0 +1,3666 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.rocketmq.common.protocol.body;%0A%0Aimport org.apache.rocketmq.common.consumer.ConsumeFromWhere;%0Aimport org.apache.rocketmq.common.protocol.heartbeat.ConsumeType;%0Aimport org.apache.rocketmq.common.protocol.heartbeat.MessageModel;%0Aimport org.apache.rocketmq.common.protocol.heartbeat.SubscriptionData;%0Aimport org.apache.rocketmq.remoting.protocol.RemotingSerializable;%0Aimport org.junit.Test;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0Apublic class ConsumerConnectionTest %7B%0A%0A    @Test%0A    public void testFromJson() %7B%0A        ConsumerConnection consumerConnection = new ConsumerConnection();%0A        HashSet%3CConnection%3E connections = new HashSet%3CConnection%3E();%0A        Connection conn = new Connection();%0A        connections.add(conn);%0A%0A        ConcurrentHashMap%3CString/* Topic */, SubscriptionData%3E subscriptionTable = new ConcurrentHashMap%3CString, SubscriptionData%3E();%0A        SubscriptionData subscriptionData = new SubscriptionData();%0A        subscriptionTable.put(%22topicA%22, subscriptionData);%0A%0A        ConsumeType consumeType = ConsumeType.CONSUME_ACTIVELY;%0A        MessageModel messageModel = MessageModel.CLUSTERING;%0A        ConsumeFromWhere consumeFromWhere = ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET;%0A%0A        consumerConnection.setConnectionSet(connections);%0A        consumerConnection.setSubscriptionTable(subscriptionTable);%0A        consumerConnection.setConsumeType(consumeType);%0A        consumerConnection.setMessageModel(messageModel);%0A        consumerConnection.setConsumeFromWhere(consumeFromWhere);%0A%0A        String json = RemotingSerializable.toJson(consumerConnection, true);%0A        ConsumerConnection fromJson = RemotingSerializable.fromJson(json, ConsumerConnection.class);%0A        assertThat(fromJson.getConsumeType()).isEqualTo(ConsumeType.CONSUME_ACTIVELY);%0A        assertThat(fromJson.getMessageModel()).isEqualTo(MessageModel.CLUSTERING);%0A%0A        HashSet%3CConnection%3E connectionSet = fromJson.getConnectionSet();%0A        assertThat(connectionSet).isInstanceOf(Set.class);%0A%0A        SubscriptionData data = fromJson.getSubscriptionTable().get(%22topicA%22);%0A        assertThat(data).isExactlyInstanceOf(SubscriptionData.class);%0A    %7D%0A%0A    @Test%0A    public void testComputeMinVersion() %7B%0A        ConsumerConnection consumerConnection = new ConsumerConnection();%0A        HashSet%3CConnection%3E connections = new HashSet%3CConnection%3E();%0A        Connection conn1 = new Connection();%0A        conn1.setVersion(1);%0A        connections.add(conn1);%0A        Connection conn2 = new Connection();%0A        conn2.setVersion(10);%0A        connections.add(conn2);%0A        consumerConnection.setConnectionSet(connections);%0A%0A        int version = consumerConnection.computeMinVersion();%0A        assertThat(version).isEqualTo(1);%0A    %7D%0A%7D%0A

Add test cases for ConsumerConnection (#834)