From 5ef816dcf307fb22cf9d5d415d5f6bb982404ec9 Mon Sep 17 00:00:00 2001 From: Manoj Date: Thu, 11 May 2017 12:28:51 +0530 Subject: [PATCH] Ensure system env var is populated --- utils/src/main/java/com/indix/gocd/utils/GoEnvironment.java | 5 +++-- .../test/java/com/indix/gocd/utils/GoEnvironmentTest.java | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/src/main/java/com/indix/gocd/utils/GoEnvironment.java b/utils/src/main/java/com/indix/gocd/utils/GoEnvironment.java index 8999089..30c8c39 100644 --- a/utils/src/main/java/com/indix/gocd/utils/GoEnvironment.java +++ b/utils/src/main/java/com/indix/gocd/utils/GoEnvironment.java @@ -18,13 +18,14 @@ */ public class GoEnvironment { private Pattern envPat = Pattern.compile("\\$\\{(\\w+)\\}"); - private Map environment = new HashMap(); + private Map environment = new HashMap<>(); public GoEnvironment() { - this(System.getenv()); + this.environment.putAll(System.getenv()); } public GoEnvironment(Map defaultEnvironment) { + this(); this.environment.putAll(defaultEnvironment); } diff --git a/utils/src/test/java/com/indix/gocd/utils/GoEnvironmentTest.java b/utils/src/test/java/com/indix/gocd/utils/GoEnvironmentTest.java index 08bb762..3ce287d 100644 --- a/utils/src/test/java/com/indix/gocd/utils/GoEnvironmentTest.java +++ b/utils/src/test/java/com/indix/gocd/utils/GoEnvironmentTest.java @@ -71,8 +71,7 @@ public void shouldNotReplaceUnknownEnvVariables() { assertThat(replaced, is("COUNT:1 ${DOESNT_EXIST}")); } - - + @Test public void shouldGetHasAWSUseIamRoleTrueIfSetToTrue() { GoEnvironment sut = new GoEnvironment(mockEnvironmentVariables