/*
 * This program and the accompanying materials are made available under the terms of the
 * Eclipse Public License v2.0 which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-v20.html
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Copyright Contributors to the Zowe Project.
 */

package org.zowe.pipelines.generic.arguments

import org.zowe.pipelines.generic.models.TestReport

/**
 * Represents the arguments available to the
 * {@link org.zowe.pipelines.generic.GenericPipeline#testGeneric(java.util.Map)} method.
 */
class TestStageArguments extends GenericStageArguments {
    /**
     * Default values provided to cobertura.
     *
     * <p>This map will be merged with {@link #cobertura}, preferring cobertura, as the final
     * object passed to the cobertura plugin</p>
     *
     * @default
     * <pre>
     * {@code
     * [
     *     autoUpdateStability       : true,
     *     classCoverageTargets      : '85, 80, 75',
     *     conditionalCoverageTargets: '70, 65, 60',
     *     failUnhealthy             : false,
     *     failUnstable              : false,
     *     fileCoverageTargets       : '100, 95, 90',
     *     lineCoverageTargets       : '80, 70, 50',
     *     maxNumberOfBuilds         : 20,
     *     methodCoverageTargets     : '80, 70, 50',
     *     onlyStable                : false,
     *     sourceEncoding            : 'ASCII',
     *     zoomCoverageChart         : false
     * ]
     * }
     * </pre>
     */
    public static final Map coberturaDefaults = [
            autoUpdateStability       : true,
            classCoverageTargets      : '85, 80, 75',
            conditionalCoverageTargets: '70, 65, 60',
            failUnhealthy             : false,
            failUnstable              : false,
            fileCoverageTargets       : '100, 95, 90',
            lineCoverageTargets       : '80, 70, 50',
            maxNumberOfBuilds         : 20,
            methodCoverageTargets     : '80, 70, 50',
            onlyStable                : false,
            sourceEncoding            : 'ASCII',
            zoomCoverageChart         : false
    ]

    /**
     * Cobertura report information.
     *
     * <p>Providing this property causes the test stage to capture a cobertura report. The values
     * provided to this map are directly sent to the cobertura plugin. For information about what
     * map options are acceptable, see <a href="https://jenkins.io/doc/pipeline/steps/cobertura/">
     * Jenkins Cobertura Plugin Documentation</a>.</p>
     */
    Map cobertura

    /**
     * Storage location for any coverage reports generated by your test task.
     *
     * <p>If this report is provided and {@link #cobertura} is not, a warning message will be
     * generated by the test task.</p>
     */
    TestReport coverageResults

    /**
     * The location of the generated junit output.
     *
     * <p>This report is required by the test stage. The junit file is used to integrate with
     * Jenkins and mark builds as unstable/failed depending on the test passing status.</p>
     */
    String junitOutput

    // @FUTURE Support a wider variety
    /**
     * Should the gnome keyring be unlocked for this test.
     *
     * @Note Setting this option to true requires that the executor machine is running the gnome
     *       keyring and the user password is jenkins. Failure to have this configuration will
     *       result in a failure to unlock the keyring. In the future, this operation would become
     *       more generic.
     *
     * @default false
     */
    boolean shouldUnlockKeyring = false

    /**
     * Storage location for the report created by your test task.
     *
     * <p>For example, this would be the html report generated by a jest test that shows the total
     * number of passing and failing tests. If not provided, the test stage will fail.</p>
     */
    TestReport testResults
}
