/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.proxy.transport.mysql.packet.handshake;

import com.google.common.primitives.Bytes;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public final class AuthPluginDataTest {
    
    private AuthPluginData authPluginData;
    
    private final byte[] part1 = {106, 105, 55, 122, 117, 98, 115, 109};
    
    private final byte[] part2 = {68, 102, 53, 122, 65, 49, 84, 79, 85, 115, 116, 113};
    
    @Before
    public void setUp() {
        authPluginData = new AuthPluginData(part1, part2);
    }
    
    @Test
    public void assertGetAuthPluginData() {
        assertThat(authPluginData.getAuthPluginData(), is(Bytes.concat(part1, part2)));
    }
    
    @Test
    public void assertGetAuthPluginDataPart1() {
        assertThat(authPluginData.getAuthPluginDataPart1(), is(part1));
    }
    
    @Test
    public void assertGetAuthPluginDataPart2() {
        assertThat(authPluginData.getAuthPluginDataPart2(), is(part2));
    }
    
    @Test
    public void assertGetAuthPluginDataWithoutArguments() {
        AuthPluginData authPluginData = new AuthPluginData();
        assertThat(authPluginData.getAuthPluginData().length, is(20));
    }
}

@@ -727,33 +727,8 @@
 es;%0A
-import org.junit.Before;%0A
 impo
@@ -888,78 +888,80 @@
     
-private AuthPluginData authPluginData;
+@Test%0A    public void assertGetAuthPluginData() %7B
 %0A    
-%0A
     
-private final byte%5B%5D p
+byte%5B%5D actualP
 art1
@@ -1011,35 +1011,26 @@
     
-%0A
     
-private final byte%5B%5D p
+byte%5B%5D actualP
 art2
@@ -1095,56 +1095,13 @@
     
-%0A
     
-@Before%0A    public void setUp() %7B%0A        a
+A
 uthP
@@ -1102,32 +1102,39 @@
  AuthPluginData 
+actual 
 = new AuthPlugin
@@ -1138,24 +1138,36 @@
 ginData(
-part1, p
+actualPart1, actualP
 art2);%0A 
@@ -1173,68 +1173,143 @@
     
-%7D%0A
     
-%0A    @Test%0A    public void assertGetAuthPluginData() %7B
+assertThat(actual.getAuthPluginDataPart1(), is(actualPart1));%0A        assertThat(actual.getAuthPluginDataPart2(), is(actualPart2));
 %0A   
@@ -1321,37 +1321,29 @@
 assertThat(a
-uthPluginData
+ctual
 .getAuthPlug
@@ -1372,16 +1372,28 @@
 cat(
-part1, p
+actualPart1, actualP
 art2
@@ -1461,136 +1461,65 @@
 Data
-Part1() %7B%0A        assertThat(authPluginData.getAuthPluginDataPart1(), is(part1));%0A    %7D%0A    %0A    @Test%0A    public void assertGet
+WithoutArguments() %7B%0A        AuthPluginData actual = new 
 Auth
@@ -1532,17 +1532,11 @@
 Data
-Part2() %7B
+();
 %0A   
@@ -1548,37 +1548,29 @@
 assertThat(a
-uthPluginData
+ctual
 .getAuthPlug
@@ -1583,29 +1583,32 @@
 Part
-2(), is(part2
+1().length, is(8
 ));%0A    
 %7D%0A  
@@ -1607,144 +1607,69 @@
     
-%7D%0A
     
-%0A    @Test%0A    public void assertGetAuthPluginDataWithoutArguments() %7B%0A        AuthPluginData authPluginData = new AuthPluginData(
+assertThat(actual.getAuthPluginDataPart2().length, is(12)
 );%0A 
@@ -1687,29 +1687,21 @@
 rtThat(a
-uthPluginData
+ctual
 .getAuth

refactor AuthPluginDataTest