@Test public void consume() { Map<String, String> returnResult = new HashMap<>(); List<Header> headers = new ArrayList<>(); Header header1 = new HeaderEntity("name1", "value1"); Header header2 = new HeaderEntity("name2", "value2"); headers.add(header1); headers.add(header2); headersConsumer .setHeaders(headers.toArray(new Header[headers.size()])) .consume(returnResult); assertEquals(returnResult.get(RESPONSE_HEADERS), "name1:value1\r\nname2:value2"); }
public void consume(Map<String, String> returnResult) { StringBuilder result = new StringBuilder(); if (headers != null) { for (Header header : headers) { result.append(header.toString()).append("\r\n"); } if (result.length() != 0) { result.delete(result.length() - 2, result.length()); } } returnResult.put(HttpClientService.RESPONSE_HEADERS, result.toString()); }
HeadersConsumer { public void consume(Map<String, String> returnResult) { StringBuilder result = new StringBuilder(); if (headers != null) { for (Header header : headers) { result.append(header.toString()).append("\r\n"); } if (result.length() != 0) { result.delete(result.length() - 2, result.length()); } } returnResult.put(HttpClientService.RESPONSE_HEADERS, result.toString()); } }
HeadersConsumer { public void consume(Map<String, String> returnResult) { StringBuilder result = new StringBuilder(); if (headers != null) { for (Header header : headers) { result.append(header.toString()).append("\r\n"); } if (result.length() != 0) { result.delete(result.length() - 2, result.length()); } } returnResult.put(HttpClientService.RESPONSE_HEADERS, result.toString()); }  }
HeadersConsumer { public void consume(Map<String, String> returnResult) { StringBuilder result = new StringBuilder(); if (headers != null) { for (Header header : headers) { result.append(header.toString()).append("\r\n"); } if (result.length() != 0) { result.delete(result.length() - 2, result.length()); } } returnResult.put(HttpClientService.RESPONSE_HEADERS, result.toString()); }  HeadersConsumer setHeaders(Header[] headers); void consume(Map<String, String> returnResult); }
HeadersConsumer { public void consume(Map<String, String> returnResult) { StringBuilder result = new StringBuilder(); if (headers != null) { for (Header header : headers) { result.append(header.toString()).append("\r\n"); } if (result.length() != 0) { result.delete(result.length() - 2, result.length()); } } returnResult.put(HttpClientService.RESPONSE_HEADERS, result.toString()); }  HeadersConsumer setHeaders(Header[] headers); void consume(Map<String, String> returnResult);  }