/*
 * 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.core.parse.rule.registry.statement;

import org.apache.shardingsphere.core.parse.rule.jaxb.entity.extractor.ExtractorRuleDefinitionEntity;
import org.apache.shardingsphere.core.parse.rule.jaxb.loader.extractor.ExtractorRuleDefinitionEntityLoader;
import org.apache.shardingsphere.core.parse.rule.jaxb.loader.statement.SQLStatementRuleDefinitionEntityLoader;
import org.apache.shardingsphere.core.parse.rule.registry.extractor.ExtractorRuleDefinition;
import org.junit.Test;

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

public final class SQLStatementRuleDefinitionTest {
    
    @Test
    public void assertGetSQLStatementRule() {
        ExtractorRuleDefinitionEntity extractorRuleDefinitionEntity =
                new ExtractorRuleDefinitionEntityLoader().load("META-INF/parsing-rule-definition/extractor-rule-definition.xml");
        SQLStatementRuleDefinition sqlStatementRuleDefinition = new SQLStatementRuleDefinition(
                new SQLStatementRuleDefinitionEntityLoader().load("META-INF/parsing-rule-definition/sql-statement-rule-definition.xml"), new ExtractorRuleDefinition(extractorRuleDefinitionEntity));
        SQLStatementRule sqlStatementRule = sqlStatementRuleDefinition.getSQLStatementRule("SelectContext");
        assertThat(sqlStatementRule.getContextName(), is("select"));
        assertThat(sqlStatementRule.getSqlStatementClass().getName(), is("org.apache.shardingsphere.core.parse.sql.statement.dml.SelectStatement"));
        assertThat(sqlStatementRule.getExtractors().size(), is(3));
        assertTrue(sqlStatementRule.getOptimizer().isPresent());
    }
}

@@ -1281,16 +1281,46 @@
 nition;%0A
+import org.junit.BeforeClass;%0A
 import o
@@ -1334,16 +1334,16 @@
 t.Test;%0A
-
 %0Aimport 
@@ -1531,55 +1531,128 @@
     
-@Test%0A    public void assertGetSQLStatementRule
+private static SQLStatementRuleDefinition sqlStatementRuleDefinition;%0A    %0A    @BeforeClass%0A    public static void setUp
 () %7B
@@ -1864,35 +1864,8 @@
     
-SQLStatementRuleDefinition 
 sqlS
@@ -2115,24 +2115,91 @@
 onEntity));%0A
+    %7D%0A    %0A    @Test%0A    public void assertSelectStatementRule() %7B%0A
         SQLS
@@ -2577,24 +2577,24 @@
 (), is(3));%0A
-
         asse
@@ -2652,10 +2652,254 @@
 ;%0A    %7D%0A
+    %0A    @Test%0A    public void assertDeleteStatementRule() %7B%0A        SQLStatementRule sqlStatementRule = sqlStatementRuleDefinition.getSQLStatementRule(%22DeleteContext%22);%0A        assertThat(sqlStatementRule.getExtractors().size(), is(0));%0A    %7D%0A
 %7D%0A

add assertDeleteStatementRule()