// Path: src/main/java/com/lazerycode/jmeter/results/ResultScanner.java
// public class ResultScanner implements IResultScanner {
//     private static final Logger LOGGER = LoggerFactory.getLogger(ResultScanner.class);
//     private static final String XML_REQUEST_FAILURE_PATTERN = "s=\"false\"";
//     private static final String XML_REQUEST_SUCCESS_PATTERN = "s=\"true\"";
//     private final boolean countFailures;
//     private final boolean countSuccesses;
//     private final boolean onlyFailWhenMatchingFailureMessage;
//     private final boolean csv;
//     private final List<String> failureMessages;
//     private int successCount = 0;
//     private int failureCount = 0;
//     private int customFailureCount = 0;
// 
//     public ResultScanner(boolean countSuccesses, boolean countFailures, boolean isCsv, boolean onlyFailWhenMatchingFailureMessage, List<String> failureMessages) {
//         this.csv = isCsv;
//         this.countFailures = countFailures;
//         this.countSuccesses = countSuccesses;
//         this.onlyFailWhenMatchingFailureMessage = onlyFailWhenMatchingFailureMessage;
//         this.failureMessages = failureMessages;
//     }
// 
//     /**
//      * Work out how to parse the file (if at all)
//      *
//      * @param file File to parse
//      * @throws MojoExecutionException MojoExecutionException
//      */
//     public void parseResultFile(File file) throws MojoExecutionException {
//         if (!file.exists()) {
//             throw new MojoExecutionException("Unable to find " + file.getAbsolutePath());
//         }
//         LOGGER.info(" ");
//         LOGGER.info("Parsing results file '{}' as type: {}", file, this.csv ? "CSV" : "XML");
//         if (csv) {
//             CSVScanResult csvScanResult = CSVFileScanner.scanCsvForValues(file, failureMessages);
//             successCount = csvScanResult.getSuccessCount();
//             failureCount = csvScanResult.getFailureCount();
//             for (Map.Entry<String, Integer> entry : csvScanResult.getSpecificFailureMessages().entrySet()) {
//                 customFailureCount = customFailureCount + entry.getValue();
//                 LOGGER.info("Number of potential custom failures using '{}' in '{}': {}", entry.getKey(), file.getName(), customFailureCount);
//             }
//         } else {
//             if (countSuccesses) {
//                 successCount = scanXmlFileForPattern(file, Pattern.compile(XML_REQUEST_SUCCESS_PATTERN, Pattern.CASE_INSENSITIVE));
//             }
//             if (countFailures) {
//                 failureCount = scanXmlFileForPattern(file, Pattern.compile(XML_REQUEST_FAILURE_PATTERN, Pattern.CASE_INSENSITIVE));
//             }
//         }
//     }
// 
//     /**
//      * @return failureCount
//      */
//     @Override
//     public int getFailureCount() {
//         if (countFailures) {
//             if (onlyFailWhenMatchingFailureMessage) {
//                 return this.customFailureCount;
//             } else {
//                 return this.failureCount;
//             }
//         }
//         return 0;
//     }
// 
//     /**
//      * @return failureCount
//      */
//     @Override
//     public int getSuccessCount() {
//         if (countSuccesses) {
//             return this.successCount;
//         }
//         return 0;
//     }
// 
//     @Override
//     public int getTotalCount() {
//         return getSuccessCount() + getFailureCount();
//     }
// }


