/*
 * 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.core.keygen;

import io.shardingsphere.core.keygen.generator.KeyGenerator;
import io.shardingsphere.core.keygen.generator.SnowflakeKeyGenerator;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.junit.Test;

import java.util.Properties;

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

public final class KeyGeneratorFactoryTest {
    
    @Test
    public void assertCreateKeyGeneratorSuccess() {
        assertThat(KeyGeneratorFactory.newInstance("SNOWFLAKE"), instanceOf(SnowflakeKeyGenerator.class));
    }
    
    @Test(expected = IllegalArgumentException.class)
    public void assertCreateKeyGeneratorFailureWithInstantiationError() {
        KeyGeneratorFactory.newInstance("instantiation");
    }
    
    @Test(expected = IllegalArgumentException.class)
    public void assertCreateKeyGeneratorFailureWithIllegalAccess() {
        KeyGeneratorFactory.newInstance("illegalAccess");
    }
    
    @RequiredArgsConstructor
    public static final class InstantiationKeyGenerator implements KeyGenerator {
        
        @Getter
        private final String type = "instantiation";
        
        private final int field;
    
        @Getter
        @Setter
        private Properties properties = new Properties();
        
        @Override
        public Comparable<?> generateKey() {
            return null;
        }
    }
    
    @NoArgsConstructor(access = AccessLevel.PRIVATE)
    public static final class IllegalAccessKeyGenerator implements KeyGenerator {
    
        @Getter
        private final String type = "illegalAccess";
    
        @Getter
        @Setter
        private Properties properties = new Properties();
        
        @Override
        public Comparable<?> generateKey() {
            return null;
        }
    }
}

@@ -687,37 +687,48 @@
 ore.
-keygen.generator.KeyGenerator
+exception.ShardingConfigurationException
 ;%0Aim
@@ -806,195 +806,22 @@
 ort 
-lombok.AccessLevel;%0Aimport lombok.Getter;%0Aimport lombok.NoArgsConstructor;%0Aimport lombok.RequiredArgsConstructor;%0Aimport lombok.Setter;%0Aimport org.junit.Test;%0A%0Aimport java.util.Properties
+org.junit.Test
 ;%0A%0Ai
@@ -1162,39 +1162,45 @@
 (expected = 
-IllegalArgument
+ShardingConfiguration
 Exception.cl
@@ -1346,1063 +1346,6 @@
   %7D%0A
-    %0A    @Test(expected = IllegalArgumentException.class)%0A    public void assertCreateKeyGeneratorFailureWithIllegalAccess() %7B%0A        KeyGeneratorFactory.newInstance(%22illegalAccess%22);%0A    %7D%0A    %0A    @RequiredArgsConstructor%0A    public static final class InstantiationKeyGenerator implements KeyGenerator %7B%0A        %0A        @Getter%0A        private final String type = %22instantiation%22;%0A        %0A        private final int field;%0A    %0A        @Getter%0A        @Setter%0A        private Properties properties = new Properties();%0A        %0A        @Override%0A        public Comparable%3C?%3E generateKey() %7B%0A            return null;%0A        %7D%0A    %7D%0A    %0A    @NoArgsConstructor(access = AccessLevel.PRIVATE)%0A    public static final class IllegalAccessKeyGenerator implements KeyGenerator %7B%0A    %0A        @Getter%0A        private final String type = %22illegalAccess%22;%0A    %0A        @Getter%0A        @Setter%0A        private Properties properties = new Properties();%0A        %0A        @Override%0A        public Comparable%3C?%3E generateKey() %7B%0A            return null;%0A        %7D%0A    %7D%0A
 %7D%0A

rewrite tests