// Path: src/main/java/org/ktc/soapui/maven/extension/impl/report/ReportCollectorFactory.java
// 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 static org.assertj.core.api.Assertions.assertThat;
import static org.ktc.soapui.maven.extension.impl.report.ReportCollectorFactory.newReportCollector;
import com.eviware.soapui.report.JUnitSecurityReportCollector;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
/*
 * Copyright 2013-2014 Thomas Bouffard (redfish4ktc)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.ktc.soapui.maven.extension.impl.report;



public class ReportCollectorFactoryTest {

    private static final Class<JUnitSecurityReportCollector> DEFAULT_COLLECTOR_CLASS = JUnitSecurityReportCollector.class;
    private static final String REPORT_COLLECTOR_SYS_PROP = "soapui.junit.reportCollector";

    @Rule
    public final RestoreSystemProperties restoreSysProperties = new RestoreSystemProperties(REPORT_COLLECTOR_SYS_PROP);

    @Test
    public void newReportCollectorWithEmptySystemProperty() {
        System.setProperty(REPORT_COLLECTOR_SYS_PROP, "");
// Path: src/main/java/org/ktc/soapui/maven/extension/impl/report/ReportCollectorFactory.java
// 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/test/java/org/ktc/soapui/maven/extension/impl/report/ReportCollectorFactoryTest.java
import static org.assertj.core.api.Assertions.assertThat;
import static org.ktc.soapui.maven.extension.impl.report.ReportCollectorFactory.newReportCollector;
import com.eviware.soapui.report.JUnitSecurityReportCollector;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;

/*
 * Copyright 2013-2014 Thomas Bouffard (redfish4ktc)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package org.ktc.soapui.maven.extension.impl.report;



public class ReportCollectorFactoryTest {

    private static final Class<JUnitSecurityReportCollector> DEFAULT_COLLECTOR_CLASS = JUnitSecurityReportCollector.class;
    private static final String REPORT_COLLECTOR_SYS_PROP = "soapui.junit.reportCollector";

    @Rule
    public final RestoreSystemProperties restoreSysProperties = new RestoreSystemProperties(REPORT_COLLECTOR_SYS_PROP);

    @Test
    public void newReportCollectorWithEmptySystemProperty() {
        System.setProperty(REPORT_COLLECTOR_SYS_PROP, "");
        assertThat(newReportCollector()).isInstanceOf(DEFAULT_COLLECTOR_CLASS);