### Question:
KubernetesUtils { public static String resolveValue(String value) throws KubernetesPluginException { 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 KubernetesPluginException("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 writeToFile(String context, String outputFileName); static void writeToFile(Path outputDir, String context, String fileSuffix); static byte[] readFileContent(Path targetFilePath); static void copyFileOrDirectory(String source, String destination); static void printInfo(String msg); static void printError(String msg); static void printDebug(String msg); static void printWarning(String message); static void printInstruction(String msg); static void deleteDirectory(Path path); static boolean isBlank(String str); static String resolveValue(String value); static List<String> getList(BLangExpression expr); static Map<String, String> getMap(BLangExpression expr); static boolean getBooleanValue(BLangExpression expr); static long getLongValue(BLangExpression expr); static int getIntValue(BLangExpression expr); static String getStringValue(BLangExpression expr); static String getValidName(String name); static DeploymentBuildExtension parseBuildExtension(BLangExpression buildExtensionValue); static Map<String, EnvVarValueModel> getEnvVarMap(BLangExpression envVarValues); static Set<String> getImagePullSecrets(BLangRecordLiteral.BLangRecordKeyValueField keyValue); static Set<CopyFileModel> getExternalFileMap(BLangRecordLiteral.BLangRecordKeyValueField keyValue); static List<EnvVar> populateEnvVar(Map<String, EnvVarValueModel> envMap); static List<BLangRecordLiteral.BLangRecordKeyValueField> convertRecordFields(
            List<BLangRecordLiteral.RecordField> fields); 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(KubernetesUtils.resolveValue("$env{DOCKER_USERNAME}"), "anuruddhal"); } catch (KubernetesPluginException e) { Assert.fail("Unable to resolve environment variable"); } try { KubernetesUtils.resolveValue("$env{DOCKER_PASSWORD}"); Assert.fail("Env value should be resolved"); } catch (KubernetesPluginException e) { Assert.assertEquals(e.getMessage(), "error resolving value: DOCKER_PASSWORD is not set in the " + "environment."); } Assert.assertEquals(KubernetesUtils.resolveValue("demo"), "demo"); }