### Question:
DockerPluginUtils { public static String resolveValue(String value) throws DockerPluginException { int startIndex; if ((startIndex = value.indexOf("$env{")) >= 0) { int endIndex = value.indexOf("}", startIndex); if (endIndex > 0) { String varName = value.substring(startIndex + 5, endIndex).trim(); String resolvedVar = Optional.ofNullable(System.getenv(varName)).orElseThrow(() -> new DockerPluginException("error resolving value: " + varName + " is not set in the environment.")); String rest = (value.length() > endIndex + 1) ? resolveValue(value.substring(endIndex + 1)) : ""; return value.substring(0, startIndex) + resolvedVar + rest; } } return value; }  static void printError(String msg); static List<BLangRecordLiteral.BLangRecordKeyValueField> getKeyValuePairs(BLangRecordLiteral bLangRecordLiteral); static void printDebug(String msg); static boolean isBlank(String str); static void deleteDirectory(Path pathToBeDeleted); static String resolveValue(String value); static AnnotationAttachmentNode createAnnotation(String annotationName);  }### Answer:
@Test public void resolveValueTest() throws Exception { Map<String, String> env = new HashMap<>(); env.put("DOCKER_USERNAME", "anuruddhal"); setEnv(env); try { Assert.assertEquals(DockerPluginUtils.resolveValue("$env{DOCKER_USERNAME}"), "anuruddhal"); } catch (DockerPluginException e) { Assert.fail("Unable to resolve environment variable"); } try { DockerPluginUtils.resolveValue("$env{DOCKER_PASSWORD}"); Assert.fail("Env value should be resolved"); } catch (DockerPluginException e) { Assert.assertEquals(e.getMessage(), "error resolving value: DOCKER_PASSWORD is not set in the " + "environment."); } Assert.assertEquals(DockerPluginUtils.resolveValue("demo"), "demo"); }