Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemEnvironmentVariables object not retrieving properties on every instance #3181

Closed
a-k-khurana opened this issue Jul 11, 2023 · 3 comments

Comments

@a-k-khurana
Copy link

a-k-khurana commented Jul 11, 2023

When debugging first test I can see SystemEnvironmentVariables retrieving all properties successfuly, but when it runs second test, very few properties are present in SystemEnvironmentVariables object.

Below is my build.gradle

ext {
slf4jVersion = '1.7.7'
serenityCoreVersion = '3.8.1'
serenityCucumberVersion = '3.8.1'
serenityRestAssuredVersion = '3.8.1'
junitVersion = '4.12'
assertJVersion = '3.8.0'
logbackVersion = '1.2.3'
}

dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.1'
testCompile group: 'org.apache.maven.plugins', name: 'maven-failsafe-plugin', version: '3.0.0-M5'
implementation "ch.qos.logback:logback-classic:${logbackVersion}"
implementation group: 'net.serenity-bdd', name: 'serenity-rest-assured', version: '3.8.1'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
compile 'org.postgresql:postgresql:42.2.5'
compile group: 'org.postgresql', name: 'postgresql', version: '9.3-1100-jdbc4'
compile 'com.adyen:adyen-java-api-library:9.0.0'
implementation group: 'org.json', name: 'json', version: '20210307'
testImplementation "net.serenity-bdd:serenity-core:${serenityCoreVersion}",
"net.serenity-bdd:serenity-cucumber:${serenityCucumberVersion}",
"net.serenity-bdd:serenity-ensure:${serenityCoreVersion}",
"junit:junit:${junitVersion}",
"org.assertj:assertj-core:${assertJVersion}"
testImplementation 'com.auth0:java-jwt:4.0.0'
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.0-M1'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0-M1'
testImplementation 'org.junit.vintage:junit-vintage-engine:5.10.0-M1'
testImplementation 'io.cucumber:cucumber-junit-platform-engine:7.12.1'
testImplementation 'org.junit.platform:junit-platform-suite:1.10.0-M1'
}

@a-k-khurana
Copy link
Author

all good. I've had to write this code to grab hold of SystemEnvironmentVariables and store it for later use.

` EnvironmentVariables environmentVariables1 = new SystemEnvironmentVariables();
if(fixed == null) {
Map<String, String> map = environmentVariables.getProperties().entrySet().stream().collect(Collectors.toMap(
e-> (String) e.getKey(),
e-> (String) e.getValue()
));
fixed = new EnvVariables();
fixed.setProperties(map);

    }
    Map<String, String> savedMap = fixed.getProperties().entrySet().stream().collect(Collectors.toMap(
            e -> (String) e.getKey(),
            e -> (String) e.getValue()
    ));
    environmentVariables1.setProperties(savedMap);
    return EnvironmentSpecificConfiguration.from(environmentVariables1)
            .getProperty(propName);`

@wakaleo
Copy link
Member

wakaleo commented Jul 13, 2023

Can you try with 3.9.0?

@wakaleo
Copy link
Member

wakaleo commented Jul 29, 2023

Fixed in version 3.9.8

@wakaleo wakaleo closed this as completed Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants