@Test (enabled = true) public void testProcessPlaceholders() { underTest = new PlaceholderHandler(); Map<String, Object> beforeSuiteVariables = new HashMap(); beforeSuiteVariables.put("preloadedVarName1", "preloadedVarValue1"); beforeSuiteVariables.put("preloadedVarName2", "preloadedVarValue2"); beforeSuiteVariables.put("preloadedVarName3", "preloadedVarValue3"); TestSuiteHandler.getInstance().getTestCaseUtils().setBeforeSuiteVariables(beforeSuiteVariables); Map<String, Object> mapToProcess = new HashMap(); mapToProcess.put("field1", "{\"custname\":\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"${preload[preloadedVarName1]}\"" + ",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"${preload[preloadedVarName2]}\"}"); Map processedMap = underTest.placeholderProcessMap(mapToProcess); Map<String, Object> expectedMap = new HashMap(); expectedMap.put("field1", "{\"custname\":\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"preloadedVarValue1\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue2\"}"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "${preload[preloadedVarName3]}:\"pippo\",\"custemail\":\"pippo@test.test\"," + "\"delivery\":\"${preload[preloadedVarName1]}\",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"${preload[preloadedVarName2]}\"}"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue3:\"pippo\",\"custemail\":\"pippo@test.test\"," + "\"delivery\":\"preloadedVarValue1\",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue2\"}"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "${preload[preloadedVarName1]}:\"pippo\",\"custemail\":\"pippo@test.test\"," + "\"delivery\":\"${preload[preloadedVarName1]}\",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"${preload[preloadedVarName1]}\"}"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\"," + "\"delivery\":\"preloadedVarValue1\",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "${preload[preloadedVarName1]}:\"pippo\",\"custemail\":\"pippo@test.test\"," + "\"delivery\":\"${preload[preloadedVarName1]}\",\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"]," + "\"comment\":\"${preload[preloadedVarName1]}\"}${preload[preloadedVarName1]}"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"preloadedVarValue1\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"${preload[preloadedVarName1]}\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"preloadedVarValue1\",\"size\":\"large\"," + "\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"preloadedVarValue1\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"preloadedVarValue1\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); Assert.assertEquals(processedMap, expectedMap); mapToProcess = new HashMap(); mapToProcess.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"{preload[preloadedVarName1]}\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); processedMap = underTest.placeholderProcessMap(mapToProcess); expectedMap = new HashMap(); expectedMap.put("field1", "preloadedVarValue1:\"pippo\",\"custemail\":\"pippo@test.test\",\"delivery\":\"{preload[preloadedVarName1]}\"," + "\"size\":\"large\",\"topping\": [\"bacon\",\"cheese\"],\"comment\":\"preloadedVarValue1\"}preloadedVarValue1"); Assert.assertEquals(processedMap, expectedMap); }
public Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap) { Map<String, Object> outputParams = requestParamsMap; if (requestParamsMap != null) { try { for (Map.Entry<String, Object> parameterObj : outputParams.entrySet()) { Object parameterValue = parameterObj.getValue(); logUtils.trace("parameterObj.getValue() = '{}'", parameterValue); logUtils.trace("parameterValue.getClass() = '{}'", parameterValue.getClass()); if (parameterValue.getClass().equals(String.class)) { if (((String) parameterValue).contains(PLACEHOLDER_SYMBOL_BEGIN)) { outputParams.put(parameterObj.getKey(), placeholderProcessString((String) parameterValue)); } } else if (parameterValue.getClass().equals(Map.class) || parameterValue.getClass().equals(HashMap.class)) { outputParams.put(parameterObj.getKey(), placeholderProcessMap((Map) parameterValue)); } } } catch (Exception oEx) { logUtils.error("Exception = '{}'", oEx.getLocalizedMessage()); } } else { outputParams = requestParamsMap; } return outputParams; }
PlaceholderHandler { public Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap) { Map<String, Object> outputParams = requestParamsMap; if (requestParamsMap != null) { try { for (Map.Entry<String, Object> parameterObj : outputParams.entrySet()) { Object parameterValue = parameterObj.getValue(); logUtils.trace("parameterObj.getValue() = '{}'", parameterValue); logUtils.trace("parameterValue.getClass() = '{}'", parameterValue.getClass()); if (parameterValue.getClass().equals(String.class)) { if (((String) parameterValue).contains(PLACEHOLDER_SYMBOL_BEGIN)) { outputParams.put(parameterObj.getKey(), placeholderProcessString((String) parameterValue)); } } else if (parameterValue.getClass().equals(Map.class) || parameterValue.getClass().equals(HashMap.class)) { outputParams.put(parameterObj.getKey(), placeholderProcessMap((Map) parameterValue)); } } } catch (Exception oEx) { logUtils.error("Exception = '{}'", oEx.getLocalizedMessage()); } } else { outputParams = requestParamsMap; } return outputParams; } }
PlaceholderHandler { public Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap) { Map<String, Object> outputParams = requestParamsMap; if (requestParamsMap != null) { try { for (Map.Entry<String, Object> parameterObj : outputParams.entrySet()) { Object parameterValue = parameterObj.getValue(); logUtils.trace("parameterObj.getValue() = '{}'", parameterValue); logUtils.trace("parameterValue.getClass() = '{}'", parameterValue.getClass()); if (parameterValue.getClass().equals(String.class)) { if (((String) parameterValue).contains(PLACEHOLDER_SYMBOL_BEGIN)) { outputParams.put(parameterObj.getKey(), placeholderProcessString((String) parameterValue)); } } else if (parameterValue.getClass().equals(Map.class) || parameterValue.getClass().equals(HashMap.class)) { outputParams.put(parameterObj.getKey(), placeholderProcessMap((Map) parameterValue)); } } } catch (Exception oEx) { logUtils.error("Exception = '{}'", oEx.getLocalizedMessage()); } } else { outputParams = requestParamsMap; } return outputParams; } PlaceholderHandler(); }
PlaceholderHandler { public Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap) { Map<String, Object> outputParams = requestParamsMap; if (requestParamsMap != null) { try { for (Map.Entry<String, Object> parameterObj : outputParams.entrySet()) { Object parameterValue = parameterObj.getValue(); logUtils.trace("parameterObj.getValue() = '{}'", parameterValue); logUtils.trace("parameterValue.getClass() = '{}'", parameterValue.getClass()); if (parameterValue.getClass().equals(String.class)) { if (((String) parameterValue).contains(PLACEHOLDER_SYMBOL_BEGIN)) { outputParams.put(parameterObj.getKey(), placeholderProcessString((String) parameterValue)); } } else if (parameterValue.getClass().equals(Map.class) || parameterValue.getClass().equals(HashMap.class)) { outputParams.put(parameterObj.getKey(), placeholderProcessMap((Map) parameterValue)); } } } catch (Exception oEx) { logUtils.error("Exception = '{}'", oEx.getLocalizedMessage()); } } else { outputParams = requestParamsMap; } return outputParams; } PlaceholderHandler(); Map<String, HeatPlaceholderModuleProvider> constructProviderMap(Map<String, HeatPlaceholderModuleProvider> providerMapInput,
            List<String> handledPlaceholders,
            HeatPlaceholderModuleProvider provider); Object placeholderProcessString(String inputStr); String getPathVar(String inputObj); String processHeaderPlaceholder(String inputString); Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap); void setResponse(Response rsp); void setPreloadedVariables(Map<String, Object> preloadedVarsInput); Map<String, Object> getPreloadedVariables(); void setFlowVariables(Map<Integer, Map<String, String>> flowPreloadedVariables); }
