@@ -0,0 +1,3148 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.shardingsphere.encrypt.metadata;%0A%0Aimport org.apache.shardingsphere.encrypt.rule.EncryptRule;%0Aimport org.apache.shardingsphere.infra.metadata.schema.spi.RuleMetaDataDecorator;%0Aimport org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;%0Aimport org.apache.shardingsphere.infra.spi.order.OrderedSPIRegistry;%0Aimport org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaData;%0Aimport org.apache.shardingsphere.sql.parser.binder.metadata.table.TableMetaData;%0Aimport org.junit.Test;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.Collections;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic final class EncryptMetaDataDecoratorTest %7B%0A    %0A    static %7B%0A        ShardingSphereServiceLoader.register(RuleMetaDataDecorator.class);%0A    %7D%0A    %0A    @Test%0A    public void assertDecorate() %7B%0A        EncryptRule rule = createEncryptRule();%0A        EncryptMetaDataDecorator decorator = (EncryptMetaDataDecorator) OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(rule), RuleMetaDataDecorator.class).get(rule);%0A        TableMetaData actual = decorator.decorate(%22t_encrypt%22, createTableMetaData(), rule);%0A        assertThat(actual.getColumns().size(), is(2));%0A        assertTrue(actual.getColumns().containsKey(%22id%22));%0A        assertTrue(actual.getColumns().containsKey(%22pwd%22));%0A    %7D%0A    %0A    private EncryptRule createEncryptRule() %7B%0A        EncryptRule result = mock(EncryptRule.class);%0A        when(result.getLogicColumnOfCipher(%22t_encrypt%22, %22pwd_cipher%22)).thenReturn(%22pwd%22);%0A        when(result.isCipherColumn(%22t_encrypt%22, %22pwd_cipher%22)).thenReturn(true);%0A        when(result.getAssistedQueryAndPlainColumns(%22t_encrypt%22)).thenReturn(Collections.singletonList(%22pwd_plain%22));%0A        return result;%0A    %7D%0A    %0A    private TableMetaData createTableMetaData() %7B%0A        Collection%3CColumnMetaData%3E columns = Arrays.asList(new ColumnMetaData(%22id%22, 1, %22int%22, true, true, true), %0A                new ColumnMetaData(%22pwd_cipher%22, 2, %22varchar%22, false, false, true), new ColumnMetaData(%22pwd_plain%22, 2, %22varchar%22, false, false, true));%0A        return new TableMetaData(columns, Collections.emptyList());%0A    %7D%0A%7D%0A

Add test case for EncryptMetaDataDecorator (#6818)