/*
 * 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.shadow.distsql.converter;

import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.distsql.handler.converter.ShadowRuleStatementConverter;
import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSegment;
import org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowRuleSegment;
import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.junit.Test;

import java.util.Collections;
import java.util.Properties;

import static org.junit.Assert.assertEquals;

public final class ShadowRuleStatementConverterTest {
    
    @Test
    public void assertConvert() {
        ShadowRuleConfiguration config = ShadowRuleStatementConverter.convert(Collections.singleton(createTableRuleSegment()));
        assertEquals("source", config.getDataSources().get("ruleName").getSourceDataSourceName());
        assertEquals("shadow", config.getDataSources().get("ruleName").getShadowDataSourceName());
        assertEquals(1, config.getTables().size());
        assertEquals(1, config.getShadowAlgorithms().size());
        assertEquals("bar", config.getShadowAlgorithms().get("algorithmsName").getProps().get("foo"));
    }
    
    private ShadowRuleSegment createTableRuleSegment() {
        ShardingSphereServiceLoader.register(ShadowAlgorithm.class);
        Properties props = new Properties();
        props.setProperty("foo", "bar");
        return new ShadowRuleSegment("ruleName", "source", "shadow",
                Collections.singletonMap("t_order", Collections.singleton(new ShadowAlgorithmSegment("algorithmsName", new AlgorithmSegment("type", props)))));
    }
}

@@ -1483,16 +1483,60 @@
 rties;%0A%0A
+import static org.hamcrest.CoreMatchers.is;%0A
 import s
@@ -1564,22 +1564,20 @@
 t.assert
-Equals
+That
 ;%0A%0Apubli
@@ -1820,25 +1820,13 @@
 sert
-Equals(%22source%22, 
+That(
 conf
@@ -1878,32 +1878,46 @@
 DataSourceName()
+, is(%22source%22)
 );%0A        asser
@@ -1921,25 +1921,13 @@
 sert
-Equals(%22shadow%22, 
+That(
 conf
@@ -1987,16 +1987,30 @@
 ceName()
+, is(%22shadow%22)
 );%0A     
@@ -2014,34 +2014,29 @@
       assert
-Equals(1, 
+That(
 config.getTa
@@ -2040,32 +2040,39 @@
 tTables().size()
+, is(1)
 );%0A        asser
@@ -2076,18 +2076,13 @@
 sert
-Equals(1, 
+That(
 conf
@@ -2112,16 +2112,23 @@
 ).size()
+, is(1)
 );%0A     
@@ -2140,22 +2140,13 @@
 sert
-Equals(%22bar%22, 
+That(
 conf
@@ -2213,16 +2213,27 @@
 t(%22foo%22)
+, is(%22bar%22)
 );%0A    %7D

Use assertThat to instead of assertEquals. (#12602)