Skip to content

Commit

Permalink
fix getName
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunrisea committed Dec 9, 2024
1 parent fc6cf8e commit 5ab9cc3
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ public interface ConfigCacheFactory {
*
* @return the config cache factory name
*/
public String getConfigCacheFactoryName();
public String getName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public class ConfigCacheFactoryDelegate {
private ConfigCacheFactoryDelegate() {
Collection<ConfigCacheFactory> configCacheFactories = NacosServiceLoader.load(ConfigCacheFactory.class);
for (ConfigCacheFactory each : configCacheFactories) {
if (StringUtils.isEmpty(each.getConfigCacheFactoryName())) {
if (StringUtils.isEmpty(each.getName())) {
LOGGER.warn(
"[ConfigCacheFactoryDelegate] Load ConfigCacheFactory({}) ConfigFactroyName (null/empty) fail. "
+ "Please add ConfigFactoryName to resolve", each.getClass().getName());
continue;
}
LOGGER.info(
"[ConfigCacheFactoryDelegate] Load ConfigCacheFactory({}) ConfigCacheFactoryName({}) successfully. ",
each.getClass().getName(), each.getConfigCacheFactoryName());
if (StringUtils.equals(configCacheFactoryType, each.getConfigCacheFactoryName())) {
each.getClass().getName(), each.getName());
if (StringUtils.equals(configCacheFactoryType, each.getName())) {
LOGGER.info("[ConfigCacheFactoryDelegate] Matched ConfigCacheFactory found,set configCacheFactory={}",
each.getClass().getName());
this.configCacheFactory = each;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface ConfigCachePostProcessor {
*
* @return the post processor name
*/
public String getPostProcessorName();
public String getName();

/**
* Post process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public class ConfigCachePostProcessorDelegate {
private ConfigCachePostProcessorDelegate() {
Collection<ConfigCachePostProcessor> processors = NacosServiceLoader.load(ConfigCachePostProcessor.class);
for (ConfigCachePostProcessor processor : processors) {
if (StringUtils.isEmpty(processor.getPostProcessorName())) {
if (StringUtils.isEmpty(processor.getName())) {
LOGGER.warn(
"[ConfigCachePostProcessorDelegate] Load ConfigCachePostProcessor({}) PostProcessorName(null/empty) fail. "
+ "Please add PostProcessorName to resolve", processor.getClass().getName());
continue;
}
LOGGER.info(
"[ConfigCachePostProcessorDelegate] Load ConfigCachePostProcessor({}) PostProcessorName({}) successfully. ",
processor.getClass().getName(), processor.getPostProcessorName());
if (StringUtils.equals(configCacheMd5PostProcessorType, processor.getPostProcessorName())) {
processor.getClass().getName(), processor.getName());
if (StringUtils.equals(configCacheMd5PostProcessorType, processor.getName())) {
LOGGER.info(
"[ConfigCachePostProcessorDelegate] Matched ConfigCachePostProcessor found,set configCacheFactory={}",
processor.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ConfigCacheGray createConfigCacheGray() {
}

@Override
public String getConfigCacheFactoryName() {
public String getName() {
return "nacos";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class NacosConfigCachePostProcessor implements ConfigCachePostProcessor {

@Override
public String getPostProcessorName() {
public String getName() {
return "nacos";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface Md5Comparator {
*
* @return the md 5 comparator name
*/
public String getMd5ComparatorName();
public String getName();

/**
* Compare md 5 list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public class Md5ComparatorDelegate {
private Md5ComparatorDelegate() {
Collection<Md5Comparator> md5Comparators = NacosServiceLoader.load(Md5Comparator.class);
for (Md5Comparator each : md5Comparators) {
if (StringUtils.isEmpty(each.getMd5ComparatorName())) {
if (StringUtils.isEmpty(each.getName())) {
LOGGER.warn(
"[Md5ComparatorDelegate] Load Md5Comparator({}) Md5ComparatorName(null/empty) fail. Please add Md5ComparatorName to resolve",
each.getClass().getName());
continue;
}
LOGGER.info("[Md5ComparatorDelegate] Load Md5Comparator({}) Md5ComparatorName({}) successfully.",
each.getClass().getName(), each.getMd5ComparatorName());
if (StringUtils.equals(md5ComparatorType, each.getMd5ComparatorName())) {
each.getClass().getName(), each.getName());
if (StringUtils.equals(md5ComparatorType, each.getName())) {
LOGGER.info("[Md5ComparatorDelegate] Matched Md5Comparator found,set md5Comparator={}",
each.getClass().getName());
md5Comparator = each;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class NacosMd5Comparator implements Md5Comparator {

@Override
public String getMd5ComparatorName() {
public String getName() {
return "nacos";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void test() {

@Test
public void test2() throws Exception {
when(nacosConfigCacheFactory.getConfigCacheFactoryName()).thenReturn("nacos");
when(nacosConfigCacheFactory.getName()).thenReturn("nacos");
when(nacosConfigCacheFactory.createConfigCache()).thenReturn(new ConfigCache());
when(nacosConfigCacheFactory.createConfigCacheGray()).thenReturn(new ConfigCacheGray());
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(ConfigCacheFactory.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void test1() {
@Test
void test2()
throws NoSuchFieldException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
when(mockConfigCacheMd5PostProcessor.getPostProcessorName()).thenReturn("nacos");
when(mockConfigCacheMd5PostProcessor.getName()).thenReturn("nacos");
doNothing().when(mockConfigCacheMd5PostProcessor).postProcess(null, null);
envUtilMockedStatic.when(() -> EnvUtil.getProperty("nacos.config.cache.type", "nacos")).thenReturn("nacos");
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(ConfigCachePostProcessor.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void testCreateConfigCache() {
}

@Test
public void testGetConfigCacheFactoryName() {
public void testGetName() {
NacosConfigCacheFactory nacosConfigCacheFactory = new NacosConfigCacheFactory();
assertEquals("nacos", nacosConfigCacheFactory.getConfigCacheFactoryName());
assertEquals("nacos", nacosConfigCacheFactory.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NacosConfigCachePostProcessorTest {
@Test
public void test() {
NacosConfigCachePostProcessor nacosConfigCacheMd5PostProcessor = new NacosConfigCachePostProcessor();
assertEquals("nacos", nacosConfigCacheMd5PostProcessor.getPostProcessorName());
assertEquals("nacos", nacosConfigCacheMd5PostProcessor.getName());
nacosConfigCacheMd5PostProcessor.postProcess(null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void test() {

@Test
public void test2() throws Exception {
when(nacosMd5Comparator.getMd5ComparatorName()).thenReturn("nacos");
when(nacosMd5Comparator.getName()).thenReturn("nacos");
envUtilMockedStatic.when(() -> EnvUtil.getProperty("nacos.config.cache.type", "nacos")).thenReturn("nacos");
nacosServiceLoaderMockedStatic.when(() -> NacosServiceLoader.load(Md5Comparator.class))
.thenReturn(Collections.singletonList(nacosMd5Comparator));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void tearDown() {
}

@Test
void getMd5ComparatorName() {
void getName() {
NacosMd5Comparator nacosMd5Comparator = new NacosMd5Comparator();
assertEquals("nacos", nacosMd5Comparator.getMd5ComparatorName());
assertEquals("nacos", nacosMd5Comparator.getName());
}

@Test
Expand Down

0 comments on commit 5ab9cc3

Please sign in to comment.