tk.labyrinth.jaap.testing.CompilerAwareTestBase Maven / Gradle / Ivy
package tk.labyrinth.jaap.testing;
import lombok.AccessLevel;
import lombok.Getter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import java.io.IOException;
import java.nio.file.Path;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.Stream;
public abstract class CompilerAwareTestBase {
@Getter(AccessLevel.PROTECTED)
private TestCompiler compiler;
@BeforeEach
private void beforeEach(@TempDir Path tempDir) throws IOException {
compiler = new TestCompiler(tempDir);
}
protected abstract Stream getCompilationWork();
protected String[] getCompilationWorkArray() {
return getCompilationWork().toArray(String[]::new);
}
protected void testWithEnvironment(BiConsumer callback) {
compiler.getTask(getCompilationWorkArray()).call(new TestCallbackProcessor(callback));
}
protected void testWithEnvironment(Consumer callback) {
testWithEnvironment((processingEnv, roundEnv) -> callback.accept(processingEnv));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy