@Test (enabled = true) public void testGeneralMapAsInput() { underTest = new PlaceholderHandler(); Map<String, Object> beforeSuiteVariables = new HashMap(); beforeSuiteVariables.put("preloadedVarName", "preloadedVarValue"); TestSuiteHandler.getInstance().getTestCaseUtils().setBeforeSuiteVariables(beforeSuiteVariables); Map<String, Object> mapToProcess = new HashMap(); mapToProcess.put("field1", "field1_value"); Map<String, String> secondLevelMap = new HashMap(); secondLevelMap.put("field2_1", "${preload[preloadedVarName]}"); mapToProcess.put("field2", secondLevelMap); Map<String, Object> expectedMap = new HashMap(); expectedMap.put("field1", "field1_value"); Map<String, String> secondLevelExpectedMap = new HashMap(); secondLevelExpectedMap.put("field2_1", "preloadedVarValue"); expectedMap.put("field2", secondLevelExpectedMap); Map processedMap = underTest.placeholderProcessMap(mapToProcess); 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; }