PlaceholderHandler { public Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap) { Map<String, Object> outputParams = requestParamsMap; if (requestParamsMap != null) { try { for (Map.Entry<String, Object> parameterObj : outputParams.entrySet()) { Object parameterValue = parameterObj.getValue(); logUtils.trace("parameterObj.getValue() = '{}'", parameterValue); logUtils.trace("parameterValue.getClass() = '{}'", parameterValue.getClass()); if (parameterValue.getClass().equals(String.class)) { if (((String) parameterValue).contains(PLACEHOLDER_SYMBOL_BEGIN)) { outputParams.put(parameterObj.getKey(), placeholderProcessString((String) parameterValue)); } } else if (parameterValue.getClass().equals(Map.class) || parameterValue.getClass().equals(HashMap.class)) { outputParams.put(parameterObj.getKey(), placeholderProcessMap((Map) parameterValue)); } } } catch (Exception oEx) { logUtils.error("Exception = '{}'", oEx.getLocalizedMessage()); } } else { outputParams = requestParamsMap; } return outputParams; } PlaceholderHandler(); Map<String, HeatPlaceholderModuleProvider> constructProviderMap(Map<String, HeatPlaceholderModuleProvider> providerMapInput,
            List<String> handledPlaceholders,
            HeatPlaceholderModuleProvider provider); Object placeholderProcessString(String inputStr); String getPathVar(String inputObj); String processHeaderPlaceholder(String inputString); Map<String, Object> placeholderProcessMap(Map<String, Object> requestParamsMap); void setResponse(Response rsp); void setPreloadedVariables(Map<String, Object> preloadedVarsInput); Map<String, Object> getPreloadedVariables(); void setFlowVariables(Map<Integer, Map<String, String>> flowPreloadedVariables); static final String DEFAULT_PRELOADED_VALUE; static final String PLACEHOLDER_SYMBOL; static final String PLACEHOLDER_SYMBOL_BEGIN; static final String PLACEHOLDER_SYMBOL_END; static final String PLACEHOLDER_JSON_SCHEMA_NO_CHECK; static final String PATH_PLACEHOLDER; static final String PLACEHOLDER_NOT_PRESENT; static final String PLACEHOLDER_PRESENT; static final String PATH_JSONPATH_REGEXP; }