GameTestBatchFactory.java
net.minecraft.gametest.framework.GameTestBatchFactory
信息
- 全限定名:net.minecraft.gametest.framework.GameTestBatchFactory
- 类型:public class
- 包:net.minecraft.gametest.framework
- 源码路径:src/main/java/net/minecraft/gametest/framework/GameTestBatchFactory.java
- 起始行号:L15
- 职责:
TODO
字段/常量
-
MAX_TESTS_PER_BATCH- 类型:
int - 修饰符:
private static final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
DIRECT- 类型:
GameTestBatchFactory.TestDecorator - 修饰符:
public static final - 源码定位:
L17 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.gametest.framework.GameTestBatchFactory.TestDecorator- 类型:
interface - 修饰符:
public - 源码定位:
L64 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static List<GameTestBatch> divideIntoBatches(Collection<Holder.Reference<GameTestInstance>> allTests, GameTestBatchFactory.TestDecorator decorator, ServerLevel level) @ L21
- 方法名:divideIntoBatches
- 源码定位:L21
- 返回类型:List
- 修饰符:public static
参数:
- allTests: Collection<Holder.Reference
> - decorator: GameTestBatchFactory.TestDecorator
- level: ServerLevel
说明:
TODO
public static GameTestRunner.GameTestBatcher fromGameTestInfo() @ L34
- 方法名:fromGameTestInfo
- 源码定位:L34
- 返回类型:GameTestRunner.GameTestBatcher
- 修饰符:public static
参数:
- 无
说明:
TODO
public static GameTestRunner.GameTestBatcher fromGameTestInfo(int maxTestsPerBatch) @ L38
- 方法名:fromGameTestInfo
- 源码定位:L38
- 返回类型:GameTestRunner.GameTestBatcher
- 修饰符:public static
参数:
- maxTestsPerBatch: int
说明:
TODO
public static GameTestBatch toGameTestBatch(Collection<GameTestInfo> tests, Holder<TestEnvironmentDefinition<?>> batch, int counter) @ L59
- 方法名:toGameTestBatch
- 源码定位:L59
- 返回类型:GameTestBatch
- 修饰符:public static
参数:
- tests: Collection
- batch: Holder<TestEnvironmentDefinition<?>>
- counter: int
说明:
TODO
代码
public class GameTestBatchFactory {
private static final int MAX_TESTS_PER_BATCH = 50;
public static final GameTestBatchFactory.TestDecorator DIRECT = (test, level) -> Stream.of(
new GameTestInfo(test, Rotation.NONE, level, RetryOptions.noRetries())
);
public static List<GameTestBatch> divideIntoBatches(
Collection<Holder.Reference<GameTestInstance>> allTests, GameTestBatchFactory.TestDecorator decorator, ServerLevel level
) {
Map<Holder<TestEnvironmentDefinition<?>>, List<GameTestInfo>> testsPerBatch = allTests.stream()
.flatMap(test -> decorator.decorate((Holder.Reference<GameTestInstance>)test, level))
.collect(Collectors.groupingBy(info -> info.getTest().batch()));
return testsPerBatch.entrySet().stream().flatMap(e -> {
Holder<TestEnvironmentDefinition<?>> batchKey = e.getKey();
List<GameTestInfo> testsInBatch = e.getValue();
return Streams.mapWithIndex(Lists.partition(testsInBatch, 50).stream(), (tests, index) -> toGameTestBatch(tests, batchKey, (int)index));
}).toList();
}
public static GameTestRunner.GameTestBatcher fromGameTestInfo() {
return fromGameTestInfo(50);
}
public static GameTestRunner.GameTestBatcher fromGameTestInfo(int maxTestsPerBatch) {
return gameTestInfos -> {
Map<Holder<TestEnvironmentDefinition<?>>, List<GameTestInfo>> testFunctionsPerBatch = gameTestInfos.stream()
.filter(Objects::nonNull)
.collect(Collectors.groupingBy(gameTestInfo -> gameTestInfo.getTest().batch()));
return testFunctionsPerBatch.entrySet()
.stream()
.flatMap(
e -> {
Holder<TestEnvironmentDefinition<?>> batchKey = e.getKey();
List<GameTestInfo> testsInBatch = e.getValue();
return Streams.mapWithIndex(
Lists.partition(testsInBatch, maxTestsPerBatch).stream(),
(tests, index) -> toGameTestBatch(List.copyOf(tests), batchKey, (int)index)
);
}
)
.toList();
};
}
public static GameTestBatch toGameTestBatch(Collection<GameTestInfo> tests, Holder<TestEnvironmentDefinition<?>> batch, int counter) {
return new GameTestBatch(counter, tests, batch);
}
@FunctionalInterface
public interface TestDecorator {
Stream<GameTestInfo> decorate(Holder.Reference<GameTestInstance> test, ServerLevel level);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
构造调用/返回值 - 关联成员:
GameTestBatch()
- 引用位置:
-
- 引用位置:
参数/构造调用 - 关联成员:
GameTestInfo()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RetryOptions.noRetries()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: