mirror of
				https://github.com/LamGC/ContentGrabbingJi.git
				synced 2025-10-31 08:36:56 +00:00 
			
		
		
		
	[Add][Change] Common 调整 FactoryInfo equals 判断细节, 添加对 FactoryInfo 的全覆盖单元测试;
[Change] FactoryInfo 调整 equals 方法, 移除优先级判断以防止因更新优先级导致出现同样组件有不同版本的情况; [Add] FactoryInfoTest 添加单元测试项(100%); [Add] CacheStoreSourceNoEqualFactory, FactoryInfoTestFactory, NameNoEqualFactoryA, NameNoEqualFactoryB, TooHighPriorityFactory, TooLowPriorityFactory, UnnamedFactory 添加测试用工厂(不要把它们注册到 SPI 中!);
This commit is contained in:
		| @ -84,11 +84,11 @@ public final class FactoryInfo { | |||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         FactoryInfo that = (FactoryInfo) o; |         FactoryInfo that = (FactoryInfo) o; | ||||||
|         return factoryName.equals(that.factoryName); |         return factoryName.equals(that.factoryName) && storeSource == that.storeSource; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int hashCode() { |     public int hashCode() { | ||||||
|         return Objects.hash(factoryName); |         return Objects.hash(factoryName, storeSource); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										86
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/FactoryInfoTest.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/FactoryInfoTest.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,86 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.factory.*; | ||||||
|  | import org.junit.Assert; | ||||||
|  | import org.junit.Test; | ||||||
|  |  | ||||||
|  | public class FactoryInfoTest { | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void analyticTest() { | ||||||
|  |         FactoryInfo infoA = new FactoryInfo(FactoryInfoTestFactory.class); | ||||||
|  |         Assert.assertEquals("test-factoryInfo", infoA.getFactoryName()); | ||||||
|  |         Assert.assertEquals(6, infoA.getFactoryPriority()); | ||||||
|  |         Assert.assertEquals(CacheStoreSource.MEMORY, infoA.getStoreSource()); | ||||||
|  |  | ||||||
|  |         FactoryInfo infoB = new FactoryInfo(FactoryInfoTestFactory.class); | ||||||
|  |  | ||||||
|  |         Assert.assertEquals(infoA, infoB); | ||||||
|  |         Assert.assertEquals(infoA.hashCode(), infoB.hashCode()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     @SuppressWarnings({"SimplifiableAssertion", "EqualsWithItself", "ConstantConditions"}) | ||||||
|  |     public void equalsTest() { | ||||||
|  |         FactoryInfo infoA = new FactoryInfo(FactoryInfoTestFactory.class); | ||||||
|  |         FactoryInfo infoB = new FactoryInfo(FactoryInfoTestFactory.class); | ||||||
|  |  | ||||||
|  |         Assert.assertTrue(infoA.equals(infoA)); | ||||||
|  |         Assert.assertTrue(infoA.equals(infoB)); | ||||||
|  |  | ||||||
|  |         Assert.assertFalse(infoA.equals(null)); | ||||||
|  |         Assert.assertFalse(infoA.equals(new Object())); | ||||||
|  |  | ||||||
|  |         Assert.assertFalse( | ||||||
|  |                 new FactoryInfo(NameNoEqualFactoryA.class) | ||||||
|  |                         .equals(new FactoryInfo(NameNoEqualFactoryB.class))); | ||||||
|  |  | ||||||
|  |         Assert.assertFalse( | ||||||
|  |                 new FactoryInfo(NameNoEqualFactoryA.class) | ||||||
|  |                         .equals(new FactoryInfo(CacheStoreSourceNoEqualFactory.class))); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test(expected = IllegalArgumentException.class) | ||||||
|  |     public void noAnnotationTest() { | ||||||
|  |         new FactoryInfo(NoAnnotationFactory.class); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test(expected = IllegalArgumentException.class) | ||||||
|  |     public void unnamedTest() { | ||||||
|  |         new FactoryInfo(UnnamedFactory.class); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     public void priorityCheckTest() { | ||||||
|  |         FactoryInfo toHighPriorityFactoryInfo = new FactoryInfo(TooHighPriorityFactory.class); | ||||||
|  |         Assert.assertEquals(FactoryPriority.PRIORITY_HIGHEST, | ||||||
|  |                 toHighPriorityFactoryInfo.getFactoryPriority()); | ||||||
|  |  | ||||||
|  |         FactoryInfo toLowPriorityFactoryInfo = new FactoryInfo(TooLowPriorityFactory.class); | ||||||
|  |         Assert.assertEquals(FactoryPriority.PRIORITY_LOWEST, | ||||||
|  |                 toLowPriorityFactoryInfo.getFactoryPriority()); | ||||||
|  |  | ||||||
|  |         Assert.assertNotEquals(toHighPriorityFactoryInfo, toLowPriorityFactoryInfo); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-NameNoEqualA", source = CacheStoreSource.REMOTE) | ||||||
|  | public class CacheStoreSourceNoEqualFactory implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-factoryInfo", source = CacheStoreSource.MEMORY, priority = 6) | ||||||
|  | public class FactoryInfoTestFactory implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/NameNoEqualFactoryA.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/NameNoEqualFactoryA.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-NameNoEqualA") | ||||||
|  | public class NameNoEqualFactoryA implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/NameNoEqualFactoryB.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/NameNoEqualFactoryB.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-NameNoEqualB") | ||||||
|  | public class NameNoEqualFactoryB implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-factoryInfo-tooHighPriority", priority = 15) | ||||||
|  | public class TooHighPriorityFactory implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "test-factoryInfo-tooLowPriority", priority = -5) | ||||||
|  | public class TooLowPriorityFactory implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/UnnamedFactory.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								ContentGrabbingJi-common/src/test/java/net/lamgc/cgj/bot/cache/factory/UnnamedFactory.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (C) 2020  LamGC | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is free software: you can redistribute it and/or modify | ||||||
|  |  * it under the terms of the GNU Affero General Public License as | ||||||
|  |  * published by the Free Software Foundation, either version 3 of the | ||||||
|  |  * License, or (at your option) any later version. | ||||||
|  |  * | ||||||
|  |  * ContentGrabbingJi is distributed in the hope that it will be useful, | ||||||
|  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |  * GNU Affero General Public License for more details. | ||||||
|  |  * | ||||||
|  |  * You should have received a copy of the GNU Affero General Public License | ||||||
|  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package net.lamgc.cgj.bot.cache.factory; | ||||||
|  |  | ||||||
|  | import net.lamgc.cgj.bot.cache.*; | ||||||
|  | import net.lamgc.cgj.bot.cache.convert.StringConverter; | ||||||
|  | import net.lamgc.cgj.bot.cache.exception.GetCacheStoreException; | ||||||
|  |  | ||||||
|  | import java.io.File; | ||||||
|  |  | ||||||
|  | @Factory(name = "") | ||||||
|  | public class UnnamedFactory implements CacheStoreFactory { | ||||||
|  |     @Override | ||||||
|  |     public void initial(File dataDirectory) { | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> SingleCacheStore<V> newSingleCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> ListCacheStore<E> newListCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <E> SetCacheStore<E> newSetCacheStore(String identify, StringConverter<E> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public <V> MapCacheStore<V> newMapCacheStore(String identify, StringConverter<V> converter) throws GetCacheStoreException { | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public boolean canGetCacheStore() { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user