// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/engine/DefectAnalysisEngine.java
// public interface DefectAnalysisEngine {
//     CompilationResult compile(File sourceFile);
// }
// 
// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/marker/IllBehaved.java
// public interface IllBehaved {}
// 
// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/marker/WellBehaved.java
// public interface WellBehaved {
// }
// 
// Path: 3_defect-analysis/1_errorprone/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/errorprone/engine/ErrorProneAnalysisEngine.java
// public class ErrorProneAnalysisEngine implements DefectAnalysisEngine {
// 
//     private final Set<String> activatedChecks;
// 
//     public ErrorProneAnalysisEngine(final Set<String> activatedChecks) {
//         this.activatedChecks = activatedChecks;
//     }
// 
//     static String jarPathFromClass(final Class<?> referenceClass) {
//         try {
//             return new File(
//                     referenceClass.getProtectionDomain()
//                             .getCodeSource()
//                             .getLocation()
//                             .toURI()
//             ).getAbsolutePath();
//         } catch (URISyntaxException e) {
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     @Override
//     public CompilationResult compile(final File sourceFile) {
//         return new ForkedRun(ErrorProneAnalysisEngine.class)
//                 .withAdditionalClassLoaderFromClass(AbstractUser.class)
//                 .withBootClassPathMatcher("com", "google", "errorprone")
//                 .withBootClassPathMatcher("org", "checkerframework")
//                 .withArg(ErrorProneCompiler.class)
//                 .withArg("-d").tempDirAsArg()
//                 .withArg("-Xep:" + Joiner.on(',').join(activatedChecks))
//                 .withArg(sourceFile.getAbsolutePath()).run();
// 
//     }
// 
// }
// 
// Path: 3_defect-analysis/x_tests/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/tests/AbstractDefectDetectionTest.java
// public abstract class AbstractDefectDetectionTest extends AbstractCompilerTest {
// 
//     protected abstract Class<? extends WellBehaved> wellBehavedClass();
// 
//     protected abstract Class<? extends IllBehaved> illBehavedClass();
// 
//     @Test
//     public void detectWellBehavedClass() {
//         final CompilationResult result = engine.compile(sourceFileFor(wellBehavedClass()));
//         assertThat(result, isSuccess());
//     }
// 
//     @Test
//     public void detectIllBehavedClass() {
//         final CompilationResult result = engine.compile(sourceFileFor(illBehavedClass()));
//         assertThat(result, isFailureWithExpectedMessage(expectedErrorMessage()));
//     }
// 
//     protected abstract String expectedErrorMessage();
// 
// }


import com.google.common.collect.ImmutableSet;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.engine.DefectAnalysisEngine;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.marker.IllBehaved;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.marker.WellBehaved;
import org.zalando.techtalks.hackingjava.defectanalysis.errorprone.engine.ErrorProneAnalysisEngine;
import org.zalando.techtalks.hackingjava.defectanalysis.tests.AbstractDefectDetectionTest;
package org.zalando.techtalks.hackingjava.defectanalysis.errorprone.regex;


public class ErrorProneRegexBugDetectionTest extends AbstractDefectDetectionTest {

    @Override protected Class<? extends WellBehaved> wellBehavedClass() {
        return WellBehavedRegex.class;
    }

    @Override protected Class<? extends IllBehaved> illBehavedClass() {
        return IllBehavedRegex.class;
    }

    @Override protected String expectedErrorMessage() {
        return "http://errorprone.info/bugpattern/InvalidPatternSyntax";
    }

    @Override protected DefectAnalysisEngine instantiateEngine() {
// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/engine/DefectAnalysisEngine.java
// public interface DefectAnalysisEngine {
//     CompilationResult compile(File sourceFile);
// }
// 
// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/marker/IllBehaved.java
// public interface IllBehaved {}
// 
// Path: 3_defect-analysis/x_baseline/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/baseline/marker/WellBehaved.java
// public interface WellBehaved {
// }
// 
// Path: 3_defect-analysis/1_errorprone/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/errorprone/engine/ErrorProneAnalysisEngine.java
// public class ErrorProneAnalysisEngine implements DefectAnalysisEngine {
// 
//     private final Set<String> activatedChecks;
// 
//     public ErrorProneAnalysisEngine(final Set<String> activatedChecks) {
//         this.activatedChecks = activatedChecks;
//     }
// 
//     static String jarPathFromClass(final Class<?> referenceClass) {
//         try {
//             return new File(
//                     referenceClass.getProtectionDomain()
//                             .getCodeSource()
//                             .getLocation()
//                             .toURI()
//             ).getAbsolutePath();
//         } catch (URISyntaxException e) {
//             throw new IllegalStateException(e);
//         }
//     }
// 
//     @Override
//     public CompilationResult compile(final File sourceFile) {
//         return new ForkedRun(ErrorProneAnalysisEngine.class)
//                 .withAdditionalClassLoaderFromClass(AbstractUser.class)
//                 .withBootClassPathMatcher("com", "google", "errorprone")
//                 .withBootClassPathMatcher("org", "checkerframework")
//                 .withArg(ErrorProneCompiler.class)
//                 .withArg("-d").tempDirAsArg()
//                 .withArg("-Xep:" + Joiner.on(',').join(activatedChecks))
//                 .withArg(sourceFile.getAbsolutePath()).run();
// 
//     }
// 
// }
// 
// Path: 3_defect-analysis/x_tests/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/tests/AbstractDefectDetectionTest.java
// public abstract class AbstractDefectDetectionTest extends AbstractCompilerTest {
// 
//     protected abstract Class<? extends WellBehaved> wellBehavedClass();
// 
//     protected abstract Class<? extends IllBehaved> illBehavedClass();
// 
//     @Test
//     public void detectWellBehavedClass() {
//         final CompilationResult result = engine.compile(sourceFileFor(wellBehavedClass()));
//         assertThat(result, isSuccess());
//     }
// 
//     @Test
//     public void detectIllBehavedClass() {
//         final CompilationResult result = engine.compile(sourceFileFor(illBehavedClass()));
//         assertThat(result, isFailureWithExpectedMessage(expectedErrorMessage()));
//     }
// 
//     protected abstract String expectedErrorMessage();
// 
// }


// Path: 3_defect-analysis/1_errorprone/src/test/java/org/zalando/techtalks/hackingjava/defectanalysis/errorprone/regex/ErrorProneRegexBugDetectionTest.java
import com.google.common.collect.ImmutableSet;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.engine.DefectAnalysisEngine;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.marker.IllBehaved;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.marker.WellBehaved;
import org.zalando.techtalks.hackingjava.defectanalysis.errorprone.engine.ErrorProneAnalysisEngine;
import org.zalando.techtalks.hackingjava.defectanalysis.tests.AbstractDefectDetectionTest;

package org.zalando.techtalks.hackingjava.defectanalysis.errorprone.regex;


public class ErrorProneRegexBugDetectionTest extends AbstractDefectDetectionTest {

    @Override protected Class<? extends WellBehaved> wellBehavedClass() {
        return WellBehavedRegex.class;
    }

    @Override protected Class<? extends IllBehaved> illBehavedClass() {
        return IllBehavedRegex.class;
    }

    @Override protected String expectedErrorMessage() {
        return "http://errorprone.info/bugpattern/InvalidPatternSyntax";
    }

    @Override protected DefectAnalysisEngine instantiateEngine() {
        return new ErrorProneAnalysisEngine(ImmutableSet.of("InvalidPatternSyntax"));