/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

package org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.decorator;

import com.zaxxer.hikari.HikariDataSource;
import org.junit.Before;
import org.junit.Test;
import java.util.Properties;

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

public final class HikariJDBCParameterDecoratorTest {
    
    private HikariJDBCParameterDecorator hikariJDBCParameterDecorator;
    
    @Before
    public void setUp() {
        hikariJDBCParameterDecorator = new HikariJDBCParameterDecorator();
    }
    
    @Test
    public void assertGetTypeResultIsHikariDataSource() {
        assertEquals(HikariDataSource.class, hikariJDBCParameterDecorator.getType());
    }
    
    @Test
    public void assertDecoratedHikariDataSource() {
        HikariDataSource hikariDataSource = new HikariDataSource();
        hikariJDBCParameterDecorator.decorate(hikariDataSource);
        Properties properties = hikariDataSource.getDataSourceProperties();
        assertThat(properties.getProperty("useServerPrepStmts"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("cachePrepStmts"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("prepStmtCacheSize"), is("250"));
        assertThat(properties.getProperty("prepStmtCacheSqlLimit"), is("2048"));
        assertThat(properties.getProperty("useLocalSessionState"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("rewriteBatchedStatements"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("cacheResultSetMetadata"), is(Boolean.FALSE.toString()));
        assertThat(properties.getProperty("cacheServerConfiguration"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("elideSetAutoCommits"), is(Boolean.TRUE.toString()));
        assertThat(properties.getProperty("maintainTimeStats"), is(Boolean.FALSE.toString()));
        assertThat(properties.getProperty("netTimeoutForStreamingResults"), is("0"));
        assertThat(properties.getProperty("tinyInt1isBit"), is(Boolean.FALSE.toString()));
    }
}

@@ -933,33 +933,8 @@
 ce;%0A
-import org.junit.Before;%0A
 impo
@@ -952,16 +952,17 @@
 t.Test;%0A
+%0A
 import j
@@ -1064,22 +1064,20 @@
 t.assert
-Equals
+Same
 ;%0Aimport
@@ -1177,208 +1177,8 @@
    %0A
-    private HikariJDBCParameterDecorator hikariJDBCParameterDecorator;%0A    %0A    @Before%0A    public void setUp() %7B%0A        hikariJDBCParameterDecorator = new HikariJDBCParameterDecorator();%0A    %7D%0A    %0A
     
@@ -1259,14 +1259,12 @@
 sert
-Equals
+Same
 (Hik
@@ -1284,17 +1284,21 @@
 .class, 
-h
+new H
 ikariJDB
@@ -1316,16 +1316,18 @@
 ecorator
+()
 .getType
@@ -1480,17 +1480,21 @@
         
-h
+new H
 ikariJDB
@@ -1512,16 +1512,18 @@
 ecorator
+()
 .decorat
@@ -1566,21 +1566,16 @@
 ies prop
-ertie
 s = hika
@@ -1629,37 +1629,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22u
@@ -1719,37 +1719,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22c
@@ -1805,37 +1805,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22p
@@ -1876,37 +1876,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22p
@@ -1952,37 +1952,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22u
@@ -2044,37 +2044,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22r
@@ -2140,37 +2140,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22c
@@ -2235,37 +2235,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22c
@@ -2331,37 +2331,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22e
@@ -2422,37 +2422,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22m
@@ -2512,37 +2512,32 @@
  assertThat(prop
-ertie
 s.getProperty(%22n
@@ -2601,21 +2601,16 @@
 hat(prop
-ertie
 s.getPro

Refactor HikariJDBCParameterDecoratorTest