// Path: src/main/java/org/ktc/soapui/maven/extension/impl/report/ReportCollectorFactory.java
// public class ReportCollectorFactory {
//     private static final Logger log = Logger.getLogger(ReportCollectorFactory.class);
// 
//     // TODO manage maxErrors
//     // currently do not use it as SmartBear JUnitSecurityReportCollector have no constuctor with int argument
//     public static JUnitSecurityReportCollector newReportCollector() {
//         String className = System.getProperty("soapui.junit.reportCollector", null);
//         if (StringUtils.isNotBlank(className)) {
//             try {
//                 return (JUnitSecurityReportCollector) Class.forName(className).getConstructor().newInstance();
//             } catch (Exception e) {
//                 log.warn("Failed to create JUnitReportCollector class [" + className + "] so use the default one;"
//                         + " error cause: " + e.toString());
//             }
//         }
//         return new JUnitSecurityReportCollector();
//     }
// 
// }


import com.eviware.soapui.SoapUIProTestCaseRunner;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.report.JUnitReportCollector;
import com.eviware.soapui.report.JUnitSecurityReportCollector;
import org.ktc.soapui.maven.extension.impl.report.ReportCollectorFactory;
    public void setTestSuiteProperties(String[] testSuiteProperties) {
        this.testSuiteProperties = testSuiteProperties;
    }

    @Override
    protected void initProject(WsdlProject project) {
        super.initProject(project);
        initTestSuiteProperties(project);
    }

    private void initTestSuiteProperties(WsdlProject project) {
        TestSuitePropertiesModifier.overrideTestSuiteProperties(project, testSuiteProperties);
    }
    
    @Override
    public void exportJUnitReports(JUnitReportCollector collector, String folder, WsdlProject project) {
        if (junitHtmlReport) {
            super.exportJUnitReports(collector, folder, project);
        } else {
            // copy from SoapUITestCaseRunner
            try {
                collector.saveReports(folder == null ? "" : folder);
            } catch (Exception e) {
                log.error("Failed to create JUnit reports", e);
            }
        }
    }

    @Override
    protected JUnitSecurityReportCollector createJUnitSecurityReportCollector() {
// Path: src/main/java/org/ktc/soapui/maven/extension/impl/report/ReportCollectorFactory.java
// public class ReportCollectorFactory {
//     private static final Logger log = Logger.getLogger(ReportCollectorFactory.class);
// 
//     // TODO manage maxErrors
//     // currently do not use it as SmartBear JUnitSecurityReportCollector have no constuctor with int argument
//     public static JUnitSecurityReportCollector newReportCollector() {
//         String className = System.getProperty("soapui.junit.reportCollector", null);
//         if (StringUtils.isNotBlank(className)) {
//             try {
//                 return (JUnitSecurityReportCollector) Class.forName(className).getConstructor().newInstance();
//             } catch (Exception e) {
//                 log.warn("Failed to create JUnitReportCollector class [" + className + "] so use the default one;"
//                         + " error cause: " + e.toString());
//             }
//         }
//         return new JUnitSecurityReportCollector();
//     }
// 
// }


// Path: src/main/java/org/ktc/soapui/maven/extension/impl/runner/SoapUIProExtensionTestCaseRunner.java
import com.eviware.soapui.SoapUIProTestCaseRunner;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.report.JUnitReportCollector;
import com.eviware.soapui.report.JUnitSecurityReportCollector;
import org.ktc.soapui.maven.extension.impl.report.ReportCollectorFactory;

    public void setTestSuiteProperties(String[] testSuiteProperties) {
        this.testSuiteProperties = testSuiteProperties;
    }

    @Override
    protected void initProject(WsdlProject project) {
        super.initProject(project);
        initTestSuiteProperties(project);
    }

    private void initTestSuiteProperties(WsdlProject project) {
        TestSuitePropertiesModifier.overrideTestSuiteProperties(project, testSuiteProperties);
    }
    
    @Override
    public void exportJUnitReports(JUnitReportCollector collector, String folder, WsdlProject project) {
        if (junitHtmlReport) {
            super.exportJUnitReports(collector, folder, project);
        } else {
            // copy from SoapUITestCaseRunner
            try {
                collector.saveReports(folder == null ? "" : folder);
            } catch (Exception e) {
                log.error("Failed to create JUnit reports", e);
            }
        }
    }

    @Override
    protected JUnitSecurityReportCollector createJUnitSecurityReportCollector() {
        return ReportCollectorFactory.newReportCollector();