@@ -0,0 +1,3226 @@
+/*%0A *  Copyright 1999-2018 Alibaba Group Holding Ltd.%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  you may not use this file except in compliance with the License.%0A *  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 io.seata.core.protocol;%0A%0Aimport io.netty.buffer.ByteBuf;%0Aimport io.netty.buffer.ByteBufAllocator;%0Aimport io.seata.core.protocol.transaction.GlobalBeginRequest;%0Aimport org.junit.Test;%0A%0Aimport java.util.ArrayList;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0A%0A/**%0A * The type MergedWarpMessageTest test.%0A *%0A * @author leizhiyuan%0A */%0Apublic class MergedWarpMessageTest %7B%0A%0A    @Test%0A    public void getTypeCode() %7B%0A        MergedWarpMessage mergedWarpMessage = new MergedWarpMessage();%0A        assertThat(mergedWarpMessage.getTypeCode()).isEqualTo(AbstractMessage.TYPE_SEATA_MERGE);%0A    %7D%0A%0A    @Test%0A    public void encode() %7B%0A        //you can run encode to get the data%0A        byte%5B%5D expect = new byte%5B%5D%7B0, 0, 0, 12, 0, 1, 0, 1, 0, 0, 11, -72, 0, 2, 120, 120%7D;%0A        MergedWarpMessage mergedWarpMessage = new MergedWarpMessage();%0A        final ArrayList%3CAbstractMessage%3E msgs = new ArrayList%3C%3E();%0A        final GlobalBeginRequest globalBeginRequest = buildGlobalBeginRequest();%0A        msgs.add(globalBeginRequest);%0A        mergedWarpMessage.msgs = msgs;%0A        byte%5B%5D result = mergedWarpMessage.encode();%0A        assertThat(expect).isEqualTo(result);%0A    %7D%0A%0A    @Test%0A    public void decode() %7B%0A        final GlobalBeginRequest globalBeginRequest = buildGlobalBeginRequest();%0A        byte%5B%5D result = new byte%5B%5D%7B0, 0, 0, 12, 0, 1, 0, 1, 0, 0, 11, -72, 0, 2, 120, 120%7D;%0A        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();%0A        MergedWarpMessage decodeResult = new MergedWarpMessage();%0A        decodeResult.decode(buffer.writeBytes(result));%0A        final AbstractMessage expected = decodeResult.msgs.get(0);%0A        assertThat(true).isEqualTo(expected instanceof GlobalBeginRequest);%0A        GlobalBeginRequest decodeGlobalBeginRequest = (GlobalBeginRequest) expected;%0A%0A        assertThat(globalBeginRequest.getTransactionName()).isEqualTo(decodeGlobalBeginRequest.getTransactionName());%0A        assertThat(globalBeginRequest.getTimeout()).isEqualTo(decodeGlobalBeginRequest.getTimeout());%0A        assertThat(globalBeginRequest.getTimeout()).isEqualTo(decodeGlobalBeginRequest.getTimeout());%0A        assertThat(globalBeginRequest.getTypeCode()).isEqualTo(decodeGlobalBeginRequest.getTypeCode());%0A        assertThat(%22xx%22).isEqualTo(decodeGlobalBeginRequest.getTransactionName());%0A    %7D%0A%0A    private GlobalBeginRequest buildGlobalBeginRequest() %7B%0A        final GlobalBeginRequest globalBeginRequest = new GlobalBeginRequest();%0A        globalBeginRequest.setTransactionName(%22xx%22);%0A        globalBeginRequest.setTimeout(3000);%0A        return globalBeginRequest;%0A    %7D%0A%7D

Add test for MergedWarpMessage (#822)