@@ -0,0 +1,2497 @@
+/*%0A * Copyright 1999-2022 Alibaba Group Holding Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * 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 com.alibaba.nacos.plugin.datasource;%0A%0Aimport com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;%0Aimport com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;%0Aimport com.alibaba.nacos.plugin.datasource.mapper.Mapper;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.Map;%0A%0Apublic class MapperManagerTest %7B%0A    %0A    @Test%0A    public void testInstance() %7B%0A        MapperManager instance = MapperManager.instance();%0A        Assert.assertNotNull(instance);%0A    %7D%0A    %0A    @Test%0A    public void testLoadInitial() throws NoSuchFieldException, IllegalAccessException %7B%0A        MapperManager instance = MapperManager.instance();%0A        instance.loadInitial();%0A        Class%3CMapperManager%3E mapperManagerClass = MapperManager.class;%0A        Field declaredField = mapperManagerClass.getDeclaredField(%22MAPPER_SPI_MAP%22);%0A        declaredField.setAccessible(true);%0A        Map%3CString, Map%3CString, Mapper%3E%3E map = (Map%3CString, Map%3CString, Mapper%3E%3E) declaredField.get(instance);%0A        Assert.assertEquals(2, map.size());%0A    %7D%0A    %0A    @Test%0A    public void testJoin() %7B%0A        MapperManager.join(new AbstractMapper() %7B%0A            @Override%0A            public String getTableName() %7B%0A                return %22test%22;%0A            %7D%0A            %0A            @Override%0A            public String getDataSource() %7B%0A                return DataSourceConstant.MYSQL;%0A            %7D%0A        %7D);%0A        MapperManager instance = MapperManager.instance();%0A        Mapper mapper = instance.findMapper(DataSourceConstant.MYSQL, %22test%22);%0A        Assert.assertNotNull(mapper);%0A    %7D%0A    %0A    @Test%0A    public void testFindMapper() %7B%0A        testJoin();%0A        MapperManager instance = MapperManager.instance();%0A        Mapper mapper = instance.findMapper(DataSourceConstant.MYSQL, %22test%22);%0A        Assert.assertNotNull(mapper);%0A    %7D%0A%7D

Add unit tests to MapperManager class (#9534)