@@ -0,0 +1,3465 @@
+/*%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 */%0Apackage org.apache.rocketmq.common.admin;%0A%0Aimport org.apache.rocketmq.common.message.MessageQueue;%0Aimport org.apache.rocketmq.remoting.protocol.RemotingSerializable;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A%0Apublic class TopicStatsTableTest %7B%0A%0A    private volatile TopicStatsTable topicStatsTable;%0A%0A    private static final String TEST_TOPIC = %22test_topic%22;%0A%0A    private static final String TEST_BROKER = %22test_broker%22;%0A%0A    private static final int QUEUE_ID = 1;%0A%0A    private static final long CURRENT_TIME_MILLIS = System.currentTimeMillis();%0A%0A    private static final long MAX_OFFSET = CURRENT_TIME_MILLIS + 100;%0A%0A    private static final long MIN_OFFSET = CURRENT_TIME_MILLIS - 100;%0A%0A    @Before%0A    public void buildTopicStatsTable() %7B%0A        HashMap%3CMessageQueue, TopicOffset%3E offsetTableMap = new HashMap%3CMessageQueue, TopicOffset%3E();%0A%0A        MessageQueue messageQueue = new MessageQueue(TEST_TOPIC, TEST_BROKER, QUEUE_ID);%0A%0A        TopicOffset topicOffset = new TopicOffset();%0A        topicOffset.setLastUpdateTimestamp(CURRENT_TIME_MILLIS);%0A        topicOffset.setMinOffset(MIN_OFFSET);%0A        topicOffset.setMaxOffset(MAX_OFFSET);%0A%0A        offsetTableMap.put(messageQueue, topicOffset);%0A%0A        topicStatsTable = new TopicStatsTable();%0A        topicStatsTable.setOffsetTable(offsetTableMap);%0A    %7D%0A%0A    @Test%0A    public void testGetOffsetTable() throws Exception %7B%0A        validateTopicStatsTable(topicStatsTable);%0A    %7D%0A%0A    @Test%0A    public void testFromJson() throws Exception %7B%0A        String json = RemotingSerializable.toJson(topicStatsTable, true);%0A        TopicStatsTable fromJson = RemotingSerializable.fromJson(json, TopicStatsTable.class);%0A%0A        validateTopicStatsTable(fromJson);%0A    %7D%0A%0A    private static void validateTopicStatsTable(TopicStatsTable topicStatsTable) throws Exception %7B%0A        Map.Entry%3CMessageQueue, TopicOffset%3E savedTopicStatsTableMap = topicStatsTable.getOffsetTable().entrySet().iterator().next();%0A        MessageQueue savedMessageQueue = savedTopicStatsTableMap.getKey();%0A        TopicOffset savedTopicOffset = savedTopicStatsTableMap.getValue();%0A%0A        Assert.assertTrue(savedMessageQueue.getTopic().equals(TEST_TOPIC));%0A        Assert.assertTrue(savedMessageQueue.getBrokerName().equals(TEST_BROKER));%0A        Assert.assertTrue(savedMessageQueue.getQueueId() == QUEUE_ID);%0A%0A        Assert.assertTrue(savedTopicOffset.getLastUpdateTimestamp() == CURRENT_TIME_MILLIS);%0A        Assert.assertTrue(savedTopicOffset.getMaxOffset() == MAX_OFFSET);%0A        Assert.assertTrue(savedTopicOffset.getMinOffset() == MIN_OFFSET);%0A    %7D%0A%0A%7D%0A

Add test cases for TopicStatsTable.java (#832)