@@ -0,0 +1,3437 @@
+/*%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.shardingsphere.proxy.frontend.mysql.command.query.builder;%0A%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.Arrays;%0A%0Aimport org.apache.shardingsphere.db.protocol.packet.DatabasePacket;%0Aimport org.apache.shardingsphere.proxy.backend.response.update.UpdateResponse;%0Aimport org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLColumnDefinition41Packet;%0Aimport org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;%0Aimport org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLEofPacket;%0Aimport org.apache.shardingsphere.db.protocol.mysql.packet.command.query.MySQLFieldCountPacket;%0Aimport org.apache.shardingsphere.infra.executor.sql.raw.execute.result.query.QueryHeader;%0Aimport org.apache.shardingsphere.proxy.backend.response.query.QueryResponse;%0A%0Aimport org.junit.Test;%0Aimport static org.hamcrest.CoreMatchers.instanceOf;%0Aimport static org.hamcrest.CoreMatchers.anyOf;%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic final class ResponsePacketBuilderTest %7B%0A%0A    @Test%0A    public void assertBuildQueryResponsePackets() %7B%0A        QueryHeader queryHeader1 = new QueryHeader(%22schema1%22, %22table1%22, %22columnLabel1%22, %22columnName1%22, 4, 5, 6, false, true, false, true);%0A        QueryHeader queryHeader2 = new QueryHeader(%22schema2%22, %22table2%22, %22columnLabel2%22, %22columnName2%22, 7, 8, 9, false, true, true, true);%0A        List%3CQueryHeader%3E queryHeaders = Arrays.asList(new QueryHeader%5B%5D%7BqueryHeader1, queryHeader2%7D);%0A        QueryResponse queryResponse = new QueryResponse(queryHeaders);%0A        Collection%3CDatabasePacket%3C?%3E%3E actual = ResponsePacketBuilder.buildQueryResponsePackets(queryResponse);%0A        assertThat(actual.stream().findAny().get(), anyOf(instanceOf(MySQLFieldCountPacket.class), instanceOf(MySQLColumnDefinition41Packet.class), instanceOf(MySQLEofPacket.class)));%0A    %7D%0A%0A    @Test%0A    public void assertBuildUpdateResponsePackets() %7B%0A        UpdateResponse updateResponse = mock(UpdateResponse.class);%0A        when(updateResponse.getUpdateCount()).thenReturn(10L);%0A        when(updateResponse.getLastInsertId()).thenReturn(100L);%0A        Collection%3CDatabasePacket%3C?%3E%3E actual = ResponsePacketBuilder.buildUpdateResponsePackets(updateResponse);%0A        MySQLOKPacket actualItem = (MySQLOKPacket) actual.stream().findAny().get();%0A        assertThat(actualItem, instanceOf(MySQLOKPacket.class));%0A        assertThat(actualItem.getAffectedRows(), is(10L));%0A        assertThat(actualItem.getLastInsertId(), is(100L));%0A    %7D%0A%7D%0A

Add test case for ResponsePacketBuilder (#7572)