import com.lazerycode.jmeter.results.ResultScanner;
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(4);
        assertThat(fileScanner.getTotalCount()).isEqualTo(4);
    }

    @Test
    public void jtlFileWithNoFailuresCountSuccessesOnly() throws Exception {
        File resultsFile = new File(jtlPassingResultsFileURL.toURI());
        ResultScanner fileScanner = new ResultScanner(COUNT_SUCCESSES, DO_NOT_COUNT_FAILURES, DEFAULT_IS_CSV, DEFAULT_ONLY_FAIL_WHEN_MATCHING_FAILURE_MESSAGES, DEFAULT_FAILURE_LIST);
        fileScanner.parseResultFile(resultsFile);

        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(4);
        assertThat(fileScanner.getTotalCount()).isEqualTo(4);
    }

    @Test
    public void jtlFileWithNoFailuresCountFailuresOnly() throws Exception {
        File resultsFile = new File(jtlPassingResultsFileURL.toURI());
        ResultScanner fileScanner = new ResultScanner(DO_NOT_COUNT_SUCCESSES, COUNT_FAILURES, DEFAULT_IS_CSV, DEFAULT_ONLY_FAIL_WHEN_MATCHING_FAILURE_MESSAGES, DEFAULT_FAILURE_LIST);
        fileScanner.parseResultFile(resultsFile);

        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(0);
        assertThat(fileScanner.getTotalCount()).isEqualTo(0);
    }

    @Test
    public void csvFileWithFailuresCountSuccessAndFailures() throws Exception {
        File resultsFile = new File(csvFailingResultsFileURL.toURI());
// Path: src/main/java/com/lazerycode/jmeter/results/ResultScanner.java
// public class ResultScanner implements IResultScanner {
//     private static final Logger LOGGER = LoggerFactory.getLogger(ResultScanner.class);
//     private static final String XML_REQUEST_FAILURE_PATTERN = "s=\"false\"";
//     private static final String XML_REQUEST_SUCCESS_PATTERN = "s=\"true\"";
//     private final boolean countFailures;
//     private final boolean countSuccesses;
//     private final boolean onlyFailWhenMatchingFailureMessage;
//     private final boolean csv;
//     private final List<String> failureMessages;
//     private int successCount = 0;
//     private int failureCount = 0;
//     private int customFailureCount = 0;
// 
//     public ResultScanner(boolean countSuccesses, boolean countFailures, boolean isCsv, boolean onlyFailWhenMatchingFailureMessage, List<String> failureMessages) {
//         this.csv = isCsv;
//         this.countFailures = countFailures;
//         this.countSuccesses = countSuccesses;
//         this.onlyFailWhenMatchingFailureMessage = onlyFailWhenMatchingFailureMessage;
//         this.failureMessages = failureMessages;
//     }
// 
//     /**
//      * Work out how to parse the file (if at all)
//      *
//      * @param file File to parse
//      * @throws MojoExecutionException MojoExecutionException
//      */
//     public void parseResultFile(File file) throws MojoExecutionException {
//         if (!file.exists()) {
//             throw new MojoExecutionException("Unable to find " + file.getAbsolutePath());
//         }
//         LOGGER.info(" ");
//         LOGGER.info("Parsing results file '{}' as type: {}", file, this.csv ? "CSV" : "XML");
//         if (csv) {
//             CSVScanResult csvScanResult = CSVFileScanner.scanCsvForValues(file, failureMessages);
//             successCount = csvScanResult.getSuccessCount();
//             failureCount = csvScanResult.getFailureCount();
//             for (Map.Entry<String, Integer> entry : csvScanResult.getSpecificFailureMessages().entrySet()) {
//                 customFailureCount = customFailureCount + entry.getValue();
//                 LOGGER.info("Number of potential custom failures using '{}' in '{}': {}", entry.getKey(), file.getName(), customFailureCount);
//             }
//         } else {
//             if (countSuccesses) {
//                 successCount = scanXmlFileForPattern(file, Pattern.compile(XML_REQUEST_SUCCESS_PATTERN, Pattern.CASE_INSENSITIVE));
//             }
//             if (countFailures) {
//                 failureCount = scanXmlFileForPattern(file, Pattern.compile(XML_REQUEST_FAILURE_PATTERN, Pattern.CASE_INSENSITIVE));
//             }
//         }
//     }
// 
//     /**
//      * @return failureCount
//      */
//     @Override
//     public int getFailureCount() {
//         if (countFailures) {
//             if (onlyFailWhenMatchingFailureMessage) {
//                 return this.customFailureCount;
//             } else {
//                 return this.failureCount;
//             }
//         }
//         return 0;
//     }
// 
//     /**
//      * @return failureCount
//      */
//     @Override
//     public int getSuccessCount() {
//         if (countSuccesses) {
//             return this.successCount;
//         }
//         return 0;
//     }
// 
//     @Override
//     public int getTotalCount() {
//         return getSuccessCount() + getFailureCount();
//     }
// }


// Path: src/test/java/com/lazerycode/jmeter/testrunner/ResultScannerTest.java
import com.lazerycode.jmeter.results.ResultScanner;
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;

        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(4);
        assertThat(fileScanner.getTotalCount()).isEqualTo(4);
    }

    @Test
    public void jtlFileWithNoFailuresCountSuccessesOnly() throws Exception {
        File resultsFile = new File(jtlPassingResultsFileURL.toURI());
        ResultScanner fileScanner = new ResultScanner(COUNT_SUCCESSES, DO_NOT_COUNT_FAILURES, DEFAULT_IS_CSV, DEFAULT_ONLY_FAIL_WHEN_MATCHING_FAILURE_MESSAGES, DEFAULT_FAILURE_LIST);
        fileScanner.parseResultFile(resultsFile);

        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(4);
        assertThat(fileScanner.getTotalCount()).isEqualTo(4);
    }

    @Test
    public void jtlFileWithNoFailuresCountFailuresOnly() throws Exception {
        File resultsFile = new File(jtlPassingResultsFileURL.toURI());
        ResultScanner fileScanner = new ResultScanner(DO_NOT_COUNT_SUCCESSES, COUNT_FAILURES, DEFAULT_IS_CSV, DEFAULT_ONLY_FAIL_WHEN_MATCHING_FAILURE_MESSAGES, DEFAULT_FAILURE_LIST);
        fileScanner.parseResultFile(resultsFile);

        assertThat(fileScanner.getFailureCount()).isEqualTo(0);
        assertThat(fileScanner.getSuccessCount()).isEqualTo(0);
        assertThat(fileScanner.getTotalCount()).isEqualTo(0);
    }

    @Test
    public void csvFileWithFailuresCountSuccessAndFailures() throws Exception {
        File resultsFile = new File(csvFailingResultsFileURL.toURI());
        ResultScanner fileScanner = new ResultScanner(COUNT_SUCCESSES, COUNT_FAILURES, true, DEFAULT_ONLY_FAIL_WHEN_MATCHING_FAILURE_MESSAGES, DEFAULT_FAILURE_LIST);