// Path: src/main/java/org/ktc/soapui/maven/extension/impl/runner/SoapUIProExtensionMockServiceRunner.java
// public class SoapUIProExtensionMockServiceRunner extends SoapUIProMockServiceRunner {
// 
//     private static final String COVERAGE_BUILDER_FIELD_NAME = "c";
// 
//     public SoapUIProExtensionMockServiceRunner() {
//         super();
//     }
// 
//     public SoapUIProExtensionMockServiceRunner(String title) {
//         super(title);
//     }
// 
//     public void activateCoverageReport(boolean activate) {
//         if (activate) {
//             setCoverageBuilder(new CoverageBuilder());
//         }
//     }
// 
//     // duplicated from SmartBear implementation has their pro mock runner defines its own outputFolder field that is
//     // then not used by this method
//     @Override
//     public String getAbsoluteOutputFolder(ModelItem modelItem) {
//         // use getter instead of calling the ouputFolder field directly
//         String folder = PropertyExpander.expandProperties(modelItem, getOutputFolder());
// 
//         if (StringUtils.isNullOrEmpty(folder)) {
//             folder = PathUtils.getExpandedResourceRoot(modelItem);
//         } else if (PathUtils.isRelativePath(folder)) {
//             folder = PathUtils.resolveResourcePath(folder, modelItem);
//         }
// 
//         return folder;
//     }
// 
//     private void setCoverageBuilder(CoverageBuilder coverageBuilder) {
//         try {
//             FieldUtils.writeField(this, COVERAGE_BUILDER_FIELD_NAME, coverageBuilder, true);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException("Unable to write field " + COVERAGE_BUILDER_FIELD_NAME, e);
//         }
//     }
// 
//     public boolean isActivateCoverageBuilder() {
//         return getCoverageBuilder() != null;
//     }
// 
//     private CoverageBuilder getCoverageBuilder() {
//         try {
//             return (CoverageBuilder) FieldUtils.readField(this, COVERAGE_BUILDER_FIELD_NAME, true);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException("Unable to read field " + COVERAGE_BUILDER_FIELD_NAME, e);
//         }
//     }
// 
//     @Override
//     protected void initGroovyLog() {
//         // stubbed to prevent multiple appenders, groovy.log is configured in soapui-log4j.xml
//     }
// 
// }
// 
// Path: src/main/java/org/ktc/soapui/maven/extension/impl/runner/wrapper/SoapUIMockRunnerWrapper.java
// public class SoapUIMockRunnerWrapper extends AbstractRunnerWrapper<SoapUIMockServiceRunner> {
// 
//     public static SoapUIMockRunnerWrapper newSoapUIMockServiceRunner(String runnerType) {
//         RunnerType runnerTypeEnum = EnumConverter.toRunnerType(runnerType);
//         SoapUIMockServiceRunner runner = runnerTypeEnum.newMockRunner();
//         return new SoapUIMockRunnerWrapper(runner, runnerTypeEnum);
//     }
// 
//     private SoapUIMockRunnerWrapper(SoapUIMockServiceRunner runner, RunnerType runnerType) {
//         super(runner, runnerType);
//     }
// 
// }


