diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/ConfigRowMapperInjectorTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/ConfigRowMapperInjectorTest.java index 3e93e4f69c4..12edf1daa62 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/ConfigRowMapperInjectorTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/ConfigRowMapperInjectorTest.java @@ -22,10 +22,10 @@ import com.alibaba.nacos.config.server.model.ConfigInfo; import com.alibaba.nacos.config.server.model.ConfigInfo4Beta; import com.alibaba.nacos.config.server.model.ConfigInfo4Tag; -import com.alibaba.nacos.config.server.model.ConfigInfoAggr; import com.alibaba.nacos.config.server.model.ConfigInfoBase; import com.alibaba.nacos.config.server.model.ConfigInfoBetaWrapper; import com.alibaba.nacos.config.server.model.ConfigInfoChanged; +import com.alibaba.nacos.config.server.model.ConfigInfoGrayWrapper; import com.alibaba.nacos.config.server.model.ConfigInfoStateWrapper; import com.alibaba.nacos.config.server.model.ConfigInfoTagWrapper; import com.alibaba.nacos.config.server.model.ConfigInfoWrapper; @@ -55,8 +55,8 @@ class ConfigRowMapperInjectorTest { @Test void testInit() { ConfigRowMapperInjector configRowMapperInjector = new ConfigRowMapperInjector(); - assertEquals(ConfigRowMapperInjector.CONFIG_INFO_WRAPPER_ROW_MAPPER, - RowMapperManager.getRowMapper(ConfigRowMapperInjector.CONFIG_INFO_WRAPPER_ROW_MAPPER.getClass().getCanonicalName())); + assertEquals(ConfigRowMapperInjector.CONFIG_INFO_WRAPPER_ROW_MAPPER, RowMapperManager.getRowMapper( + ConfigRowMapperInjector.CONFIG_INFO_WRAPPER_ROW_MAPPER.getClass().getCanonicalName())); } @Test @@ -319,26 +319,37 @@ void testConfigInfoBaseRowMapper() throws SQLException { } @Test - void testConfigInfoAggrRowMapper() throws SQLException { + void testConfigInfoGrayRowMapper() throws SQLException { - ConfigInfoAggr preConfig = new ConfigInfoAggr(); + ConfigInfoGrayWrapper preConfig = new ConfigInfoGrayWrapper(); preConfig.setDataId("testDataId"); preConfig.setGroup("group_id11"); preConfig.setContent("content1123434t"); - preConfig.setDatumId("datum4567890"); + preConfig.setGrayName("grayName"); + preConfig.setGrayRule("rule12345"); preConfig.setTenant("tenang34567890"); preConfig.setAppName("app3456789"); + preConfig.setEncryptedDataKey("key12345"); + Timestamp timestamp = Timestamp.valueOf("2024-12-12 12:34:34"); ResultSetImpl resultSet = Mockito.mock(ResultSetImpl.class); Mockito.when(resultSet.getString(eq("data_id"))).thenReturn(preConfig.getDataId()); Mockito.when(resultSet.getString(eq("group_id"))).thenReturn(preConfig.getGroup()); Mockito.when(resultSet.getString(eq("tenant_id"))).thenReturn(preConfig.getTenant()); - Mockito.when(resultSet.getString(eq("datum_id"))).thenReturn(preConfig.getDatumId()); + Mockito.when(resultSet.getString(eq("gray_name"))).thenReturn(preConfig.getGrayName()); + Mockito.when(resultSet.getString(eq("app_name"))).thenReturn(preConfig.getAppName()); + + Mockito.when(resultSet.getString(eq("gray_rule"))).thenReturn(preConfig.getGrayRule()); + Mockito.when(resultSet.getTimestamp(eq("gmt_modified"))).thenReturn(timestamp); + Mockito.when(resultSet.getString(eq("content"))).thenReturn(preConfig.getContent()); Mockito.when(resultSet.getString(eq("app"))).thenReturn(preConfig.getAppName()); - ConfigRowMapperInjector.ConfigInfoAggrRowMapper configInfoWrapperRowMapper = new ConfigRowMapperInjector.ConfigInfoAggrRowMapper(); + Mockito.when(resultSet.getString(eq("encrypted_data_key"))).thenReturn(preConfig.getEncryptedDataKey()); + + ConfigRowMapperInjector.ConfigInfoGrayWrapperRowMapper configInfoWrapperRowMapper = new ConfigRowMapperInjector.ConfigInfoGrayWrapperRowMapper(); - ConfigInfoAggr configInfoWrapper = configInfoWrapperRowMapper.mapRow(resultSet, 10); + ConfigInfoGrayWrapper configInfoWrapper = configInfoWrapperRowMapper.mapRow(resultSet, 10); assertEquals(preConfig, configInfoWrapper); + assertEquals(timestamp.getTime(), configInfoWrapper.getLastModified()); } diff --git a/plugin/datasource/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.mapper.Mapper b/plugin/datasource/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.mapper.Mapper index d11d4ba59eb..0a7fa58522f 100644 --- a/plugin/datasource/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.mapper.Mapper +++ b/plugin/datasource/src/main/resources/META-INF/services/com.alibaba.nacos.plugin.datasource.mapper.Mapper @@ -14,7 +14,6 @@ # limitations under the License. # -com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoAggrMapperByMySql com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoBetaMapperByMySql com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoMapperByMySql com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoTagMapperByMySql @@ -25,7 +24,6 @@ com.alibaba.nacos.plugin.datasource.impl.mysql.TenantInfoMapperByMySql com.alibaba.nacos.plugin.datasource.impl.mysql.TenantCapacityMapperByMySql com.alibaba.nacos.plugin.datasource.impl.mysql.GroupCapacityMapperByMysql -com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoAggrMapperByDerby com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoBetaMapperByDerby com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoMapperByDerby com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoTagMapperByDerby diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/MapperManagerTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/MapperManagerTest.java index eff15277ce5..18a68933d3e 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/MapperManagerTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/MapperManagerTest.java @@ -18,7 +18,7 @@ import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.impl.mysql.AbstractMapperByMysql; -import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoAggrMapper; +import com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoGrayMapperByMySql; import com.alibaba.nacos.plugin.datasource.mapper.Mapper; import com.alibaba.nacos.plugin.datasource.mapper.TestMapper; import org.junit.jupiter.api.Test; @@ -78,7 +78,7 @@ void testFindMapper() { void testEnableDataSourceLogJoin() { MapperManager.join(new TestMapper()); MapperManager instance = MapperManager.instance(true); - ConfigInfoAggrMapper mapper = instance.findMapper(DataSourceConstant.MYSQL, "enable_data_source_log_test"); + ConfigInfoGrayMapperByMySql mapper = instance.findMapper(DataSourceConstant.MYSQL, "enable_data_source_log_test"); assertNotNull(mapper); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/mapper/TestMapper.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/mapper/TestMapper.java index 643d242e4da..2ac49c8cf71 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/mapper/TestMapper.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/mapper/TestMapper.java @@ -18,14 +18,14 @@ import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.impl.TestInterface; -import com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoAggrMapperByMySql; +import com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoGrayMapperByMySql; /** * Implement interfaces other than Mapper. just for test * * @author mikolls **/ -public class TestMapper extends ConfigInfoAggrMapperByMySql implements TestInterface { +public class TestMapper extends ConfigInfoGrayMapperByMySql implements TestInterface { @Override public String getTableName() {