Class FixtureRegistry

java.lang.Object
cloud.opencode.base.test.fixture.FixtureRegistry

public final class FixtureRegistry extends Object
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 Details

    • register

      public static <T> void register(TestFixture<T> fixture)
      Register a fixture 注册夹具
      Type Parameters:
      T - the data type | 数据类型
      Parameters:
      fixture - the fixture | 夹具
    • register

      public static <T> void register(String name, Supplier<T> supplier)
      Register a simple fixture 注册简单夹具
      Type Parameters:
      T - the data type | 数据类型
      Parameters:
      name - the fixture name | 夹具名称
      supplier - the data supplier | 数据供应者
    • get

      public static <T> TestFixture<T> get(String name)
      Get a fixture by name 按名称获取夹具
      Type Parameters:
      T - the data type | 数据类型
      Parameters:
      name - the fixture name | 夹具名称
      Returns:
      the fixture | 夹具
    • getData

      public static <T> T getData(String name)
      Get fixture data by name 按名称获取夹具数据
      Type Parameters:
      T - the data type | 数据类型
      Parameters:
      name - the fixture name | 夹具名称
      Returns:
      the fixture data | 夹具数据
    • exists

      public static boolean exists(String name)
      Check if fixture exists 检查夹具是否存在
      Parameters:
      name - the fixture name | 夹具名称
      Returns:
      true if exists | 如果存在返回true
    • unregister

      public static void unregister(String name)
      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 | 数量