/*
 * 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.api.config.encryptor;

import org.junit.Test;

import java.util.Properties;

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

public final class EncryptorConfigurationTest {
    
    @Test(expected = IllegalArgumentException.class)
    public void assertConstructorWithoutType() {
        new EncryptorConfiguration(null, "pwd", new Properties());
    }
    
    @Test(expected = IllegalArgumentException.class)
    public void assertConstructorWithoutColumns() {
        new EncryptorConfiguration("TEST", "", new Properties());
    }
    
    @Test
    public void assertConstructorWithoutAssistedQueryColumnsAndProperties() {
        EncryptorConfiguration actual = new EncryptorConfiguration("TEST", "pwd", null, null);
        assertThat(actual.getType(), is("TEST"));
        assertThat(actual.getColumns(), is("pwd"));
        assertThat(actual.getAssistedQueryColumns(), is(""));
        assertThat(actual.getProperties(), is(new Properties()));
    }
    
    @Test
    public void assertConstructorWithMinArguments() {
        Properties props = new Properties();
        props.setProperty("key", "value");
        EncryptorConfiguration actual = new EncryptorConfiguration("TEST", "pwd", props);
        assertThat(actual.getType(), is("TEST"));
        assertThat(actual.getColumns(), is("pwd"));
        assertThat(actual.getAssistedQueryColumns(), is(""));
        assertThat(actual.getProperties(), is(props));
    }
    
    @Test
    public void assertConstructorWithMaxArguments() {
        Properties props = new Properties();
        props.setProperty("key", "value");
        EncryptorConfiguration actual = new EncryptorConfiguration("TEST", "pwd", "pwd_query", props);
        assertThat(actual.getType(), is("TEST"));
        assertThat(actual.getColumns(), is("pwd"));
        assertThat(actual.getAssistedQueryColumns(), is("pwd_query"));
        assertThat(actual.getProperties(), is(props));
    }
}

@@ -1192,16 +1192,19 @@
 (null, %22
+tb.
 pwd%22, ne
@@ -1573,24 +1573,27 @@
 on(%22TEST%22, %22
+tb.
 pwd%22, null, 
@@ -1670,32 +1670,41 @@
 tThat(actual.get
+Qualified
 Columns(), is(%22p
@@ -1694,32 +1694,35 @@
 dColumns(), is(%22
+tb.
 pwd%22));%0A        
@@ -2076,24 +2076,27 @@
 on(%22TEST%22, %22
+tb.
 pwd%22, props)
@@ -2168,32 +2168,41 @@
 tThat(actual.get
+Qualified
 Columns(), is(%22p
@@ -2192,32 +2192,35 @@
 dColumns(), is(%22
+tb.
 pwd%22));%0A        
@@ -2571,15 +2571,21 @@
 %22, %22
+tb.
 pwd%22, %22
+tb.
 pwd_
@@ -2679,16 +2679,25 @@
 tual.get
+Qualified
 Columns(
@@ -2703,16 +2703,19 @@
 (), is(%22
+tb.
 pwd%22));%0A
@@ -2771,16 +2771,19 @@
 (), is(%22
+tb.
 pwd_quer

modify EncryptorConfigurationTest