@@ -0,0 +1,3436 @@
+/*%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.context;%0A%0Aimport org.apache.shardingsphere.encrypt.rule.EncryptColumn;%0Aimport org.apache.shardingsphere.encrypt.rule.EncryptRule;%0Aimport org.apache.shardingsphere.encrypt.rule.EncryptTable;%0Aimport org.apache.shardingsphere.encrypt.spi.context.EncryptColumnDataType;%0Aimport org.apache.shardingsphere.encrypt.spi.context.EncryptContext;%0Aimport org.junit.Test;%0A%0Aimport java.sql.Types;%0Aimport java.util.LinkedHashMap;%0Aimport java.util.Map;%0Aimport java.util.Optional;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic final class EncryptContextBuilderTest %7B%0A%0A    @Test%0A    public void assertBuildSuccessfully() %7B%0A        EncryptColumn encryptColumn = mockEncryptColumn();%0A        EncryptTable encryptTable = mock(EncryptTable.class);%0A        when(encryptTable.findEncryptColumn(%22cipher%22)).thenReturn(Optional.of(encryptColumn));%0A        EncryptRule encryptRule = mock(EncryptRule.class);%0A        when(encryptRule.findEncryptTable(%22test%22)).thenReturn(Optional.of(encryptTable));%0A        EncryptContext encryptContext = EncryptContextBuilder.build(%22test%22, %22test%22, %22cipher%22, encryptRule);%0A        assertThat(encryptContext.getLogicDataType().get().getTypeName(), is(%22int(20) unsigned not null default 0%22));%0A        assertThat(encryptContext.getCipherDataType().get().getTypeName(), is(%22varchar(200) not null default ''%22));%0A        assertThat(encryptContext.getAssistedQueryDataType().get().getTypeName(), is(%22varchar(200) not null%22));%0A        assertThat(encryptContext.getPlainDataType().get().getTypeName(), is(%22int(20) unsigned not null default 0%22));%0A    %7D%0A%0A    private EncryptColumn mockEncryptColumn() %7B%0A        Map%3CString, Integer%3E dataTypes = new LinkedHashMap%3C%3E();%0A        dataTypes.put(%22int%22, Types.INTEGER);%0A        dataTypes.put(%22varchar%22, Types.VARCHAR);%0A        EncryptColumnDataType logicDataType = new EncryptColumnDataType(%22int(20) unsigned not null default 0%22, dataTypes);%0A        EncryptColumnDataType cipherDataType = new EncryptColumnDataType(%22varchar(200) not null default ''%22, dataTypes);%0A        EncryptColumnDataType assistedQueryDataType = new EncryptColumnDataType(%22varchar(200) not null%22, dataTypes);%0A        EncryptColumnDataType plainDataType = new EncryptColumnDataType(%22int(20) unsigned not null default 0%22, dataTypes);%0A        return new EncryptColumn(logicDataType, %22cipher_certificate_number%22, cipherDataType,%0A                %22assisted_certificate_number%22, assistedQueryDataType, %22certificate_number_plain%22, plainDataType, %22test%22);%0A    %7D%0A%7D%0A

Add more unit test for EncryptContextBuilder (#15189)