### Question:
HttpRequestTransformer implements Transformer { protected String applyVariablesToString(final String str, final InputRow inputRow) { if (Strings.isNullOrEmpty(str)) { return null; } String result = str; final List<Object> values = inputRow.getValues(input); for (int i = 0; i < input.length; i++) { final Object value = values.get(i); final String valueStr; if (value == null) { valueStr = ""; } else { valueStr = value.toString(); } result = StringUtils.replaceAll(result, variableNames[i], valueStr); } return result; }  @Initialize void init(); @Close void close(); @Override OutputColumns getOutputColumns(); @Override Object[] transform(final InputRow inputRow); void setCharset(final String charset); void setMaxConcurrentRequests(final int maxConcurrentRequests); void setMethod(final HttpMethod method); void setRequestBody(final String requestBody); void setUrl(final String url); void setHttpClient(final CloseableHttpClient httpClient); void setInputAndVariables(final InputColumn<?>[] input, final String[] variableNames); static final String PROPERTY_INPUT_COLUMNS; static final String PROPERTY_VARIABLE_NAMES; }### Answer:
@Test public void testApplyVariablesToString() throws Exception { final HttpRequestTransformer t = new HttpRequestTransformer(); t.setHttpClient(HttpClients.createSystem()); t.setMethod(HttpMethod.GET); t.setRequestBody("Hello ${name}! Dear ${name} would you like some ${product}?"); final InputColumn<?> col1 = new MockInputColumn<>("foo"); t.setInputAndVariables(new InputColumn[] { col1 }, new String[] { "${name}" }); t.init(); assertEquals("Hello world! Dear world would you like some ${product}?", t.applyVariablesToString(t.requestBody, new MockInputRow().put(col1, "world"))); assertEquals("Hello ! Dear would you like some ${product}?", t.applyVariablesToString(t.requestBody, new MockInputRow().put(col1, null))); final InputColumn<?> col2 = new MockInputColumn<>("bar"); t.setInputAndVariables(new InputColumn[] { col1, col2 }, new String[] { "${name}", "${product}" }); assertEquals("Hello customer! Dear customer would you like some tea?", t.applyVariablesToString(t.requestBody, new MockInputRow().put(col1, "customer").put(col2, "tea"))); t.close(); }