Class FixtureRegistry
java.lang.Object
cloud.opencode.base.test.fixture.FixtureRegistry
Fixture Registry
夹具注册表
Registry for managing test fixtures.
管理测试夹具的注册表。
Features | 主要功能:
- Test fixture registration and lookup - 测试夹具注册和查找
- Type-safe fixture management - 类型安全的夹具管理
Usage Examples | 使用示例:
FixtureRegistry registry = new FixtureRegistry();
registry.register("user", () -> new User("test"));
User user = registry.get("user", User.class);
Security | 安全性:
- Thread-safe: Yes (concurrent data structures) - 线程安全: 是(并发数据结构)
- Since:
- JDK 25, opencode-base-test V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clear all fixtures 清除所有夹具static booleanCheck if fixture exists 检查夹具是否存在static <T> TestFixture<T> Get a fixture by name 按名称获取夹具static <T> TGet fixture data by name 按名称获取夹具数据static <T> voidregister(TestFixture<T> fixture) Register a fixture 注册夹具static <T> voidRegister a simple fixture 注册简单夹具static voidresetAll()Reset all fixtures 重置所有夹具static intsize()Get fixture count 获取夹具数量static voidTear down all fixtures 拆除所有夹具static voidunregister(String name) Unregister a fixture 取消注册夹具
-
Method Details
-
register
Register a fixture 注册夹具- Type Parameters:
T- the data type | 数据类型- Parameters:
fixture- the fixture | 夹具
-
register
-
get
Get a fixture by name 按名称获取夹具- Type Parameters:
T- the data type | 数据类型- Parameters:
name- the fixture name | 夹具名称- Returns:
- the fixture | 夹具
-
getData
Get fixture data by name 按名称获取夹具数据- Type Parameters:
T- the data type | 数据类型- Parameters:
name- the fixture name | 夹具名称- Returns:
- the fixture data | 夹具数据
-
exists
Check if fixture exists 检查夹具是否存在- Parameters:
name- the fixture name | 夹具名称- Returns:
- true if exists | 如果存在返回true
-
unregister
Unregister a fixture 取消注册夹具- Parameters:
name- the fixture name | 夹具名称
-
resetAll
public static void resetAll()Reset all fixtures 重置所有夹具 -
tearDownAll
public static void tearDownAll()Tear down all fixtures 拆除所有夹具 -
clear
public static void clear()Clear all fixtures 清除所有夹具 -
size
public static int size()Get fixture count 获取夹具数量- Returns:
- the count | 数量
-