import com.eviware.soapui.tools.SoapUIMockServiceRunner;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.ktc.soapui.maven.extension.impl.runner.SoapUIProExtensionMockServiceRunner;
import org.ktc.soapui.maven.extension.impl.runner.wrapper.SoapUIMockRunnerWrapper;
/*
 * Copyright 2012-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;


public class MockServiceMojo extends AbstractSoapuiRunnerMojo {
    // already in smartbear implementation
    private String mockService;
    private String path;
    private String port;
    private boolean noBlock;

    // custom maven-soapui-extension-plugin
    private boolean coverageReport;

    @Override
    protected void performRunnerExecute() throws MojoExecutionException, MojoFailureException {
        SoapUIMockRunnerWrapper runnerWrapper = SoapUIMockRunnerWrapper.newSoapUIMockServiceRunner(runnerType);

        SoapUIMockServiceRunner runner = runnerWrapper.getRunner();
        configureWithSharedParameters(runner);

        runner.setBlock(!noBlock);
        runner.setMockService(mockService);
        runner.setPath(path);
        runner.setPort(port);
        runner.setSaveAfterRun(saveAfterRun);

        if (runnerWrapper.isProRunner()) {
// Path: src/main/java/org/ktc/soapui/maven/extension/impl/runner/SoapUIProExtensionMockServiceRunner.java
// public class SoapUIProExtensionMockServiceRunner extends SoapUIProMockServiceRunner {
// 
//     private static final String COVERAGE_BUILDER_FIELD_NAME = "c";
// 
//     public SoapUIProExtensionMockServiceRunner() {
//         super();
//     }
// 
//     public SoapUIProExtensionMockServiceRunner(String title) {
//         super(title);
//     }
// 
//     public void activateCoverageReport(boolean activate) {
//         if (activate) {
//             setCoverageBuilder(new CoverageBuilder());
//         }
//     }
// 
//     // duplicated from SmartBear implementation has their pro mock runner defines its own outputFolder field that is
//     // then not used by this method
//     @Override
//     public String getAbsoluteOutputFolder(ModelItem modelItem) {
//         // use getter instead of calling the ouputFolder field directly
//         String folder = PropertyExpander.expandProperties(modelItem, getOutputFolder());
// 
//         if (StringUtils.isNullOrEmpty(folder)) {
//             folder = PathUtils.getExpandedResourceRoot(modelItem);
//         } else if (PathUtils.isRelativePath(folder)) {
//             folder = PathUtils.resolveResourcePath(folder, modelItem);
//         }
// 
//         return folder;
//     }
// 
//     private void setCoverageBuilder(CoverageBuilder coverageBuilder) {
//         try {
//             FieldUtils.writeField(this, COVERAGE_BUILDER_FIELD_NAME, coverageBuilder, true);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException("Unable to write field " + COVERAGE_BUILDER_FIELD_NAME, e);
//         }
//     }
// 
//     public boolean isActivateCoverageBuilder() {
//         return getCoverageBuilder() != null;
//     }
// 
//     private CoverageBuilder getCoverageBuilder() {
//         try {
//             return (CoverageBuilder) FieldUtils.readField(this, COVERAGE_BUILDER_FIELD_NAME, true);
//         } catch (IllegalAccessException e) {
//             throw new RuntimeException("Unable to read field " + COVERAGE_BUILDER_FIELD_NAME, e);
//         }
//     }
// 
//     @Override
//     protected void initGroovyLog() {
//         // stubbed to prevent multiple appenders, groovy.log is configured in soapui-log4j.xml
//     }
// 
// }
// 
// Path: src/main/java/org/ktc/soapui/maven/extension/impl/runner/wrapper/SoapUIMockRunnerWrapper.java
// public class SoapUIMockRunnerWrapper extends AbstractRunnerWrapper<SoapUIMockServiceRunner> {
// 
//     public static SoapUIMockRunnerWrapper newSoapUIMockServiceRunner(String runnerType) {
//         RunnerType runnerTypeEnum = EnumConverter.toRunnerType(runnerType);
//         SoapUIMockServiceRunner runner = runnerTypeEnum.newMockRunner();
//         return new SoapUIMockRunnerWrapper(runner, runnerTypeEnum);
//     }
// 
//     private SoapUIMockRunnerWrapper(SoapUIMockServiceRunner runner, RunnerType runnerType) {
//         super(runner, runnerType);
//     }
// 
// }


// Path: src/main/java/org/ktc/soapui/maven/extension/MockServiceMojo.java
import com.eviware.soapui.tools.SoapUIMockServiceRunner;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.ktc.soapui.maven.extension.impl.runner.SoapUIProExtensionMockServiceRunner;
import org.ktc.soapui.maven.extension.impl.runner.wrapper.SoapUIMockRunnerWrapper;

/*
 * Copyright 2012-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;


public class MockServiceMojo extends AbstractSoapuiRunnerMojo {
    // already in smartbear implementation
    private String mockService;
    private String path;
    private String port;
    private boolean noBlock;

    // custom maven-soapui-extension-plugin
    private boolean coverageReport;

    @Override
    protected void performRunnerExecute() throws MojoExecutionException, MojoFailureException {
        SoapUIMockRunnerWrapper runnerWrapper = SoapUIMockRunnerWrapper.newSoapUIMockServiceRunner(runnerType);

        SoapUIMockServiceRunner runner = runnerWrapper.getRunner();
        configureWithSharedParameters(runner);

        runner.setBlock(!noBlock);
        runner.setMockService(mockService);
        runner.setPath(path);
        runner.setPort(port);
        runner.setSaveAfterRun(saveAfterRun);

        if (runnerWrapper.isProRunner()) {
            SoapUIProExtensionMockServiceRunner proRunner = (SoapUIProExtensionMockServiceRunner) runner;