// Path: x_common/compiler-testing/src/main/java/org/zalando/techtalks/hackingjava/common/compiler/CompilationResult.java
// public final class CompilationResult {
// 
//     private final boolean success;
//     private final List<String> warnings;
//     private final List<String> errors;
// 
//     public boolean isSuccess() {
//         return success;
//     }
// 
//     public List<String> getWarnings() {
//         return Collections.unmodifiableList(warnings);
//     }
// 
//     public List<String> getErrors() {
//         return Collections.unmodifiableList(errors);
//     }
// 
//     public CompilationResult(final boolean success, final List<String> warnings, final List<String> errors) {
//         this.success = success;
//         this.warnings = new ArrayList<>(warnings);
//         this.errors = new ArrayList<>(errors);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(success, warnings, errors);
//     }
// 
//     @Override
//     public boolean equals(final Object obj) {
//         if (this == obj) {
//             return true;
//         }
// 
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
// 
//         final CompilationResult other = (CompilationResult) obj;
//         return Objects.equals(this.success, other.success) && Objects.equals(this.warnings, other.warnings)
//                 && Objects.equals(this.errors, other.errors);
//     }
// 
//     @Override
//     public String toString() {
//         return "CompilationResult{" + "success=" + success + ", warnings=" + warnings + ", errors=" + errors + '}';
//     }
// }
// 
// 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);
// }


import com.google.common.base.Joiner;
import java.util.List;
import java.util.stream.Collectors;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.SelfDescribing;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.Before;
import org.zalando.techtalks.hackingjava.common.compiler.CompilationResult;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.engine.DefectAnalysisEngine;
package org.zalando.techtalks.hackingjava.defectanalysis.tests;


public abstract class AbstractCompilerTest extends CompilationHelper {

    DefectAnalysisEngine engine;

    protected abstract DefectAnalysisEngine instantiateEngine();

    @Before
    public void setupEngine() {
        this.engine = instantiateEngine();
    }

    protected Matcher<CompilationResult> isSuccess() {
        return new TypeSafeDiagnosingMatcher<CompilationResult>() {
            @Override public void describeTo(final Description description) {
                description.appendText("Successful compilation");
            }

            @Override protected boolean matchesSafely(final CompilationResult item,
                                                      final Description mismatchDescription) {
                final boolean success = item.isSuccess();
                if (!success) mismatchDescription.appendText(Joiner.on('\n').join(item.getErrors()));
                return success;
            }

            ;
        };

    }

// Path: x_common/compiler-testing/src/main/java/org/zalando/techtalks/hackingjava/common/compiler/CompilationResult.java
// public final class CompilationResult {
// 
//     private final boolean success;
//     private final List<String> warnings;
//     private final List<String> errors;
// 
//     public boolean isSuccess() {
//         return success;
//     }
// 
//     public List<String> getWarnings() {
//         return Collections.unmodifiableList(warnings);
//     }
// 
//     public List<String> getErrors() {
//         return Collections.unmodifiableList(errors);
//     }
// 
//     public CompilationResult(final boolean success, final List<String> warnings, final List<String> errors) {
//         this.success = success;
//         this.warnings = new ArrayList<>(warnings);
//         this.errors = new ArrayList<>(errors);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(success, warnings, errors);
//     }
// 
//     @Override
//     public boolean equals(final Object obj) {
//         if (this == obj) {
//             return true;
//         }
// 
//         if (obj == null || getClass() != obj.getClass()) {
//             return false;
//         }
// 
//         final CompilationResult other = (CompilationResult) obj;
//         return Objects.equals(this.success, other.success) && Objects.equals(this.warnings, other.warnings)
//                 && Objects.equals(this.errors, other.errors);
//     }
// 
//     @Override
//     public String toString() {
//         return "CompilationResult{" + "success=" + success + ", warnings=" + warnings + ", errors=" + errors + '}';
//     }
// }
// 
// 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_tests/src/main/java/org/zalando/techtalks/hackingjava/defectanalysis/tests/AbstractCompilerTest.java
import com.google.common.base.Joiner;
import java.util.List;
import java.util.stream.Collectors;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.SelfDescribing;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.Before;
import org.zalando.techtalks.hackingjava.common.compiler.CompilationResult;
import org.zalando.techtalks.hackingjava.defectanalysis.baseline.engine.DefectAnalysisEngine;

package org.zalando.techtalks.hackingjava.defectanalysis.tests;


public abstract class AbstractCompilerTest extends CompilationHelper {

    DefectAnalysisEngine engine;

    protected abstract DefectAnalysisEngine instantiateEngine();

    @Before
    public void setupEngine() {
        this.engine = instantiateEngine();
    }

    protected Matcher<CompilationResult> isSuccess() {
        return new TypeSafeDiagnosingMatcher<CompilationResult>() {
            @Override public void describeTo(final Description description) {
                description.appendText("Successful compilation");
            }

            @Override protected boolean matchesSafely(final CompilationResult item,
                                                      final Description mismatchDescription) {
                final boolean success = item.isSuccess();
                if (!success) mismatchDescription.appendText(Joiner.on('\n').join(item.getErrors()));
                return success;
            }

            ;
        };

    }

    protected Matcher<CompilationResult> isFailureWithExpectedMessage(String message) {