// Path: src/main/java/org/sonar/plugins/xquery/api/XQueryConstants.java
// public interface XQueryConstants {
//     static String XQUERY_LANGUAGE_KEY = "xquery";
//     static String FILE_EXTENSIONS_KEY = "sonar.xquery.fileExtensions";
//     static String SOURCE_DIRECTORY_KEY = "sonar.xquery.sourceDirectory";
//     static String XQTEST_REPORTS_DIRECTORY_KEY = "sonar.xqtest.reportsPath";
// 
//     static String XQUERY_LANGUAGE_NAME = "XQuery";
//     static String[] DEFAULT_FILE_EXTENSIONS = {"xqy", "xquery", "xq", "xqi", "xql", "xqm", "xqws"};
//     static String DEFAULT_FILE_EXTENSIONS_STRING = "xqy, xquery, xq, xqi, xql, xqm, xqws";
//     static String DEFAULT_SOURCE_DIRECTORY = "src/main/xquery";
//     static String DEFAULT_XQTEST_DIRECTORY = "target/xqtest-reports";
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.plugins.xquery.api.XQueryConstants;
import java.io.File;
/*
 * © 2014 by Intellectual Reserve, Inc. All rights reserved.
 */

package org.sonar.plugins.xquery.test;



public class XQueryTestSensor implements Sensor {

    private static final Logger LOGGER = LoggerFactory.getLogger(XQueryTestSensor.class);

    private final SurefireXQueryParser surefireXQueryParser;
    private final Settings settings;
    private final FileSystem fileSystem;

    public XQueryTestSensor(SurefireXQueryParser surefireXQueryParser, Settings settings, FileSystem fileSystem) {
        this.surefireXQueryParser = surefireXQueryParser;
        this.settings = settings;
        this.fileSystem = fileSystem;
    }

    @Override
    public boolean shouldExecuteOnProject(Project project) {
        return fileSystem.files(fileSystem.predicates().hasLanguage(XQueryConstants.XQUERY_LANGUAGE_KEY)).iterator().hasNext();
    }

    @Override
    public void analyse(Project project, SensorContext context) {
// Path: src/main/java/org/sonar/plugins/xquery/api/XQueryConstants.java
// public interface XQueryConstants {
//     static String XQUERY_LANGUAGE_KEY = "xquery";
//     static String FILE_EXTENSIONS_KEY = "sonar.xquery.fileExtensions";
//     static String SOURCE_DIRECTORY_KEY = "sonar.xquery.sourceDirectory";
//     static String XQTEST_REPORTS_DIRECTORY_KEY = "sonar.xqtest.reportsPath";
// 
//     static String XQUERY_LANGUAGE_NAME = "XQuery";
//     static String[] DEFAULT_FILE_EXTENSIONS = {"xqy", "xquery", "xq", "xqi", "xql", "xqm", "xqws"};
//     static String DEFAULT_FILE_EXTENSIONS_STRING = "xqy, xquery, xq, xqi, xql, xqm, xqws";
//     static String DEFAULT_SOURCE_DIRECTORY = "src/main/xquery";
//     static String DEFAULT_XQTEST_DIRECTORY = "target/xqtest-reports";
// }


// Path: src/main/java/org/sonar/plugins/xquery/test/XQueryTestSensor.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
import org.sonar.plugins.xquery.api.XQueryConstants;
import java.io.File;

/*
 * © 2014 by Intellectual Reserve, Inc. All rights reserved.
 */

package org.sonar.plugins.xquery.test;



public class XQueryTestSensor implements Sensor {

    private static final Logger LOGGER = LoggerFactory.getLogger(XQueryTestSensor.class);

    private final SurefireXQueryParser surefireXQueryParser;
    private final Settings settings;
    private final FileSystem fileSystem;

    public XQueryTestSensor(SurefireXQueryParser surefireXQueryParser, Settings settings, FileSystem fileSystem) {
        this.surefireXQueryParser = surefireXQueryParser;
        this.settings = settings;
        this.fileSystem = fileSystem;
    }

    @Override
    public boolean shouldExecuteOnProject(Project project) {
        return fileSystem.files(fileSystem.predicates().hasLanguage(XQueryConstants.XQUERY_LANGUAGE_KEY)).iterator().hasNext();
    }

    @Override
    public void analyse(Project project, SensorContext context) {
        File dir = new File(settings.getString(XQueryConstants.XQTEST_REPORTS_DIRECTORY_KEY));