All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.reports.configuration.BooleanReportProperty.kt Maven / Gradle / Ivy

The newest version!
package net.serenitybdd.reports.configuration

import net.serenitybdd.core.environment.EnvironmentSpecificConfiguration
import net.thucydides.core.ThucydidesSystemProperty
import net.thucydides.core.util.EnvironmentVariables

class BooleanReportProperty(val property: String, val defaultValue: Boolean) : ReportProperty {
    constructor(property: ThucydidesSystemProperty, defaultValue: Boolean) : this(property.toString(), defaultValue)

    override fun configuredIn(environmentVariables: EnvironmentVariables) : Boolean = valueDefinedIn(environmentVariables, property, defaultValue)

    private fun valueDefinedIn(environmentVariables: EnvironmentVariables, propertyName: String, defaultValue: Boolean) =
       EnvironmentSpecificConfiguration.from(environmentVariables).getOptionalProperty(propertyName)
                                                           .orElse(defaultValue.toString())
                                                           .toBoolean();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy