use of common.pattern.LoadedPatternGenerator in project solution-finder by knewjade.
the class PercentCoreTest method assertPercentCore.
private void assertPercentCore(Obj obj, double successPercent) throws Exception {
PatternGenerator generator = new LoadedPatternGenerator(obj.patterns);
NormalEnumeratePieces enumeratePieces = new NormalEnumeratePieces(generator, obj.maxDepth, obj.isUsingHold);
Set<LongPieces> blocks = enumeratePieces.enumerate();
Injector injector = Guice.createInjector(new BasicModule(obj.maxClearLine));
Optional<ExecutorService> executorService = obj.isSingleThread ? Optional.empty() : Optional.of(injector.getInstance(ExecutorService.class));
LockedCandidateThreadLocal candidateThreadLocal = injector.getInstance(LockedCandidateThreadLocal.class);
LockedReachableThreadLocal reachableThreadLocal = injector.getInstance(LockedReachableThreadLocal.class);
MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
PercentCore percentCore = getPercentCore(obj, executorService.orElse(null), candidateThreadLocal, reachableThreadLocal, minoFactory);
Field field = FieldFactory.createField(obj.marks);
percentCore.run(field, blocks, obj.maxClearLine, obj.maxDepth);
executorService.ifPresent(ExecutorService::shutdown);
assertThat(percentCore.getResultTree().getSuccessPercent()).isEqualTo(successPercent);
}
Aggregations