in src/jvm/main/org/jetbrains/kotlinx/lincheck/CTestStructure.java [57:108]
public static CTestStructure getFromTestClass(Class<?> testClass) {
Map<String, OperationGroup> groupConfigs = new HashMap<>();
List<ActorGenerator> actorGenerators = new ArrayList<>();
List<Actor> validationFunctions = new ArrayList<>();
List<Method> stateRepresentations = new ArrayList<>();
Class<?> clazz = testClass;
RandomProvider randomProvider = new RandomProvider();
Map<Class<?>, ParameterGenerator<?>> parameterGeneratorsMap = new HashMap<>();
while (clazz != null) {
readTestStructureFromClass(
clazz,
groupConfigs,
actorGenerators,
parameterGeneratorsMap,
validationFunctions,
stateRepresentations,
randomProvider
);
clazz = clazz.getSuperclass();
}
List<ParameterGenerator<?>> parameterGenerators = new ArrayList<>(parameterGeneratorsMap.values());
if (stateRepresentations.size() > 1) {
throw new IllegalStateException("At most one state representation function is allowed, but several were detected:" +
stateRepresentations.stream()
.map(Method::getName)
.collect(Collectors.joining(", ")));
}
Method stateRepresentation = stateRepresentations.isEmpty() ? null : stateRepresentations.get(0);
if (validationFunctions.size() > 1) {
throw new IllegalStateException("At most one validation function is allowed, but several were detected: " +
validationFunctions.stream()
.map(actor -> {
Method method = actor.getMethod();
return method.getName();
})
.collect(Collectors.joining(", ")));
}
Actor validationFunction = validationFunctions.isEmpty() ? null : validationFunctions.get(0);
return new CTestStructure(
actorGenerators,
parameterGenerators,
new ArrayList<>(groupConfigs.values()),
validationFunction,
stateRepresentation,
randomProvider
);
}