@Test void detemplatizeBundleStringMissingEnv() { Map<String,ContextVariableEnvironmentProperty> env = new HashMap<>(); env.put("myEnvironmentVariable", new ContextVariableEnvironmentProperty("myEnvironmentVariable","abc")); Bundle bundle = new Bundle(); bundle.putAllContextVariableEnvironmentProperties(env); BundleDetemplatizer bundleDetemplatizer = new BundleDetemplatizer(bundle); assertThrows(BundleDetemplatizeException.class, () -> bundleDetemplatizer.detemplatizeBundleString(bundleXml)); }
CharSequence detemplatizeBundleString(CharSequence bundleString) { Map<String, String> contextVariableEnvironmentVariables = bundle.getContextVariableEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); Map<String, String> serviceEnvironmentVariables = bundle.getServiceEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); bundleString = replaceVariableInBundle(bundleString, contextVariableEnvironmentVariables, "L7p:Base64Expression ENV_PARAM_NAME=\\\"ENV\\.(.+?)\\\"", v -> "L7p:Base64Expression stringValue=\"" + Base64.getEncoder().encodeToString(v.getBytes()) + "\""); bundleString = replaceVariableInBundle(bundleString, serviceEnvironmentVariables, "l7:StringValue>SERVICE_PROPERTY_ENV\\.(.+?)<", v -> "l7:StringValue>" + v + "<").toString(); return bundleString; }
BundleDetemplatizer { CharSequence detemplatizeBundleString(CharSequence bundleString) { Map<String, String> contextVariableEnvironmentVariables = bundle.getContextVariableEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); Map<String, String> serviceEnvironmentVariables = bundle.getServiceEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); bundleString = replaceVariableInBundle(bundleString, contextVariableEnvironmentVariables, "L7p:Base64Expression ENV_PARAM_NAME=\\\"ENV\\.(.+?)\\\"", v -> "L7p:Base64Expression stringValue=\"" + Base64.getEncoder().encodeToString(v.getBytes()) + "\""); bundleString = replaceVariableInBundle(bundleString, serviceEnvironmentVariables, "l7:StringValue>SERVICE_PROPERTY_ENV\\.(.+?)<", v -> "l7:StringValue>" + v + "<").toString(); return bundleString; } }
BundleDetemplatizer { CharSequence detemplatizeBundleString(CharSequence bundleString) { Map<String, String> contextVariableEnvironmentVariables = bundle.getContextVariableEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); Map<String, String> serviceEnvironmentVariables = bundle.getServiceEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); bundleString = replaceVariableInBundle(bundleString, contextVariableEnvironmentVariables, "L7p:Base64Expression ENV_PARAM_NAME=\\\"ENV\\.(.+?)\\\"", v -> "L7p:Base64Expression stringValue=\"" + Base64.getEncoder().encodeToString(v.getBytes()) + "\""); bundleString = replaceVariableInBundle(bundleString, serviceEnvironmentVariables, "l7:StringValue>SERVICE_PROPERTY_ENV\\.(.+?)<", v -> "l7:StringValue>" + v + "<").toString(); return bundleString; } BundleDetemplatizer(Bundle bundle); }
BundleDetemplatizer { CharSequence detemplatizeBundleString(CharSequence bundleString) { Map<String, String> contextVariableEnvironmentVariables = bundle.getContextVariableEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); Map<String, String> serviceEnvironmentVariables = bundle.getServiceEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); bundleString = replaceVariableInBundle(bundleString, contextVariableEnvironmentVariables, "L7p:Base64Expression ENV_PARAM_NAME=\\\"ENV\\.(.+?)\\\"", v -> "L7p:Base64Expression stringValue=\"" + Base64.getEncoder().encodeToString(v.getBytes()) + "\""); bundleString = replaceVariableInBundle(bundleString, serviceEnvironmentVariables, "l7:StringValue>SERVICE_PROPERTY_ENV\\.(.+?)<", v -> "l7:StringValue>" + v + "<").toString(); return bundleString; } BundleDetemplatizer(Bundle bundle);  }
BundleDetemplatizer { CharSequence detemplatizeBundleString(CharSequence bundleString) { Map<String, String> contextVariableEnvironmentVariables = bundle.getContextVariableEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); Map<String, String> serviceEnvironmentVariables = bundle.getServiceEnvironmentProperties().entrySet().stream().collect(toMap(Entry::getKey, e -> e.getValue().getValue())); bundleString = replaceVariableInBundle(bundleString, contextVariableEnvironmentVariables, "L7p:Base64Expression ENV_PARAM_NAME=\\\"ENV\\.(.+?)\\\"", v -> "L7p:Base64Expression stringValue=\"" + Base64.getEncoder().encodeToString(v.getBytes()) + "\""); bundleString = replaceVariableInBundle(bundleString, serviceEnvironmentVariables, "l7:StringValue>SERVICE_PROPERTY_ENV\\.(.+?)<", v -> "l7:StringValue>" + v + "<").toString(); return bundleString; } BundleDetemplatizer(Bundle bundle);   }