Package net.thucydides.core.util
Class MockEnvironmentVariables
java.lang.Object
net.thucydides.core.util.MockEnvironmentVariables
- All Implemented Interfaces:
EnvironmentVariables
public class MockEnvironmentVariables extends java.lang.Object implements EnvironmentVariables
-
Constructor Summary
Constructors Modifier Constructor Description MockEnvironmentVariables()
protected
MockEnvironmentVariables(java.util.Properties properties)
protected
MockEnvironmentVariables(java.util.Properties properties, java.util.Map<java.lang.String,java.lang.String> values)
-
Method Summary
Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>
asMap()
boolean
aValueIsDefinedFor(java.lang.Enum<?> property)
boolean
aValueIsDefinedFor(java.lang.String property)
void
clearProperty(java.lang.String name)
EnvironmentVariables
copy()
static EnvironmentVariables
fromSystemEnvironment()
java.util.List<java.lang.String>
getKeys()
java.util.Properties
getProperties()
java.util.Properties
getPropertiesWithPrefix(java.lang.String prefix)
java.lang.String
getProperty(java.lang.Enum<?> property)
java.lang.String
getProperty(java.lang.Enum<?> property, java.lang.String defaultValue)
java.lang.String
getProperty(java.lang.String name)
java.lang.String
getProperty(java.lang.String name, java.lang.String defaultValue)
java.lang.Boolean
getPropertyAsBoolean(java.lang.Enum<?> property, boolean defaultValue)
java.lang.Boolean
getPropertyAsBoolean(java.lang.String name, boolean defaultValue)
java.lang.Integer
getPropertyAsInteger(java.lang.Enum<?> property, java.lang.Integer defaultValue)
java.lang.Integer
getPropertyAsInteger(java.lang.String name, java.lang.Integer defaultValue)
java.lang.String
getValue(java.lang.Enum<?> property)
java.lang.String
getValue(java.lang.Enum<?> property, java.lang.String defaultValue)
java.lang.String
getValue(java.lang.String name)
java.lang.String
getValue(java.lang.String name, java.lang.String defaultValue)
java.lang.String
injectSystemPropertiesInto(java.lang.String value)
java.util.Optional<java.lang.String>
optionalProperty(java.lang.String name)
Returns an optional system property.boolean
propertySetIsEmpty()
void
setProperties(java.util.Map<java.lang.String,java.lang.String> newProperties)
void
setProperty(java.lang.String name, java.lang.String value)
void
setValue(java.lang.String name, java.lang.String value)
java.util.Map<java.lang.String,java.lang.String>
simpleSystemPropertiesAsMap()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
MockEnvironmentVariables
public MockEnvironmentVariables() -
MockEnvironmentVariables
protected MockEnvironmentVariables(java.util.Properties properties) -
MockEnvironmentVariables
protected MockEnvironmentVariables(java.util.Properties properties, java.util.Map<java.lang.String,java.lang.String> values)
-
-
Method Details
-
fromSystemEnvironment
-
propertySetIsEmpty
public boolean propertySetIsEmpty() -
getValue
public java.lang.String getValue(java.lang.String name)- Specified by:
getValue
in interfaceEnvironmentVariables
-
getValue
public java.lang.String getValue(java.lang.Enum<?> property)- Specified by:
getValue
in interfaceEnvironmentVariables
-
getValue
public java.lang.String getValue(java.lang.String name, java.lang.String defaultValue)- Specified by:
getValue
in interfaceEnvironmentVariables
-
getValue
public java.lang.String getValue(java.lang.Enum<?> property, java.lang.String defaultValue)- Specified by:
getValue
in interfaceEnvironmentVariables
-
getPropertyAsInteger
public java.lang.Integer getPropertyAsInteger(java.lang.String name, java.lang.Integer defaultValue)- Specified by:
getPropertyAsInteger
in interfaceEnvironmentVariables
-
getPropertyAsInteger
public java.lang.Integer getPropertyAsInteger(java.lang.Enum<?> property, java.lang.Integer defaultValue)- Specified by:
getPropertyAsInteger
in interfaceEnvironmentVariables
-
getPropertyAsBoolean
public java.lang.Boolean getPropertyAsBoolean(java.lang.String name, boolean defaultValue)- Specified by:
getPropertyAsBoolean
in interfaceEnvironmentVariables
-
getPropertyAsBoolean
public java.lang.Boolean getPropertyAsBoolean(java.lang.Enum<?> property, boolean defaultValue)- Specified by:
getPropertyAsBoolean
in interfaceEnvironmentVariables
-
getProperty
public java.lang.String getProperty(java.lang.String name)- Specified by:
getProperty
in interfaceEnvironmentVariables
-
optionalProperty
public java.util.Optional<java.lang.String> optionalProperty(java.lang.String name)Description copied from interface:EnvironmentVariables
Returns an optional system property. The property may be defined in the project's serenity.properties or serenity.conf file, or be provided as a a system property. This is designed particularly for user-provided properties, to make it easier to store test confiuration properties in a single file. Sample usage: ``` EnvironmentVariables environmentVariables; String environment = environmentVariables.optionalProperty("env").orElse("DEV") ```- Specified by:
optionalProperty
in interfaceEnvironmentVariables
-
getProperty
public java.lang.String getProperty(java.lang.Enum<?> property)- Specified by:
getProperty
in interfaceEnvironmentVariables
-
getProperty
public java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)- Specified by:
getProperty
in interfaceEnvironmentVariables
-
getProperty
public java.lang.String getProperty(java.lang.Enum<?> property, java.lang.String defaultValue)- Specified by:
getProperty
in interfaceEnvironmentVariables
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)- Specified by:
setProperty
in interfaceEnvironmentVariables
-
setProperties
public void setProperties(java.util.Map<java.lang.String,java.lang.String> newProperties)- Specified by:
setProperties
in interfaceEnvironmentVariables
-
clearProperty
public void clearProperty(java.lang.String name)- Specified by:
clearProperty
in interfaceEnvironmentVariables
-
copy
- Specified by:
copy
in interfaceEnvironmentVariables
-
getKeys
public java.util.List<java.lang.String> getKeys()- Specified by:
getKeys
in interfaceEnvironmentVariables
-
getProperties
public java.util.Properties getProperties()- Specified by:
getProperties
in interfaceEnvironmentVariables
-
getPropertiesWithPrefix
public java.util.Properties getPropertiesWithPrefix(java.lang.String prefix)- Specified by:
getPropertiesWithPrefix
in interfaceEnvironmentVariables
-
aValueIsDefinedFor
public boolean aValueIsDefinedFor(java.lang.Enum<?> property)- Specified by:
aValueIsDefinedFor
in interfaceEnvironmentVariables
-
aValueIsDefinedFor
public boolean aValueIsDefinedFor(java.lang.String property)- Specified by:
aValueIsDefinedFor
in interfaceEnvironmentVariables
-
injectSystemPropertiesInto
public java.lang.String injectSystemPropertiesInto(java.lang.String value)- Specified by:
injectSystemPropertiesInto
in interfaceEnvironmentVariables
-
asMap
public java.util.Map<java.lang.String,java.lang.String> asMap()- Specified by:
asMap
in interfaceEnvironmentVariables
-
simpleSystemPropertiesAsMap
public java.util.Map<java.lang.String,java.lang.String> simpleSystemPropertiesAsMap()- Specified by:
simpleSystemPropertiesAsMap
in interfaceEnvironmentVariables
-
setValue
public void setValue(java.lang.String name, java.lang.String value)
-